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
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)
form._errors['threadmsgid'] = form.error_class(('Selected thread did not exist in the archives',))
except Exception:
form._errors['threadmsgid'] = form.error_class(('An error occurred looking up the thread in the archives.',))
+ # In this case, we have created a patch - delete it. This causes a agp in id's, but it should
+ # not happen very often. If we successfully attached to it, we will have already returned.
+ patch.delete()
else:
form = NewPatchForm()