Merged in [9650] from rjsparks@nostrum.com:

Set the parent for newly created RGs. Be more robust if an RG has no parent. Test creation of an RG. Fixes #1718 and #1719.
 - Legacy-Id: 9661
Note: SVN reference [9650] has been migrated to Git commit b9bf7594001f0014ff4c2ac3688b431f1fcd39ec
This commit is contained in:
Henrik Levkowetz 2015-06-03 16:52:49 +00:00
parent 1c54a13f68
commit 9067f88fa7
3 changed files with 31 additions and 2 deletions

View file

@ -63,6 +63,7 @@ class GroupForm(forms.Form):
if self.group_type == "rg":
self.fields['ad'].widget = forms.HiddenInput()
self.fields['parent'].queryset = self.fields['parent'].queryset.filter(acronym="irtf")
self.fields['parent'].initial = self.fields['parent'].queryset.first()
self.fields['parent'].widget = forms.HiddenInput()
else:
self.fields['parent'].queryset = self.fields['parent'].queryset.filter(type="area")
@ -247,7 +248,7 @@ def edit(request, group_type=None, acronym=None, action="edit"):
diff('name', "Name")
diff('acronym', "Acronym")
diff('state', "State")
diff('parent', "IETF Area")
diff('parent', "IETF Area" if group.type=="wg" else "Group parent")
diff('list_email', "Mailing list email")
diff('list_subscribe', "Mailing list subscribe address")
diff('list_archive', "Mailing list archive")

View file

@ -337,6 +337,34 @@ class GroupEditTests(TestCase):
self.assertEqual(group.charter.name, "charter-ietf-testwg")
self.assertEqual(group.charter.rev, "00-00")
def test_create_rg(self):
make_test_data()
url = urlreverse('group_create', kwargs=dict(group_type="rg"))
login_testing_unauthorized(self, "secretary", url)
irtf = Group.objects.get(acronym='irtf')
num_rgs = len(Group.objects.filter(type="rg"))
proposed_state = GroupStateName.objects.get(slug="proposed")
# normal get
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('form input[name=acronym]')), 1)
self.assertEqual(q('form input[name=parent]').attr('value'),'%s'%irtf.pk)
r = self.client.post(url, dict(acronym="testrg", name="Testing RG", state=proposed_state.pk, parent=irtf.pk))
self.assertEqual(r.status_code, 302)
self.assertEqual(len(Group.objects.filter(type="rg")), num_rgs + 1)
group = Group.objects.get(acronym="testrg")
self.assertEqual(group.name, "Testing RG")
self.assertEqual(group.charter.name, "charter-irtf-testrg")
self.assertEqual(group.charter.rev, "00-00")
self.assertEqual(group.parent.acronym,'irtf')
def test_create_based_on_existing_bof(self):
make_test_data()

View file

@ -7,7 +7,7 @@ def get_ad_email_list(group):
emails = []
if group.type.slug == 'wg':
emails.append('%s-ads@tools.ietf.org' % group.acronym)
elif group.type.slug == 'rg':
elif group.type.slug == 'rg' and group.parent:
emails.append(group.parent.role_set.filter(name='chair')[0].email.address)
return emails