本文整理汇总了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")
示例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)