本文整理汇总了Python中issues.models.Issue.notify_created方法的典型用法代码示例。如果您正苦于以下问题:Python Issue.notify_created方法的具体用法?Python Issue.notify_created怎么用?Python Issue.notify_created使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类issues.models.Issue
的用法示例。
在下文中一共展示了Issue.notify_created方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resource_report
# 需要导入模块: from issues.models import Issue [as 别名]
# 或者: from issues.models.Issue import notify_created [as 别名]
def resource_report(request, object_id, template_name='depot/resource_report.html'):
"""
View for reporting a report when a user finds a problem with it.
"""
resource = get_one_or_404(Resource, id=ObjectId(object_id))
reporter=get_account(request.user.id)
# if 'next' in request.GET:
# url = request.GET['next']
# else:
# url = None
# url = url or reverse('resource', args=[resource.id])
if Issue.objects(reporter=reporter, related_document=resource).count():
messages.warning(request, 'You have already reported this resource.')
return HttpResponseRedirect(reverse('resource', args=[resource.id]))
if request.method == 'POST':
form = ResourceReportForm(request.POST)
if form.is_valid():
severity=int(form.cleaned_data['severity'])
message=form.cleaned_data['message']
issue = Issue(
message=message,
severity=severity,
reporter=reporter)
issue.related_document = resource
issue.save()
issue.notify_created()
# only moderate as STATUS_BAD if SEVERITY_CRITICAL
if severity == SEVERITY_CRITICAL:
resource.moderate_as_bad(reporter)
return HttpResponseRedirect(reverse('issue_detail', args=[issue.id]))
else:
form = ResourceReportForm()
return render_to_response(template_name, {
'next': urlquote_plus(request.GET.get('next', '')),
'form': form,
'object': resource,
}, RequestContext(request))