Ticket #5961: template_name_comments.diff

File template_name_comments.diff, 6.4 KB (added by Ryan Kaskel <ryan@…>, 7 years ago)
  • django/contrib/comments/views/karma.py

     
    44from django.contrib.comments.models import Comment, KarmaScore
    55from django.utils.translation import ugettext as _
    66
    7 def vote(request, comment_id, vote, extra_context=None, context_processors=None):
     7def vote(request, comment_id, vote, template_name='comments/karma_vote_accepted.html',
     8         extra_context=None, context_processors=None):
    89    """
    910    Rate a comment (+1 or -1)
    1011
     
    2829    KarmaScore.objects.vote(request.user.id, comment_id, rating)
    2930    # Reload comment to ensure we have up to date karma count
    3031    comment = Comment.objects.get(pk=comment_id)
    31     return render_to_response('comments/karma_vote_accepted.html', {'comment': comment},
     32    return render_to_response(template_name, {'comment': comment},
    3233        context_instance=RequestContext(request, extra_context, context_processors))
  • django/contrib/comments/views/userflags.py

     
    66from django.http import HttpResponseRedirect
    77from django.conf import settings
    88
    9 def flag(request, comment_id, extra_context=None, context_processors=None):
     9def flag(request, comment_id, template_name='comments/flag_verify.html',
     10         extra_context=None, context_processors=None):
    1011    """
    1112    Flags a comment. Confirmation on GET, action on POST.
    1213
     
    2021    if request.POST:
    2122        UserFlag.objects.flag(comment, request.user)
    2223        return HttpResponseRedirect('%sdone/' % request.path)
    23     return render_to_response('comments/flag_verify.html', {'comment': comment},
     24    return render_to_response(template_name, {'comment': comment},
    2425        context_instance=RequestContext(request, extra_context, context_processors))
    2526flag = login_required(flag)
    2627
    27 def flag_done(request, comment_id, extra_context=None, context_processors=None):
     28def flag_done(request, comment_id, template_name='comments/flag_done.html',
     29              extra_context=None, context_processors=None):
    2830    if extra_context is None: extra_context = {}
    2931    comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID)
    30     return render_to_response('comments/flag_done.html', {'comment': comment},
     32    return render_to_response(template_name, {'comment': comment},
    3133        context_instance=RequestContext(request, extra_context, context_processors))
    3234
    33 def delete(request, comment_id, extra_context=None, context_processors=None):
     35def delete(request, comment_id, template_name='comments/delete_verify.html',
     36           extra_context=None, context_processors=None):
    3437    """
    3538    Deletes a comment. Confirmation on GET, action on POST.
    3639
     
    5154            m = ModeratorDeletion(None, request.user.id, comment.id, None)
    5255            m.save()
    5356        return HttpResponseRedirect('%sdone/' % request.path)
    54     return render_to_response('comments/delete_verify.html', {'comment': comment},
     57    return render_to_response(template_name, {'comment': comment},
    5558        context_instance=RequestContext(request, extra_context, context_processors))
    5659delete = login_required(delete)
    5760
    58 def delete_done(request, comment_id, extra_context=None, context_processors=None):
     61def delete_done(request, comment_id, template_name='comments/delete_done.html',
     62                extra_context=None, context_processors=None):
    5963    if extra_context is None: extra_context = {}
    6064    comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID)
    61     return render_to_response('comments/delete_done.html', {'comment': comment},
     65    return render_to_response(template_name, {'comment': comment},
    6266        context_instance=RequestContext(request, extra_context, context_processors))
  • django/contrib/comments/views/comments.py

     
    155155        c.save()
    156156        return c
    157157
    158 def post_comment(request, extra_context=None, context_processors=None):
     158def post_comment(request, template_name='comments/preview.html', extra_context=None, context_processors=None):
    159159    """
    160160    Post a comment
    161161
     
    234234                return field_list
    235235        comment = errors and '' or manipulator.get_comment(new_data)
    236236        comment_form = CommentFormWrapper(manipulator, new_data, errors, rating_choices)
    237         return render_to_response('comments/preview.html', {
     237        return render_to_response(template_name, {
    238238            'comment': comment,
    239239            'comment_form': comment_form,
    240240            'options': options,
     
    258258    else:
    259259        raise Http404, _("The comment form didn't provide either 'preview' or 'post'")
    260260
    261 def post_free_comment(request, extra_context=None, context_processors=None):
     261def post_free_comment(request, template_name='comments/free_preview.html', extra_context=None, context_processors=None):
    262262    """
    263263    Post a free comment (not requiring a log in)
    264264
     
    303303    errors = manipulator.get_validation_errors(new_data)
    304304    if errors or 'preview' in request.POST:
    305305        comment = errors and '' or manipulator.get_comment(new_data)
    306         return render_to_response('comments/free_preview.html', {
     306        return render_to_response(template_name, {
    307307            'comment': comment,
    308308            'comment_form': oldforms.FormWrapper(manipulator, new_data, errors),
    309309            'options': options,
     
    323323    else:
    324324        raise Http404, _("The comment form didn't provide either 'preview' or 'post'")
    325325
    326 def comment_was_posted(request, extra_context=None, context_processors=None):
     326def comment_was_posted(request, template_name='comments/posted.html', extra_context=None, context_processors=None):
    327327    """
    328328    Display "comment was posted" success page
    329329
     
    341341            obj = content_type.get_object_for_this_type(pk=object_id)
    342342        except ObjectDoesNotExist:
    343343            pass
    344     return render_to_response('comments/posted.html', {'object': obj},
     344    return render_to_response(template_name, {'object': obj},
    345345        context_instance=RequestContext(request, extra_context, context_processors))
Back to Top