From 3969d6c931ba5e2fe5a8f091008c5635befd9eea Mon Sep 17 00:00:00 2001 From: Ryan Cross Date: Sat, 21 Mar 2020 21:01:34 +0000 Subject: [PATCH] Prevent use of capital letters in group acronym. Fixes #2709. Commit ready for merge. - Legacy-Id: 17491 --- ietf/secr/groups/forms.py | 6 ++++++ ietf/secr/groups/tests.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ietf/secr/groups/forms.py b/ietf/secr/groups/forms.py index be53cf82b..a21d57243 100644 --- a/ietf/secr/groups/forms.py +++ b/ietf/secr/groups/forms.py @@ -74,6 +74,12 @@ class GroupModelForm(forms.ModelForm): if lsgc: self.fields['liaison_contacts'].initial = lsgc.contacts + def clean_acronym(self): + acronym = self.cleaned_data['acronym'] + if any(x.isupper() for x in acronym): + raise forms.ValidationError('Capital letters not allowed in group acronym') + return acronym + def clean_parent(self): parent = self.cleaned_data['parent'] type = self.cleaned_data['type'] diff --git a/ietf/secr/groups/tests.py b/ietf/secr/groups/tests.py index c49d95cd1..92184be6f 100644 --- a/ietf/secr/groups/tests.py +++ b/ietf/secr/groups/tests.py @@ -84,6 +84,22 @@ class GroupsTest(TestCase): response = self.client.post(url,post_data) self.assertEqual(response.status_code, 200) + def test_add_group_capital_acronym(self): + area = GroupFactory(type_id='area') + url = reverse('ietf.secr.groups.views.add') + post_data = {'acronym':'TEST', + 'name':'Test Group', + 'type':'wg', + 'status':'active', + 'parent':area.id, + 'awp-TOTAL_FORMS':'2', + 'awp-INITIAL_FORMS':'0', + 'submit':'Save'} + self.client.login(username="secretary", password="secretary+password") + response = self.client.post(url,post_data) + self.assertEqual(response.status_code, 200) + self.assertContains(response, 'Capital letters not allowed in group acronym') + # ------- Test View -------- # def test_view(self): MeetingFactory(type_id='ietf')