当前位置: 首页>>代码示例>>Python>>正文


Python Event.get_with_slug_user方法代码示例

本文整理汇总了Python中models.Event.get_with_slug_user方法的典型用法代码示例。如果您正苦于以下问题:Python Event.get_with_slug_user方法的具体用法?Python Event.get_with_slug_user怎么用?Python Event.get_with_slug_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Event的用法示例。


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

示例1: create_event

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_with_slug_user [as 别名]
def create_event(user, **kwargs):
    """
    server endpoint for creation of events

    events are created by the user of the neuaer plugin. for example
    when the user wants to invoke the plugin event upon bluetooth disconnection
    """
    req = CreateEventRequest(request, settings.EVENT)

    if not req.is_valid():
        return jsonify(**req.error_message)

    event_props = {
        'slug' : req.event.get('event_id', None),
        'redirect': req.event.get('after_config_redirect', None),
        'user': user
        }

    event = Event.get_with_slug_user(**event_props)

    # create the event if it doesn't already exist
    if not event:
        event = Event(**event_props)
        event.put()
    else:
        return jsonify(**error_responses('create_event', 'event_exists'))

    return jsonify(success="created")
开发者ID:neuaer,项目名称:python-example,代码行数:30,代码来源:views.py

示例2: decorated_view

# 需要导入模块: from models import Event [as 别名]
# 或者: from models.Event import get_with_slug_user [as 别名]
    def decorated_view(user, *args, **kwargs):
        format = kwargs.get('format', '')

        if not kwargs['slug']:
            return errorify(format, **error_responses('event_id_missing'))

        event = Event.get_with_slug_user(slug = kwargs['slug'], user = user)

        if not event:
            return errorify(format, **error_responses('event_missing'))

        return route(event, *args, **kwargs)
开发者ID:neuaer,项目名称:python-example,代码行数:14,代码来源:decorators.py


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