Esempio n. 1
0
def resolve(request, slug=None, template_name="issues/resolve.html"):
    issue = get_object_or_404(Issue, slug=slug)
    
    has_papers = issue.papers.exists()
    
    resolution_form = ResolutionForm(request.POST or None, issue=issue)
    
    if resolution_form.is_valid():
        resolution = resolution_form.save()
        
        issue.register_action(request.user, 'resolve', resolution)
        
        return HttpResponseRedirect(issue.get_absolute_url())
    
    return render_to_response(template_name, {
        'issue': issue,
        'resolution_form': resolution_form,
        'has_papers': has_papers,
    }, context_instance=RequestContext(request))
Esempio n. 2
0
def resolve(request, slug=None, template_name="issues/resolve.html"):
    issue = get_object_or_404(Issue, slug=slug)
    
    has_papers = issue.papers.exists()
    
    resolution_form = ResolutionForm(request.POST or None, issue=issue)
    
    if resolution_form.is_valid():
        resolution_paper = resolution_form.cleaned_data['resolution']
        if issue.resolve(resolution_paper):
            issue.register_action(request.user, 'resolve-issue', resolution_paper)
        else:
            messages.add_message(request, messages.ERROR,
                _("Sorry, the paper you selected is not associated with this issue.")
            )
        return HttpResponseRedirect(issue.get_absolute_url())
    
    return render_to_response(template_name, {
        'issue': issue,
        'resolution_form': resolution_form,
        'has_papers': has_papers,
    }, context_instance=RequestContext(request))