summaryrefslogtreecommitdiff
path: root/pgcommitfest/commitfest/ajax.py
diff options
context:
space:
mode:
authorMagnus Hagander2013-07-19 15:04:01 +0000
committerMagnus Hagander2013-07-19 15:04:01 +0000
commite70b670283d3b768b5f73fcef46e7549c59d84b7 (patch)
tree90305da114ca52597b9b198f894764f5d167659c /pgcommitfest/commitfest/ajax.py
parent5a7e76780ad670ea330c4c4a64df8da1b95364a2 (diff)
Ability to add new patches
Diffstat (limited to 'pgcommitfest/commitfest/ajax.py')
-rw-r--r--pgcommitfest/commitfest/ajax.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/pgcommitfest/commitfest/ajax.py b/pgcommitfest/commitfest/ajax.py
index b9c3db4..7c73771 100644
--- a/pgcommitfest/commitfest/ajax.py
+++ b/pgcommitfest/commitfest/ajax.py
@@ -74,14 +74,19 @@ 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")
+
+def doAttachThread(cf, patch, msgid, user):
r = sorted(_archivesAPI('/message-id.json/%s' % msgid), key=lambda x: x['date'])
# We have the full thread metadata - using the first and last entry,
# construct a new mailthread in our own model.
# First, though, check if it's already there.
if MailThread.objects.filter(messageid=r[0]['msgid'], patch=patch).exists():
# It already existed. Pretend everything is fine.
- return 'OK'
+ return True
# Now create a new mailthread entry
m = MailThread(messageid=r[0]['msgid'],
@@ -96,11 +101,11 @@ def attachThread(request):
)
m.save()
parse_and_add_attachments(r, m)
- PatchHistory(patch=patch, by=request.user, what='Attached mail thread %s' % r[0]['msgid']).save()
+ PatchHistory(patch=patch, by=user, what='Attached mail thread %s' % r[0]['msgid']).save()
patch.set_modified()
patch.save()
- return 'OK'
+ return True
@transaction.commit_on_success
def detachThread(request):