From f89a815b47a839d240ddcea313cc8715456bd16e Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Wed, 15 Dec 2010 22:00:13 -0500 Subject: [PATCH] Updated commenting to use ajax --- review/views.py | 7 +++++-- templates/review/edit.html | 32 +++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/review/views.py b/review/views.py index d14ee16..fd19ef4 100755 --- a/review/views.py +++ b/review/views.py @@ -1,4 +1,4 @@ -from django.http import Http404, HttpResponseRedirect +from django.http import Http404, HttpResponse, HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext from django.core.urlresolvers import reverse @@ -55,4 +55,7 @@ def add_comment(request): comment.author = request.user comment.path = diff.b.path if diff.b else diff.a.path comment.save() - return HttpResponseRedirect(reverse(edit, args=[review.pk])) + data = RequestContext(request, { + 'comment': comment, + }) + return render_to_response('components/comment.html', data) diff --git a/templates/review/edit.html b/templates/review/edit.html index 8d0a7cc..a7dc8c6 100644 --- a/templates/review/edit.html +++ b/templates/review/edit.html @@ -15,8 +15,7 @@ var line_b = info[3]; if ($('#' + form_id).length == 0) { // Show the comment form - $(this).after( - '' + + var form = $( '
' + "{% csrf_token %}" + '' + @@ -26,9 +25,28 @@ '