feat: Group admin form accepts acronyms starting with numbers for SDO groups (#7051)
* feat: Group admin form accepts acronyms starting with numbers for SDO groups (#6825) * fix: Acronym can't start with hyphen * fix: Restore some tests
This commit is contained in:
parent
74ceac7aea
commit
65cf001ecf
|
@ -1,4 +1,4 @@
|
|||
# Copyright The IETF Trust 2010-2020, All Rights Reserved
|
||||
# Copyright The IETF Trust 2010-2024, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
|
@ -72,6 +72,12 @@ class GroupForm(forms.ModelForm):
|
|||
'Acronym is invalid. For groups that create documents, the acronym must be at least '
|
||||
'two characters and only contain lowercase letters and numbers starting with a letter.'
|
||||
)
|
||||
elif self.cleaned_data['type'].pk == 'sdo':
|
||||
valid_re = r'^[a-z0-9][a-z0-9-]*[a-z0-9]$'
|
||||
error_msg = (
|
||||
'Acronym is invalid. It must be at least two characters and only contain lowercase '
|
||||
'letters and numbers. It may contain hyphens, but that is discouraged.'
|
||||
)
|
||||
else:
|
||||
valid_re = r'^[a-z][a-z0-9-]*[a-z0-9]$'
|
||||
error_msg = (
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright The IETF Trust 2009-2023, All Rights Reserved
|
||||
# Copyright The IETF Trust 2009-2024, All Rights Reserved
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
|
@ -2044,8 +2044,17 @@ class AcronymValidationTests(TestCase):
|
|||
self.assertTrue(form.is_valid())
|
||||
form = AdminGroupForm({'acronym':'shouldfail-','name':'should fail','type':'wg','state':'active','used_roles':'[]','time':now})
|
||||
self.assertIn('acronym',form.errors)
|
||||
form = AdminGroupForm({'acronym':'shouldfail-','name':'should fail','type':'sdo','state':'active','used_roles':'[]','time':now})
|
||||
self.assertIn('acronym',form.errors)
|
||||
form = AdminGroupForm({'acronym':'-shouldfail','name':'should fail','type':'wg','state':'active','used_roles':'[]','time':now})
|
||||
self.assertIn('acronym',form.errors)
|
||||
form = AdminGroupForm({'acronym':'-shouldfail','name':'should fail','type':'sdo','state':'active','used_roles':'[]','time':now})
|
||||
self.assertIn('acronym',form.errors)
|
||||
# SDO groups (and only SDO groups) can have a leading number
|
||||
form = AdminGroupForm({'acronym':'3gpp-should-pass','name':'should pass','type':'sdo','state':'active','used_roles':'[]','time':now})
|
||||
self.assertTrue(form.is_valid())
|
||||
form = AdminGroupForm({'acronym':'123shouldfail','name':'should fail','type':'wg','state':'active','used_roles':'[]','time':now})
|
||||
self.assertIn('acronym',form.errors)
|
||||
|
||||
wg = GroupFactory(acronym='bad-idea', type_id='wg') # There are some existing wg and programs with hyphens in their acronyms.
|
||||
form = AdminGroupForm({'acronym':wg.acronym,'name':wg.name,'type':wg.type_id,'state':wg.state_id,'used_roles':str(wg.used_roles),'time':now},instance=wg)
|
||||
|
|
Loading…
Reference in a new issue