From 0925e8e242e456f73fd812bfcd1ab9dda8006f4a Mon Sep 17 00:00:00 2001 From: Bartosz Balazinski Date: Wed, 20 Jul 2016 00:02:45 +0000 Subject: [PATCH] Annotated the document state selection list with indications of whether the state is an IETF or IRTF state. Fixes #1968. Commit ready to merge. - Legacy-Id: 11721 --- ietf/doc/views_draft.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ietf/doc/views_draft.py b/ietf/doc/views_draft.py index 40677842a..5e1790fef 100644 --- a/ietf/doc/views_draft.py +++ b/ietf/doc/views_draft.py @@ -1245,10 +1245,21 @@ class AdoptDraftForm(forms.Form): state_choices = State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'],slug__in=['wg-cand', 'c-adopt', 'adopt-wg', 'info', 'wg-doc']) self.fields['group'].choices = [(g.pk, '%s - %s' % (g.acronym, g.name)) for g in self.fields["group"].queryset] + self.fields['newstate'].choices = [('','-- Pick a state --')] + self.fields['newstate'].choices.extend([(x.pk,x.name + " (IETF)") for x in state_choices if x.type_id == 'draft-stream-ietf']) + self.fields['newstate'].choices.extend([(x.pk,x.name + " (IRTF)") for x in state_choices if x.type_id == 'draft-stream-irtf']) - self.fields['newstate'].choices = [(x.pk,x.name) for x in state_choices] - self.fields['newstate'].choices.insert(0,('','--------')) - + def clean_newstate(self): + group = self.cleaned_data['group'] + newstate = self.cleaned_data['newstate'] + + if (newstate.type_id == 'draft-stream-ietf') and (group.type_id == 'rg'): + raise forms.ValidationError('Cannot assign IETF WG state to IRTF group') + elif (newstate.type_id == 'draft-stream-irtf') and (group.type_id == 'wg'): + raise forms.ValidationError('Cannot assign IRTF RG state to IETF group') + else: + return newstate + @login_required def adopt_draft(request, name): doc = get_object_or_404(Document, type="draft", name=name)