本文整理汇总了Python中models.Report.content方法的典型用法代码示例。如果您正苦于以下问题:Python Report.content方法的具体用法?Python Report.content怎么用?Python Report.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.content方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_report
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import content [as 别名]
def set_report(name, content):
report = Report.find_by_name(name)
if report is None:
report = Report()
report.name = name
report.content = content
report.put()
示例2: addreport
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import content [as 别名]
def addreport(request):
if request.method == 'POST':
form = ReportForm(request.POST)
if form.is_valid():
report = Report()
report.headline = form.cleaned_data.get("headline")
report.content = form.cleaned_data.get("content")
report.reporter = request.user.username
report.date = datetime.now()
report.save()
return HttpResponseRedirect(reverse('news:index'))
else:
form = ReportForm()
return render_to_response('news/addreport.html', {'form':form}, context_instance=RequestContext(request))
示例3: api_submit
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import content [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