summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander2015-02-04 20:08:32 +0000
committerMagnus Hagander2015-02-04 20:08:32 +0000
commit5ec1b2a727eba4e3f4a70028a975d12dffc03ccb (patch)
tree2adae3514781688e2a6dac65b9e4064031e7818a
parent12de0f70e0bd94b2ffccc347df2420cd5cf5ecb4 (diff)
Show a message when a thread is re-added to the same message
-rw-r--r--pgcommitfest/commitfest/ajax.py10
-rw-r--r--pgcommitfest/commitfest/static/commitfest/js/commitfest.js3
2 files changed, 6 insertions, 7 deletions
diff --git a/pgcommitfest/commitfest/ajax.py b/pgcommitfest/commitfest/ajax.py
index d1d8bcb..f489d12 100644
--- a/pgcommitfest/commitfest/ajax.py
+++ b/pgcommitfest/commitfest/ajax.py
@@ -86,10 +86,7 @@ def attachThread(request):
patch = get_object_or_404(Patch, pk=int(request.POST['p']), commitfests=cf)
msgid = request.POST['msg']
- if doAttachThread(cf, patch, msgid, request.user):
- return 'OK'
- else:
- raise Exception("Something happened that cannot happen")
+ return doAttachThread(cf, patch, msgid, request.user)
def doAttachThread(cf, patch, msgid, user):
# Note! Must be called in an open transaction!
@@ -101,8 +98,7 @@ def doAttachThread(cf, patch, msgid, user):
if len(threads):
thread = threads[0]
if thread.patches.filter(id=patch.id).exists():
- # We have everything, so claim we're done.
- return True
+ return 'This thread is already added to this email'
# We did not exist, so we'd better add ourselves.
# While at it, we update the thread entry with the latest data from the
@@ -135,7 +131,7 @@ def doAttachThread(cf, patch, msgid, user):
patch.set_modified()
patch.save()
- return True
+ return 'OK'
@transaction.commit_on_success
def detachThread(request):
diff --git a/pgcommitfest/commitfest/static/commitfest/js/commitfest.js b/pgcommitfest/commitfest/static/commitfest/js/commitfest.js
index ca49f61..f1797ff 100644
--- a/pgcommitfest/commitfest/static/commitfest/js/commitfest.js
+++ b/pgcommitfest/commitfest/static/commitfest/js/commitfest.js
@@ -98,6 +98,9 @@ function doAttachThread(cfid, patchid, msgid, reloadonsuccess) {
'p': patchid,
'msg': msgid,
}).success(function(data) {
+ if (data != 'OK') {
+ alert(data);
+ }
if (reloadonsuccess)
location.reload();
return true;