Skip to content

Commit b9bf759

Browse files
committed
Set the parent for newly created RGs. Be more robust if an RG has no parent. Test creation of an RG. Fixes ietf-tools#1718 and ietf-tools#1719. Commit ready for merge.
- Legacy-Id: 9650
1 parent 0ce1383 commit b9bf759

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

ietf/group/edit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def __init__(self, *args, **kwargs):
6363
if self.group_type == "rg":
6464
self.fields['ad'].widget = forms.HiddenInput()
6565
self.fields['parent'].queryset = self.fields['parent'].queryset.filter(acronym="irtf")
66+
self.fields['parent'].initial = self.fields['parent'].queryset.first()
6667
self.fields['parent'].widget = forms.HiddenInput()
6768
else:
6869
self.fields['parent'].queryset = self.fields['parent'].queryset.filter(type="area")
@@ -247,7 +248,7 @@ def diff(attr, name):
247248
diff('name', "Name")
248249
diff('acronym', "Acronym")
249250
diff('state', "State")
250-
diff('parent', "IETF Area")
251+
diff('parent', "IETF Area" if group.type=="wg" else "Group parent")
251252
diff('list_email', "Mailing list email")
252253
diff('list_subscribe', "Mailing list subscribe address")
253254
diff('list_archive', "Mailing list archive")

ietf/group/tests_info.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,34 @@ def test_create(self):
337337
self.assertEqual(group.charter.name, "charter-ietf-testwg")
338338
self.assertEqual(group.charter.rev, "00-00")
339339

340+
def test_create_rg(self):
341+
342+
make_test_data()
343+
344+
url = urlreverse('group_create', kwargs=dict(group_type="rg"))
345+
login_testing_unauthorized(self, "secretary", url)
346+
347+
irtf = Group.objects.get(acronym='irtf')
348+
num_rgs = len(Group.objects.filter(type="rg"))
349+
350+
proposed_state = GroupStateName.objects.get(slug="proposed")
351+
352+
# normal get
353+
r = self.client.get(url)
354+
self.assertEqual(r.status_code, 200)
355+
q = PyQuery(r.content)
356+
self.assertEqual(len(q('form input[name=acronym]')), 1)
357+
self.assertEqual(q('form input[name=parent]').attr('value'),'%s'%irtf.pk)
358+
359+
r = self.client.post(url, dict(acronym="testrg", name="Testing RG", state=proposed_state.pk, parent=irtf.pk))
360+
self.assertEqual(r.status_code, 302)
361+
self.assertEqual(len(Group.objects.filter(type="rg")), num_rgs + 1)
362+
group = Group.objects.get(acronym="testrg")
363+
self.assertEqual(group.name, "Testing RG")
364+
self.assertEqual(group.charter.name, "charter-irtf-testrg")
365+
self.assertEqual(group.charter.rev, "00-00")
366+
self.assertEqual(group.parent.acronym,'irtf')
367+
340368
def test_create_based_on_existing_bof(self):
341369
make_test_data()
342370

ietf/secr/utils/mail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def get_ad_email_list(group):
77
emails = []
88
if group.type.slug == 'wg':
99
emails.append('%s-ads@tools.ietf.org' % group.acronym)
10-
elif group.type.slug == 'rg':
10+
elif group.type.slug == 'rg' and group.parent:
1111
emails.append(group.parent.role_set.filter(name='chair')[0].email.address)
1212
return emails
1313

0 commit comments

Comments
 (0)