Ticket #3091: ticket_3091__rev_6186.diff
File ticket_3091__rev_6186.diff, 7.6 KB (added by , 17 years ago) |
---|
-
django/contrib/comments/views/karma.py
4 4 from django.contrib.comments.models import Comment, KarmaScore 5 5 from django.utils.translation import ugettext as _ 6 6 7 def vote(request, comment_id, vote ):7 def vote(request, comment_id, vote, extra_context=None, context_processors=None): 8 8 """ 9 9 Rate a comment (+1 or -1) 10 10 … … 13 13 comment 14 14 `comments.comments` object being rated 15 15 """ 16 if extra_context is None: extra_context = {} 16 17 rating = {'up': 1, 'down': -1}.get(vote, False) 17 18 if not rating: 18 19 raise Http404, "Invalid vote" … … 27 28 KarmaScore.objects.vote(request.user.id, comment_id, rating) 28 29 # Reload comment to ensure we have up to date karma count 29 30 comment = Comment.objects.get(pk=comment_id) 30 return render_to_response('comments/karma_vote_accepted.html', {'comment': comment}, context_instance=RequestContext(request)) 31 return render_to_response('comments/karma_vote_accepted.html', {'comment': comment}, 32 context_instance=RequestContext(request, extra_context, context_processors)) -
django/contrib/comments/views/userflags.py
6 6 from django.http import HttpResponseRedirect 7 7 from django.conf import settings 8 8 9 def flag(request, comment_id ):9 def flag(request, comment_id, extra_context=None, context_processors=None): 10 10 """ 11 11 Flags a comment. Confirmation on GET, action on POST. 12 12 … … 15 15 comment 16 16 the flagged `comments.comments` object 17 17 """ 18 if extra_context is None: extra_context = {} 18 19 comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID) 19 20 if request.POST: 20 21 UserFlag.objects.flag(comment, request.user) 21 22 return HttpResponseRedirect('%sdone/' % request.path) 22 return render_to_response('comments/flag_verify.html', {'comment': comment}, context_instance=RequestContext(request)) 23 return render_to_response('comments/flag_verify.html', {'comment': comment}, 24 context_instance=RequestContext(request, extra_context, context_processors)) 23 25 flag = login_required(flag) 24 26 25 def flag_done(request, comment_id): 27 def flag_done(request, comment_id, extra_context=None, context_processors=None): 28 if extra_context is None: extra_context = {} 26 29 comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID) 27 return render_to_response('comments/flag_done.html', {'comment': comment}, context_instance=RequestContext(request)) 30 return render_to_response('comments/flag_done.html', {'comment': comment}, 31 context_instance=RequestContext(request, extra_context, context_processors)) 28 32 29 def delete(request, comment_id ):33 def delete(request, comment_id, extra_context=None, context_processors=None): 30 34 """ 31 35 Deletes a comment. Confirmation on GET, action on POST. 32 36 … … 35 39 comment 36 40 the flagged `comments.comments` object 37 41 """ 42 if extra_context is None: extra_context = {} 38 43 comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID) 39 44 if not Comment.objects.user_is_moderator(request.user): 40 45 raise Http404 … … 46 51 m = ModeratorDeletion(None, request.user.id, comment.id, None) 47 52 m.save() 48 53 return HttpResponseRedirect('%sdone/' % request.path) 49 return render_to_response('comments/delete_verify.html', {'comment': comment}, context_instance=RequestContext(request)) 54 return render_to_response('comments/delete_verify.html', {'comment': comment}, 55 context_instance=RequestContext(request, extra_context, context_processors)) 50 56 delete = login_required(delete) 51 57 52 def delete_done(request, comment_id): 58 def delete_done(request, comment_id, extra_context=None, context_processors=None): 59 if extra_context is None: extra_context = {} 53 60 comment = get_object_or_404(Comment,pk=comment_id, site__id__exact=settings.SITE_ID) 54 return render_to_response('comments/delete_done.html', {'comment': comment}, context_instance=RequestContext(request)) 61 return render_to_response('comments/delete_done.html', {'comment': comment}, 62 context_instance=RequestContext(request, extra_context, context_processors)) -
django/contrib/comments/views/comments.py
155 155 c.save() 156 156 return c 157 157 158 def post_comment(request ):158 def post_comment(request, extra_context=None, context_processors=None): 159 159 """ 160 160 Post a comment 161 161 … … 185 185 rating_choices 186 186 choice of ratings 187 187 """ 188 if extra_context is None: extra_context = {} 188 189 if not request.POST: 189 190 raise Http404, _("Only POSTs are allowed") 190 191 try: … … 244 245 'ratings_required': RATINGS_REQUIRED in option_list, 245 246 'rating_range': rating_range, 246 247 'rating_choices': rating_choices, 247 }, context_instance=RequestContext(request ))248 }, context_instance=RequestContext(request, extra_context, context_processors)) 248 249 elif 'post' in request.POST: 249 250 # If the IP is banned, mail the admins, do NOT save the comment, and 250 251 # serve up the "Thanks for posting" page as if the comment WAS posted. … … 257 258 else: 258 259 raise Http404, _("The comment form didn't provide either 'preview' or 'post'") 259 260 260 def post_free_comment(request ):261 def post_free_comment(request, extra_context=None, context_processors=None): 261 262 """ 262 263 Post a free comment (not requiring a log in) 263 264 … … 277 278 security hash (must be included in a posted form to succesfully 278 279 post a comment). 279 280 """ 281 if extra_context is None: extra_context = {} 280 282 if not request.POST: 281 283 raise Http404, _("Only POSTs are allowed") 282 284 try: … … 307 309 'options': options, 308 310 'target': target, 309 311 'hash': security_hash, 310 }, context_instance=RequestContext(request ))312 }, context_instance=RequestContext(request, extra_context, context_processors)) 311 313 elif 'post' in request.POST: 312 314 # If the IP is banned, mail the admins, do NOT save the comment, and 313 315 # serve up the "Thanks for posting" page as if the comment WAS posted. … … 321 323 else: 322 324 raise Http404, _("The comment form didn't provide either 'preview' or 'post'") 323 325 324 def comment_was_posted(request ):326 def comment_was_posted(request, extra_context=None, context_processors=None): 325 327 """ 326 328 Display "comment was posted" success page 327 329 … … 330 332 object 331 333 The object the comment was posted on 332 334 """ 335 if extra_context is None: extra_context = {} 333 336 obj = None 334 337 if 'c' in request.GET: 335 338 content_type_id, object_id = request.GET['c'].split(':') … … 338 341 obj = content_type.get_object_for_this_type(pk=object_id) 339 342 except ObjectDoesNotExist: 340 343 pass 341 return render_to_response('comments/posted.html', {'object': obj}, context_instance=RequestContext(request)) 344 return render_to_response('comments/posted.html', {'object': obj}, 345 context_instance=RequestContext(request, extra_context, context_processors))