From ab60a8ea86e2b4d0174a4bcdd6a7c1abdb78f9e5 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Fri, 17 May 2013 13:00:21 +0200 Subject: Dynamically insert replies in the thread Closes: #47 --- hyperkitty/static/css/hyperkitty-message.css | 6 +++- hyperkitty/static/js/hyperkitty.js | 7 +++-- hyperkitty/templates/messages/temp_message.html | 38 +++++++++++++++++++++++++ hyperkitty/views/message.py | 16 +++++++++-- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 hyperkitty/templates/messages/temp_message.html diff --git a/hyperkitty/static/css/hyperkitty-message.css b/hyperkitty/static/css/hyperkitty-message.css index edc5cab..3978015 100644 --- a/hyperkitty/static/css/hyperkitty-message.css +++ b/hyperkitty/static/css/hyperkitty-message.css @@ -194,7 +194,7 @@ } /* The email thread */ -.even, .odd { +.even, .odd, .temporary { border-top: 1px solid rgb(179, 179, 179); padding: 1em; margin: 20px 0px 20px 0px; @@ -205,6 +205,10 @@ .odd { background-color: rgb(238, 238, 238); } +.temporary { + background-color: rgb(215, 215, 229); + display: none; +} .email-body { white-space: pre; diff --git a/hyperkitty/static/js/hyperkitty.js b/hyperkitty/static/js/hyperkitty.js index ddebd09..a06aa79 100644 --- a/hyperkitty/static/js/hyperkitty.js +++ b/hyperkitty/static/js/hyperkitty.js @@ -202,14 +202,17 @@ function setup_replies(baseElem) { $.ajax({ type: "POST", url: form.attr("action"), - //dataType: "json", + dataType: "json", data: data, success: function(response) { + var reply = $(response.message_html); + reply.insertAfter(form.parents(".email").first().parent()); form.parents(".reply-form").first().slideUp(function() { form.find("textarea").val(""); + reply.slideDown(); }); $('
' - + response + '
') + + response.result + '') .appendTo(form.parents('.email-info').first()) .delay(2000).fadeOut('slow', function() { $(this).remove(); }); }, diff --git a/hyperkitty/templates/messages/temp_message.html b/hyperkitty/templates/messages/temp_message.html new file mode 100644 index 0000000..f518114 --- /dev/null +++ b/hyperkitty/templates/messages/temp_message.html @@ -0,0 +1,38 @@ +{% load url from future %} +{% load gravatar %} +{% load hk_generic %} + +
+ + + +
+ +{# vim: set noet: #} diff --git a/hyperkitty/views/message.py b/hyperkitty/views/message.py index e526977..25d1e6f 100644 --- a/hyperkitty/views/message.py +++ b/hyperkitty/views/message.py @@ -171,8 +171,20 @@ def reply(request, mlist_fqdn, message_id_hash): post_to_list(request, mlist, subject, form.cleaned_data["message"], headers) except PostingFailed, e: return HttpResponse(str(e), content_type="text/plain", status=500) - return HttpResponse("The reply has been sent successfully.", - mimetype="text/plain") + + reply = { + "sender_name": "%s %s" % (request.user.first_name, + request.user.last_name), + "sender_email": request.user.email, + "content": form.cleaned_data["message"], + "level": message.thread_depth, # no need to increment, level = thread_depth - 1 + } + t = loader.get_template('messages/temp_message.html') + html = t.render(RequestContext(request, { 'email': reply })) + result = {"result": "The reply has been sent successfully.", + "message_html": html} + return HttpResponse(json.dumps(result), + mimetype="application/javascript") @login_required -- cgit