Exemplo n.º 1
0
def generate_icalendar_event(event_id):
    """Takes an event id and returns the event in iCal format"""
    cal = Calendar()
    event = icalendar.Event()
    matching_event = Event.query.get(event_id)
    if matching_event is None:
        return api_response(status_code=404, error='Event')
    event.add('summary', matching_event.name)
    event.add('geo', (matching_event.latitude, matching_event.longitude))
    event.add('location', matching_event.location_name)
    event.add('color', matching_event.color)
    event.add('dtstart', matching_event.start_time)
    event.add('dtend', matching_event.end_time)
    event.add('logo', matching_event.logo)
    event.add('email', matching_event.email)
    event.add('description', matching_event.description)
    event.add(
        'url',
        url_for('event_detail.display_event_detail_home',
                identifier=matching_event.identifier,
                _external=True))
    cal.add_component(event)

    #Saving ical in file
    filename = "event_calendar/event-calendar-" + str(event_id) + ".ics"
    f = open(os.path.join(os.path.realpath('.') + '/static/', filename), 'wb')
    f.write(cal.to_ical())
    f.close()

    return api_response(data=jsonify(calendar=str(cal.to_ical),
                                     filename=filename),
                        status_code=event_status_code(event_id),
                        error='Event')
def generate_icalendar_event(event_id):
    """Takes an event id and returns the event in iCal format"""
    cal = Calendar()
    event = icalendar.Event()
    matching_event = Event.query.get(event_id)
    if matching_event is None:
        return api_response(status_code=404, error='Event')
    event.add('summary', matching_event.name)
    event.add('geo', (matching_event.latitude, matching_event.longitude))
    event.add('location', matching_event.location_name)
    event.add('color', matching_event.color)
    event.add('dtstart', matching_event.start_time)
    event.add('dtend', matching_event.end_time)
    event.add('logo', matching_event.logo)
    event.add('email', matching_event.email)
    event.add('description', matching_event.description)
    event.add('url', matching_event.event_url)
    cal.add_component(event)

    #Saving ical in file
    filename = "event_calendar/event-calendar-" + str(event_id) + ".ics"
    f = open(os.path.join(os.path.realpath('.') + '/static/', filename), 'wb')
    f.write(cal.to_ical())
    f.close()

    return api_response(
        data=jsonify(calendar=str(cal.to_ical), filename=filename),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 3
0
def generate_icalendar_track(event_id, track_id):
    """Takes a track id and returns the track in iCal format"""
    cal = Calendar()
    track = icalendar.Event()
    matching_track = Track.query.get(track_id)
    if matching_track is None:
        return api_response(status_code=404, error='Track')
    if matching_track.event_id != event_id:
        return api_response(status_code=404, error='Event')
    track.add('summary', matching_track.name)
    track.add('description', matching_track.description)
    track.add('url', matching_track.track_image_url)
    cal.add_component(track)
    return cal.to_ical()
def generate_icalendar_track(event_id, track_id):
    """Takes a track id and returns the track in iCal format"""
    cal = Calendar()
    track = icalendar.Event()
    matching_track = Track.query.get(track_id)
    if matching_track is None:
        return api_response(status_code=404, error='Track')
    if matching_track.event_id != event_id:
        return api_response(status_code=404, error='Event')
    track.add('summary', matching_track.name)
    track.add('description', matching_track.description)
    track.add('url', matching_track.track_image_url)
    cal.add_component(track)
    return cal.to_ical()
Exemplo n.º 5
0
def get_sessions(event_id):
    """Returns all event's sessions"""
    sessions = Session.query.filter_by(event_id=event_id, is_accepted=True)
    return api_response(data=ObjectFormatter.get_json("sessions", sessions,
                                                      request),
                        status_code=event_status_code(event_id),
                        error='Event')
Exemplo n.º 6
0
def get_event_version(event_id):
    """Returns event's the latest version"""
    version = Version.query.filter_by(event_id=event_id).order_by(
        Version.id.desc()).first()
    if version:
        return jsonify(version.serialize)
    return api_response(status_code=404, error='Version')
Exemplo n.º 7
0
def get_sponsors(event_id):
    """Returns all event's sponsors"""
    sponsors = Sponsor.query.filter_by(event_id=event_id)
    return api_response(data=ObjectFormatter.get_json("sponsors", sponsors,
                                                      request),
                        status_code=event_status_code(event_id),
                        error='Event')
Exemplo n.º 8
0
def get_microlocations(event_id):
    """Returns all event's microlocations"""
    microlocations = Microlocation.query.filter_by(event_id=event_id)
    return api_response(data=ObjectFormatter.get_json("microlocations",
                                                      microlocations, request),
                        status_code=event_status_code(event_id),
                        error='Event')
Exemplo n.º 9
0
def get_tracks(event_id):
    """Returns all event's tracks"""
    tracks = Track.query.filter_by(event_id=event_id)
    return api_response(data=ObjectFormatter.get_json("tracks", tracks,
                                                      request),
                        status_code=event_status_code(event_id),
                        error='Event')
def get_tracks(event_id):
    """Returns all event's tracks"""
    tracks = Track.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("tracks", tracks, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
def get_sponsors(event_id):
    """Returns all event's sponsors"""
    sponsors = Sponsor.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("sponsors", sponsors, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 12
0
def get_tracks_per_page(event_id, page):
    """Returns 20 event's tracks"""
    tracks = Track.query.filter_by(event_id=event_id)
    return api_response(data=ObjectFormatter.get_json("tracks", tracks,
                                                      request, page),
                        status_code=event_status_code(event_id),
                        error='Event',
                        check_data=True)
Exemplo n.º 13
0
def get_formats(event_id):
    """Returns all event's formats"""
    formats = Format.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("formats", formats, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 14
0
def get_languages(event_id):
    """Returns all event's languages"""
    languages = Language.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("languages", languages, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 15
0
def get_sessions_per_page(event_id, page):
    """Returns 20 event's sessions"""
    sessions = Session.query.filter_by(event_id=event_id, is_accepted=True)
    return api_response(data=ObjectFormatter.get_json("sessions", sessions,
                                                      request, page),
                        status_code=event_status_code(event_id),
                        error='Event',
                        check_data=True)
def get_sessions(event_id):
    """Returns all event's sessions"""
    sessions = Session.query.filter_by(event_id=event_id, is_accepted=True)
    return api_response(
        data=ObjectFormatter.get_json("sessions", sessions, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 17
0
def get_sponsors_per_page(event_id, page):
    """Returns 20 event's sponsors"""
    sponsors = Sponsor.query.filter_by(event_id=event_id)
    return api_response(data=ObjectFormatter.get_json("sponsors", sponsors,
                                                      request, page),
                        status_code=event_status_code(event_id),
                        error='Event',
                        check_data=True)
def get_microlocations(event_id):
    """Returns all event's microlocations"""
    microlocations = Microlocation.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("microlocations", microlocations, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
def get_event_version(event_id):
    """Returns event's the latest version"""
    version = Version.query.filter_by(event_id=event_id).order_by(Version.id.desc()).first()
    if version:
        return jsonify(version.serialize)
    return api_response(
        status_code=404,
        error='Version'
    )
def get_session_by_id(session_id):
    """Returns a session's data by session id"""
    session = DataGetter.get_session(session_id)
    if session:
        return jsonify(session.serialize)
    return api_response(
        status_code=404,
        error='Session'
    )
def get_session_by_id(session_id):
    """Returns a session's data by session id"""
    session = DataGetter.get_session(session_id)
    if session:
        return jsonify(session.serialize)
    return api_response(
        status_code=404,
        error='Session'
    )
def get_event_by_id(event_id):
    """Returns events by event id"""
    event = DataGetter.get_event(event_id)
    if event:
        return jsonify({"events": event.serialize})
    return api_response(
        status_code=404,
        error='Event'
    )
def get_sessions_per_page(event_id, page):
    """Returns 20 event's sessions"""
    sessions = Session.query.filter_by(event_id=event_id, is_accepted=True)
    return api_response(
        data=ObjectFormatter.get_json("sessions", sessions, request, page),
        status_code=event_status_code(event_id),
        error='Event',
        check_data=True
    )
Exemplo n.º 24
0
def get_formatsper_page(event_id, page):
    """Returns 20 event's formats"""
    formats = Format.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("formats", formats, request, page),
        status_code=event_status_code(event_id),
        error='Event',
        check_data=True
    )
def get_tracks_per_page(event_id, page):
    """Returns 20 event's tracks"""
    tracks = Track.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("tracks", tracks, request, page),
        status_code=event_status_code(event_id),
        error='Event',
        check_data=True
    )
def get_speaker_by_id(speaker_id):
    """Return speaker data by speaker id"""
    speaker = DataGetter.get_speaker(speaker_id)
    if speaker:
        return jsonify(speaker.serialize)
    return api_response(
        status_code=404,
        error='Speaker'
    )
def get_microlocations_per_page(event_id, page):
    """Returns 20 event's microlocations"""
    microlocations = Microlocation.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("microlocations", microlocations, request, page),
        status_code=event_status_code(event_id),
        error='Event',
        check_data=True
    )
def get_sponsors_per_page(event_id, page):
    """Returns 20 event's sponsors"""
    sponsors = Sponsor.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("sponsors", sponsors, request, page),
        status_code=event_status_code(event_id),
        error='Event',
        check_data=True
    )
def get_event_by_id(event_id):
    """Returns events by event id"""
    event = DataGetter.get_event(event_id)
    if event:
        return jsonify({"events": event.serialize})
    return api_response(
        status_code=404,
        error='Event'
    )
def get_speaker_by_id(speaker_id):
    """Return speaker data by speaker id"""
    speaker = DataGetter.get_speaker(speaker_id)
    if speaker:
        return jsonify(speaker.serialize)
    return api_response(
        status_code=404,
        error='Speaker'
    )
Exemplo n.º 31
0
def get_microlocations_per_page(event_id, page):
    """Returns 20 event's microlocations"""
    microlocations = Microlocation.query.filter_by(event_id=event_id)
    return api_response(data=ObjectFormatter.get_json("microlocations",
                                                      microlocations, request,
                                                      page),
                        status_code=event_status_code(event_id),
                        error='Event',
                        check_data=True)
Exemplo n.º 32
0
def get_languages_per_page(event_id, page):
    """Returns 20 event's languages"""
    languages = Language.query.filter_by(event_id=event_id)
    return api_response(
        data=ObjectFormatter.get_json("languages", languages, request, page),
        status_code=event_status_code(event_id),
        error='Event',
        check_data=True
    )
def get_sessions_at_event(event_id, session_title):
    """
    Returns all the sessions of a particular event which
    contain session_title string in their title
    """
    sessions = Session.query.filter(Session.event_id == event_id, Session.title.contains(session_title))
    return api_response(
        data=ObjectFormatter.get_json("sessions", sessions, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 34
0
def get_speakers_at_event(event_id, speaker_name):
    """
    Returns all the speakers of a particular event which
    contain speaker_name string in their name
    """
    speakers = Speaker.query.filter(Speaker.event_id == event_id,
                                    Speaker.name.contains(speaker_name))
    return api_response(data=ObjectFormatter.get_json("speakers", speakers,
                                                      request),
                        status_code=event_status_code(event_id),
                        error='Event')
Exemplo n.º 35
0
def get_sessions_at_event(event_id, session_title):
    """
    Returns all the sessions of a particular event which
    contain session_title string in their title
    """
    sessions = Session.query.filter(Session.event_id == event_id,
                                    Session.title.contains(session_title))
    return api_response(data=ObjectFormatter.get_json("sessions", sessions,
                                                      request),
                        status_code=event_status_code(event_id),
                        error='Event')
def get_speakers_at_event(event_id, speaker_name):
    """
    Returns all the speakers of a particular event which
    contain speaker_name string in their name
    """
    speakers = Speaker.query.filter(Speaker.event_id == event_id, Speaker.name.contains(speaker_name))
    return api_response(
        data=ObjectFormatter.get_json("speakers", speakers, request),
        status_code=event_status_code(event_id),
        error='Event'
    )
Exemplo n.º 37
0
def generate_icalendar_event(event_id):
    """Takes an event id and returns the event in iCal format"""
    cal = Calendar()
    event = icalendar.Event()
    matching_event = Event.query.get(event_id)
    if matching_event is None:
        return api_response(status_code=404, error='Event')
    event.add('summary', matching_event.name)
    event.add('geo', (matching_event.latitude, matching_event.longitude))
    event.add('location', matching_event.location_name)
    event.add('color', matching_event.color)
    event.add('dtstart', matching_event.start_time)
    event.add('dtend', matching_event.end_time)
    event.add('logo', matching_event.logo)
    event.add('email', matching_event.email)
    event.add('description', matching_event.slogan)
    event.add('url', matching_event.url)
    cal.add_component(event)
    return cal.to_ical()
Exemplo n.º 38
0
def get_events_per_page(page):
    """Returns 20 events per page"""
    return api_response(data=ObjectFormatter.get_json("events", Event.query,
                                                      request, page),
                        check_data=True)
def get_events_per_page(page):
    """Returns 20 events per page"""
    return api_response(
        data=ObjectFormatter.get_json("events", Event.query, request, page),
        check_data=True
    )