From 225c1d9afe1682dfe5d2cb1bc800508ac03e9271 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 2 Mar 2017 20:07:50 +0000 Subject: [PATCH] Changed the state choices in the document adoption form to exclude the few that should not be available, rather than explicitly list all others. Makes adding WG/RG states simpler. - Legacy-Id: 12949 --- ietf/doc/views_draft.py | 8 ++++---- ietf/settings.py | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ietf/doc/views_draft.py b/ietf/doc/views_draft.py index 2f6942664..87f9a6260 100644 --- a/ietf/doc/views_draft.py +++ b/ietf/doc/views_draft.py @@ -1208,7 +1208,7 @@ def request_publication(request, name): class AdoptDraftForm(forms.Form): group = forms.ModelChoiceField(queryset=Group.objects.filter(type__in=["wg", "rg"], state="active").order_by("-type", "acronym"), required=True, empty_label=None) - newstate = forms.ModelChoiceField(queryset=State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'],slug__in=['wg-cand', 'c-adopt', 'adopt-wg', 'info', 'wg-doc', 'candidat','active']),required=True,label="State") + newstate = forms.ModelChoiceField(queryset=State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'], used=True).exclude(slug__in=settings.GROUP_STATES_WITH_EXTRA_PROCESSING), required=True, label="State") comment = forms.CharField(widget=forms.Textarea, required=False, label="Comment", help_text="Optional comment explaining the reasons for the adoption.", strip=False) weeks = forms.IntegerField(required=False, label="Expected weeks in adoption state") @@ -1218,16 +1218,16 @@ class AdoptDraftForm(forms.Form): super(AdoptDraftForm, self).__init__(*args, **kwargs) if has_role(user, "Secretariat"): - state_choices = State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'],slug__in=['wg-cand', 'c-adopt', 'adopt-wg', 'info', 'wg-doc', 'candidat','active']) + state_choices = State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'], used=True).exclude(slug__in=settings.GROUP_STATES_WITH_EXTRA_PROCESSING) elif has_role(user, "IRTF Chair"): #The IRTF chair can adopt a draft into any RG group_ids = list(Group.objects.filter(type="rg", state="active").values_list('id', flat=True)) group_ids.extend(list(Group.objects.filter(type="wg", state="active", role__person__user=user, role__name__in=("chair", "delegate", "secr")).values_list('id', flat=True))) self.fields["group"].queryset = self.fields["group"].queryset.filter(id__in=group_ids).distinct() - state_choices = State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'],slug__in=['wg-cand', 'c-adopt', 'adopt-wg', 'info', 'wg-doc', 'candidat','active']) + state_choices = State.objects.filter(type='draft-stream-irtf', used=True).exclude(slug__in=settings.GROUP_STATES_WITH_EXTRA_PROCESSING) else: self.fields["group"].queryset = self.fields["group"].queryset.filter(role__person__user=user, role__name__in=("chair", "delegate", "secr")).distinct() - state_choices = State.objects.filter(type__in=['draft-stream-ietf','draft-stream-irtf'],slug__in=['wg-cand', 'c-adopt', 'adopt-wg', 'info', 'wg-doc']) + state_choices = State.objects.filter(type='draft-stream-ietf', used=True).exclude(slug__in=settings.GROUP_STATES_WITH_EXTRA_PROCESSING) 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 --')] diff --git a/ietf/settings.py b/ietf/settings.py index 8720dfa44..3d0d9f458 100644 --- a/ietf/settings.py +++ b/ietf/settings.py @@ -515,6 +515,11 @@ TEST_CODE_COVERAGE_REPORT_FILE = os.path.join(TEST_CODE_COVERAGE_REPORT_DIR, "in # WG Chair configuration MAX_WG_DELEGATES = 3 +# These states aren't available in forms with drop-down choices for new +# document state: +GROUP_STATES_WITH_EXTRA_PROCESSING = ["sub-pub", "rfc-edit", ] + + DATE_FORMAT = "Y-m-d" DATETIME_FORMAT = "Y-m-d H:i T"