diff options
author | Magnus Hagander | 2015-08-14 10:34:39 +0000 |
---|---|---|
committer | Magnus Hagander | 2015-08-14 10:34:39 +0000 |
commit | d20c6971576e998625e226fac6acdee283cd3549 (patch) | |
tree | 3322073e227e460d71b5f31b5a3316c92c001fec /pgcommitfest/commitfest/forms.py | |
parent | c6e940c1acc2e6c41fe809213a9b9c96a7ce63c2 (diff) |
Ensure duplicate patches aren't created when an invalid msgid is entered
Diffstat (limited to 'pgcommitfest/commitfest/forms.py')
-rw-r--r-- | pgcommitfest/commitfest/forms.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pgcommitfest/commitfest/forms.py b/pgcommitfest/commitfest/forms.py index 2a832ae..67205d2 100644 --- a/pgcommitfest/commitfest/forms.py +++ b/pgcommitfest/commitfest/forms.py @@ -3,6 +3,7 @@ from django.forms import ValidationError from django.forms.widgets import HiddenInput from django.db.models import Q from django.contrib.auth.models import User +from django.http import Http404 from selectable.forms.widgets import AutoCompleteSelectMultipleWidget @@ -58,6 +59,15 @@ class NewPatchForm(forms.ModelForm): model = Patch exclude = ('commitfests', 'mailthreads', 'modified', 'authors', 'reviewers', 'committer', 'wikilink', 'gitlink', 'lastmail', ) + def clean_threadmsgid(self): + try: + _archivesAPI('/message-id.json/%s' % self.cleaned_data['threadmsgid']) + except Http404: + raise ValidationError("Message not found in archives") + except: + raise ValidationError("Error in API call to validate thread") + return self.cleaned_data['threadmsgid'] + def _fetch_thread_choices(patch): for mt in patch.mailthread_set.order_by('-latestmessage'): ti = sorted(_archivesAPI('/message-id.json/%s' % mt.messageid), key=lambda x: x['date'], reverse=True) |