Ticket #3091: comments.patch

File comments.patch, 3.1 KB (added by Eric Floehr <eric@…>, 17 years ago)

Patch to django.contrib.comments.views methods

  • comments.py

     
    154154        c.save()
    155155        return c
    156156
    157 def post_comment(request):
     157def post_comment(request, extra_context=None, context_processors=None):
    158158    """
    159159    Post a comment
    160160
     
    232232                return field_list
    233233        comment = errors and '' or manipulator.get_comment(new_data)
    234234        comment_form = CommentFormWrapper(manipulator, new_data, errors, rating_choices)
     235        if extra_context is None: extra_context = {}
    235236        return render_to_response('comments/preview.html', {
    236237            'comment': comment,
    237238            'comment_form': comment_form,
     
    243244            'ratings_required': RATINGS_REQUIRED in option_list,
    244245            'rating_range': rating_range,
    245246            'rating_choices': rating_choices,
    246         }, context_instance=RequestContext(request))
     247        }, context_instance=RequestContext(request, extra_context, context_processors))
    247248    elif request.POST.has_key('post'):
    248249        # If the IP is banned, mail the admins, do NOT save the comment, and
    249250        # serve up the "Thanks for posting" page as if the comment WAS posted.
     
    256257    else:
    257258        raise Http404, _("The comment form didn't provide either 'preview' or 'post'")
    258259
    259 def post_free_comment(request):
     260def post_free_comment(request, extra_context=None, context_processors=None):
    260261    """
    261262    Post a free comment (not requiring a log in)
    262263
     
    300301    errors = manipulator.get_validation_errors(new_data)
    301302    if errors or request.POST.has_key('preview'):
    302303        comment = errors and '' or manipulator.get_comment(new_data)
     304        if extra_context is None: extra_context = {}
    303305        return render_to_response('comments/free_preview.html', {
    304306            'comment': comment,
    305307            'comment_form': forms.FormWrapper(manipulator, new_data, errors),
    306308            'options': options,
    307309            'target': target,
    308310            'hash': security_hash,
    309         }, context_instance=RequestContext(request))
     311        }, context_instance=RequestContext(request, extra_context, context_processors))
    310312    elif request.POST.has_key('post'):
    311313        # If the IP is banned, mail the admins, do NOT save the comment, and
    312314        # serve up the "Thanks for posting" page as if the comment WAS posted.
     
    320322    else:
    321323        raise Http404, _("The comment form didn't provide either 'preview' or 'post'")
    322324
    323 def comment_was_posted(request):
     325def comment_was_posted(request, extra_context=None, context_processors=None):
    324326    """
    325327    Display "comment was posted" success page
    326328
     
    337339            obj = content_type.get_object_for_this_type(pk=object_id)
    338340        except ObjectDoesNotExist:
    339341            pass
    340     return render_to_response('comments/posted.html', {'object': obj}, context_instance=RequestContext(request))
     342    if extra_context is None: extra_context = {}
     343    return render_to_response('comments/posted.html', {
     344        'object': obj
     345    }, context_instance=RequestContext(request, extra_context, context_processors))
Back to Top