This patch against django svn 20060611 adds the freshly posted comment
to the 'posted' template thus allowing to show the comment or link
via an anchor to the comment. E.g.
<a href="{{ object.get_absolute_url }}#comment-{{ comment.id }}">View Comment</a>
--Maximillian Dornseif
|
|
|
252 | 252 | else: |
253 | 253 | manipulator.do_html2python(new_data) |
254 | 254 | comment = manipulator.save(new_data) |
255 | | return HttpResponseRedirect("../posted/?c=%s:%s" % (content_type_id, object_id)) |
| 255 | return HttpResponseRedirect("../posted/?c=%s:%s&ic=%s" % (content_type_id, object_id, comment.id)) |
256 | 256 | else: |
257 | 257 | raise Http404, _("The comment form didn't provide either 'preview' or 'post'") |
258 | 258 | |
… |
… |
|
316 | 316 | else: |
317 | 317 | manipulator.do_html2python(new_data) |
318 | 318 | comment = manipulator.save(new_data) |
319 | | return HttpResponseRedirect("../posted/?c=%s:%s" % (content_type_id, object_id)) |
| 319 | return HttpResponseRedirect("../posted/?c=%s:%s&if=%s" % (content_type_id, object_id, comment.id)) |
320 | 320 | else: |
321 | 321 | raise Http404, _("The comment form didn't provide either 'preview' or 'post'") |
322 | 322 | |
… |
… |
|
330 | 330 | The object the comment was posted on |
331 | 331 | """ |
332 | 332 | obj = None |
| 333 | comment = None |
333 | 334 | if request.GET.has_key('c'): |
334 | 335 | content_type_id, object_id = request.GET['c'].split(':') |
335 | 336 | try: |
… |
… |
|
337 | 338 | obj = content_type.get_object_for_this_type(pk=object_id) |
338 | 339 | except ObjectDoesNotExist: |
339 | 340 | pass |
340 | | return render_to_response('comments/posted.html', {'object': obj}, context_instance=RequestContext(request)) |
| 341 | try: |
| 342 | comment_id = request.GET['if'] |
| 343 | comment = FreeComment.objects.get(pk=comment_id) |
| 344 | except ObjectDoesNotExist: |
| 345 | pass |
| 346 | try: |
| 347 | comment_id = request.GET['ic'] |
| 348 | comment = Comment.objects.get(pk=comment_id) |
| 349 | except ObjectDoesNotExist: |
| 350 | pass |
| 351 | return render_to_response('comments/posted.html', {'object': obj, 'comment': comment}, context_instance=RequestContext(request)) |