• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python views_helpers.api_response函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中views_helpers.api_response函数的典型用法代码示例。如果您正苦于以下问题:Python api_response函数的具体用法?Python api_response怎么用?Python api_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了api_response函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: generate_icalendar_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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:30,代码来源:api_v1_views.py


示例2: generate_icalendar_track

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()
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:14,代码来源:api_v1_views.py


示例3: get_languages

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'
    )
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:8,代码来源:views.py


示例4: get_microlocations

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:8,代码来源:api_v1_views.py


示例5: get_formats

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'
    )
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:8,代码来源:views.py


示例6: get_sponsors

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:8,代码来源:api_v1_views.py


示例7: get_tracks

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:8,代码来源:api_v1_views.py


示例8: get_sessions

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:8,代码来源:api_v1_views.py


示例9: get_microlocations_per_page

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
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例10: get_formatsper_page

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
    )
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:9,代码来源:views.py


示例11: get_sponsors_per_page

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
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例12: get_speaker_by_id

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例13: get_tracks_per_page

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
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例14: get_event_version

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例15: get_session_by_id

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例16: get_event_by_id

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例17: get_sessions_per_page

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
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:9,代码来源:api_v1_views.py


示例18: get_languages_per_page

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
    )
开发者ID:shivamMg,项目名称:open-event-orga-server,代码行数:9,代码来源:views.py


示例19: get_sessions_at_event

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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:11,代码来源:api_v1_views.py


示例20: get_speakers_at_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'
    )
开发者ID:deepakpathania,项目名称:open-event-orga-server,代码行数:11,代码来源:api_v1_views.py



注:本文中的views_helpers.api_response函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gettext.translate函数代码示例发布时间:2022-05-26
下一篇:
Python db.drop_all函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap