本文整理汇总了Python中models.user.User.get_by_checkin_code方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_checkin_code方法的具体用法?Python User.get_by_checkin_code怎么用?Python User.get_by_checkin_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.get_by_checkin_code方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: favourites_ical
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_checkin_code [as 别名]
def favourites_ical():
code = request.args.get('token', None)
user = None
if code:
user = User.get_by_checkin_code(app.config.get('FEED_SECRET_KEY'), str(code))
if not current_user.is_anonymous:
user = current_user
if not user:
abort(404)
schedule = _get_scheduled_proposals(request.args, override_user=user)
title = 'EMF {} Favourites for {}'.format(event_start().year, user.name)
cal = Calendar()
cal.add('summary', title)
cal.add('X-WR-CALNAME', title)
cal.add('X-WR-CALDESC', title)
cal.add('version', '2.0')
for event in schedule:
if not event['is_fave']:
continue
cal_event = Event()
cal_event.add('uid', event['id'])
cal_event.add('summary', event['title'])
cal_event.add('description', event['description'])
cal_event.add('location', event['venue'])
cal_event.add('dtstart', event['start_date'])
cal_event.add('dtend', event['end_date'])
cal.add_component(cal_event)
return Response(cal.to_ical(), mimetype='text/calendar')
示例2: checkin_qrcode
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_checkin_code [as 别名]
def checkin_qrcode(code):
match = re.match('%s$' % checkin_code_re, code)
if not match:
abort(404)
user = User.get_by_checkin_code(app.config.get('SECRET_KEY'), code)
return redirect(url_for('.checkin', user_id=user.id, source='code'))
示例3: user_from_code
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_checkin_code [as 别名]
def user_from_code(query):
if not query:
return None
# QR code
match = re.match(re.escape(app.config.get('CHECKIN_BASE')) + '(%s)$' % checkin_code_re, query)
if not match:
# Barcode
match = re.match('(%s)$' % checkin_code_re, query)
if not match:
return None
code = match.group(1)
user = User.get_by_checkin_code(app.config.get('SECRET_KEY'), code)
return user
示例4: favourites_json
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_checkin_code [as 别名]
def favourites_json():
code = request.args.get('token', None)
user = None
if code:
user = User.get_by_checkin_code(app.config.get('FEED_SECRET_KEY'), str(code))
if not current_user.is_anonymous:
user = current_user
if not user:
abort(404)
def convert_time_to_str(event):
event['start_date'] = event['start_date'].strftime('%Y-%m-%d %H:%M:00')
event['end_date'] = event['end_date'].strftime('%Y-%m-%d %H:%M:00')
return event
schedule = [convert_time_to_str(p) for p in _get_scheduled_proposals(request.args, override_user=user) if p['is_fave']]
# NB this is JSON in a top-level array (security issue for low-end browsers)
return Response(json.dumps(schedule), mimetype='application/json')