当前位置: 首页>>代码示例>>Python>>正文


Python Issue.notify_created方法代码示例

本文整理汇总了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))
开发者ID:majailievska,项目名称:engineclub,代码行数:47,代码来源:views.py


注:本文中的issues.models.Issue.notify_created方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。