本文整理汇总了Python中models.Report.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Report.to_dict方法的具体用法?Python Report.to_dict怎么用?Python Report.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.to_dict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reportsv1
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import to_dict [as 别名]
def reportsv1():
if not request.args or not request.args['key'] or request.args['key'] != IOS_API_KEY:
abort(401)
if request.method == "POST":
if not request.json or not 'google_places_id' in request.json or not 'crowd_level' in request.json:
abort(400)
report = Report(
google_places_id=request.json['google_places_id'],
crowd_level=request.json['crowd_level'])
if 'comments' in request.json:
report.populate(comments=request.json['comments'])
if 'ios_device_id' in request.json:
report.populate(ios_device_id=request.json['ios_device_id'])
if 'photo_url' in request.json:
report.populate(photo_url=request.json['photo_url'])
try:
# report.put()
return jsonify(report.to_dict())
except CapabilityDisabledError:
abort(400)
if len(request.args) == 1:
reports = Report.query().order(-Report.created_at).fetch(20)
return jsonify({"reports": [report.to_dict() for report in reports]})
if len(request.args) > 2:
abort(400)
if not request.args['google_places_id']:
abort(400)
google_places_id = request.args['google_places_id']
reports = Report.query(Report.google_places_id==google_places_id).order(-Report.created_at).fetch(20)
return jsonify({"reports": [report.to_dict() for report in reports]})