Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Group admin form accepts acronyms starting with numbers for SDO groups #7051

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ietf/group/admin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -72,6 +72,12 @@ def clean(self):
'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 = (
Expand Down
11 changes: 10 additions & 1 deletion ietf/group/tests_info.py
Original file line number Diff line number Diff line change
@@ -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 -*-


Expand Down Expand Up @@ -2044,8 +2044,17 @@ def test_admin_acronym_validation(self):
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)
rjsparks marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand Down
Loading