Skip to content

Commit 1edc863

Browse files
committed
Merged in [16763] from rjsparks@nostrum.com:
Allow responsible AD to be None for documents in iesg states idexists and dead. Fixes ietf-tools#2803 and ietf-tools#993. - Legacy-Id: 16838 Note: SVN reference [16763] has been migrated to Git commit 9f54af3
1 parent 058a8c3 commit 1edc863

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

ietf/doc/tests_draft.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,18 @@ def test_doc_change_ad(self):
941941
self.assertEqual(doc.ad,ad2)
942942
self.assertTrue(doc.latest_event(DocEvent,type="added_comment").desc.startswith('Shepherding AD changed'))
943943

944+
doc.set_state(State.objects.get(type_id='draft-iesg',slug='lc'))
945+
r = self.client.post(url,dict())
946+
self.assertEqual(r.status_code,200)
947+
q = PyQuery(r.content)
948+
self.assertTrue(q('.has-error'))
949+
950+
doc.set_state(State.objects.get(type_id='draft-iesg',slug='idexists'))
951+
r = self.client.post(url,dict())
952+
self.assertEqual(r.status_code,302)
953+
doc = Document.objects.get(name=self.docname)
954+
self.assertEqual(doc.ad, None)
955+
944956
def test_doc_change_shepherd(self):
945957
doc = Document.objects.get(name=self.docname)
946958
doc.shepherd = None

ietf/doc/views_draft.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,39 +1067,49 @@ def change_shepherd_email(request, name):
10671067

10681068
class AdForm(forms.Form):
10691069
ad = forms.ModelChoiceField(Person.objects.filter(role__name="ad", role__group__state="active", role__group__type="area").order_by('name'),
1070-
label="Shepherding AD", empty_label="(None)", required=True)
1070+
label="Shepherding AD", empty_label="(None)", required=False)
10711071

1072-
def __init__(self, *args, **kwargs):
1072+
def __init__(self, doc, *args, **kwargs):
10731073
super(self.__class__, self).__init__(*args, **kwargs)
1074-
1074+
self.doc = doc
10751075
# if previous AD is now ex-AD, append that person to the list
10761076
ad_pk = self.initial.get('ad')
10771077
choices = self.fields['ad'].choices
10781078
if ad_pk and ad_pk not in [pk for pk, name in choices]:
10791079
self.fields['ad'].choices = list(choices) + [("", "-------"), (ad_pk, Person.objects.get(pk=ad_pk).plain_name())]
10801080

1081+
def clean_ad(self):
1082+
ad = self.cleaned_data['ad']
1083+
state = self.doc.get_state('draft-iesg')
1084+
if not ad:
1085+
if state.slug not in ['idexists','dead']:
1086+
raise forms.ValidationError("Drafts in state %s must have an assigned AD." % state)
1087+
return ad
1088+
10811089
@role_required("Area Director", "Secretariat")
10821090
def edit_ad(request, name):
10831091
"""Change the shepherding Area Director for this draft."""
10841092

10851093
doc = get_object_or_404(Document, type="draft", name=name)
10861094

10871095
if request.method == 'POST':
1088-
form = AdForm(request.POST)
1096+
form = AdForm(doc, request.POST)
10891097
if form.is_valid():
1090-
doc.ad = form.cleaned_data['ad']
1098+
new_ad = form.cleaned_data['ad']
1099+
if new_ad != doc.ad:
1100+
doc.ad = new_ad
10911101

1092-
c = DocEvent(type="added_comment", doc=doc, rev=doc.rev, by=request.user.person)
1093-
c.desc = "Shepherding AD changed to "+doc.ad.name
1094-
c.save()
1102+
c = DocEvent(type="added_comment", doc=doc, rev=doc.rev, by=request.user.person)
1103+
c.desc = "Shepherding AD changed to "+doc.ad.name if doc.ad else "None"
1104+
c.save()
10951105

1096-
doc.save_with_history([c])
1106+
doc.save_with_history([c])
10971107

10981108
return redirect('ietf.doc.views_doc.document_main', name=doc.name)
10991109

11001110
else:
11011111
init = { "ad" : doc.ad_id }
1102-
form = AdForm(initial=init)
1112+
form = AdForm(doc, initial=init)
11031113

11041114
return render(request, 'doc/draft/change_ad.html',
11051115
{'form': form,

0 commit comments

Comments
 (0)