From: Magnus Hagander Date: Wed, 4 Feb 2015 20:01:17 +0000 (+0100) Subject: Fix attaching of threads whe not logged in X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=12de0f70e0bd94b2ffccc347df2420cd5cf5ecb4;p=pgcommitfest2.git Fix attaching of threads whe not logged in This needs to redirect to the login page and back, so the user is actually logged in when attaching. This was only partially ipmlemented before, it turns out. --- diff --git a/pgcommitfest/commitfest/static/commitfest/js/commitfest.js b/pgcommitfest/commitfest/static/commitfest/js/commitfest.js index 1ac3bc2..ca49f61 100644 --- a/pgcommitfest/commitfest/static/commitfest/js/commitfest.js +++ b/pgcommitfest/commitfest/static/commitfest/js/commitfest.js @@ -25,9 +25,13 @@ function findLatestThreads() { return false; } -function browseThreads(attachfunc) { +function browseThreads(attachfunc, closefunc) { $('#attachThreadList').find('option').remove(); $('#attachThreadMessageId').val(''); + $('#attachModal').off('hidden.bs.modal'); + $('#attachModal').on('hidden.bs.modal', function(e) { + if (closefunc) closefunc(); + }); $('#attachModal').modal(); findLatestThreads(); @@ -52,9 +56,16 @@ function browseThreads(attachfunc) { } -function attachThread(cfid, patchid) { +function attachThread(cfid, patchid, closefunc) { browseThreads(function(msgid) { - doAttachThread(cfid, patchid, msgid); + doAttachThread(cfid, patchid, msgid, !closefunc); + if (closefunc) { + /* We don't really care about closing it, we just reload immediately */ + closefunc(); + } + }, + function() { + if (closefunc) closefunc(); }); } @@ -81,13 +92,14 @@ function attachThreadChanged() { } } -function doAttachThread(cfid, patchid, msgid) { +function doAttachThread(cfid, patchid, msgid, reloadonsuccess) { $.post('/ajax/attachThread/', { 'cf': cfid, 'p': patchid, 'msg': msgid, }).success(function(data) { - location.reload(); + if (reloadonsuccess) + location.reload(); return true; }).fail(function(data) { if (data.status == 404) { diff --git a/pgcommitfest/commitfest/templates/patch.html b/pgcommitfest/commitfest/templates/patch.html index d09a175..2c504cf 100644 --- a/pgcommitfest/commitfest/templates/patch.html +++ b/pgcommitfest/commitfest/templates/patch.html @@ -58,7 +58,7 @@ {%if user.is_authenticated%}
{%else%} -
+
{%endif%}
{%for t in patch.mailthread_set.all%} @@ -147,5 +147,12 @@ $(document).ready(function() { $(o).tooltip(); }); }); +{%if attachnow%} +$(document).ready(function() { + attachThread({{cf.id}},{{patch.id}}, function() { + document.location.replace('/{{cf.id}}/{{patch.id}}/'); + }); +}); +{%endif%} {%endblock%} diff --git a/pgcommitfest/commitfest/views.py b/pgcommitfest/commitfest/views.py index b11ee88..3e0dcd1 100644 --- a/pgcommitfest/commitfest/views.py +++ b/pgcommitfest/commitfest/views.py @@ -207,6 +207,7 @@ def patch(request, cfid, patchid): 'is_this_committer': is_this_committer, 'is_reviewer': is_reviewer, 'committers': committers, + 'attachnow': request.GET.has_key('attachthreadnow'), 'title': patch.name, 'breadcrumbs': [{'title': cf.title, 'href': '/%s/' % cf.pk},], }, context_instance=RequestContext(request))