本文整理汇总了Python中models.Report.report_type方法的典型用法代码示例。如果您正苦于以下问题:Python Report.report_type方法的具体用法?Python Report.report_type怎么用?Python Report.report_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.report_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_submit
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import report_type [as 别名]
def api_submit():
try:
if not (0 <= int(request.form["type"]) < len(REPORT_TYPES)):
raise Exception("Invalid report type %s" % request.form["type"])
report = Report()
report.report_type = int(request.form["type"])
if "content" in request.form:
report.content = request.form["content"]
if "location" in request.form:
loc = request.form["location"].split(',')
report.geo_lat, report.geo_lng = float(loc[0]), float(loc[1])
report.set_city()
db.session.add(report)
db.session.commit()
img = request.files.get("photo", None)
if img:
img.save(os.path.join(app.config["IMAGE_FOLDER"], repr(report.id) + ".png"))
report.img_src = repr(report.id) + ".png"
vid = request.files.get("video", None)
if vid:
vid.save(os.path.join(app.config["VIDEO_FOLDER"], repr(report.id) + ".avi"))
report.vid_src = repr(report.id) + ".avi"
db.session.commit()
logger.info("API: Report %d was created", report.id)
return "%d" % report.id
except Exception, e:
logger.error("API: Report creation failed")
logger.error("Exception: %s", str(e))
res = Response(status = 500)
return res