diff options
author | Magnus Hagander | 2015-02-04 20:01:17 +0000 |
---|---|---|
committer | Magnus Hagander | 2015-02-04 20:01:17 +0000 |
commit | 12de0f70e0bd94b2ffccc347df2420cd5cf5ecb4 (patch) | |
tree | 8675ed09726abd13c920d1ec05a2d35256cd5cf4 | |
parent | 381c48a49d469b1a94f9d5bf59ede6a35e752af9 (diff) |
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.
-rw-r--r-- | pgcommitfest/commitfest/static/commitfest/js/commitfest.js | 22 | ||||
-rw-r--r-- | pgcommitfest/commitfest/templates/patch.html | 9 | ||||
-rw-r--r-- | pgcommitfest/commitfest/views.py | 1 |
3 files changed, 26 insertions, 6 deletions
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%} <div style="float:right"><button class="btn btn-default" onclick="attachThread({{cf.id}},{{patch.id}})">Attach thread</button></div> {%else%} - <div style="float:right"><button class="btn btn-default" onclick="location.href='/https/git.postgresql.org/login_and_redirect_back'">Attach thread</button></div> + <div style="float:right"><button class="btn btn-default" onclick="location.href='/https/git.postgresql.org/account/login/?next=/{{cf.id}}/{{patch.id}}/%3Fattachthreadnow'">Attach thread</button></div> {%endif%} <dl> {%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%} </script> {%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)) |