Skip to content

Commit 068493d

Browse files
committed
Merged in [18205] from rjsparks@nostrum.com:
Add rudimentary validation to the admin group form acronym field. Partially addresses ietf-tools#3026. - Legacy-Id: 18215 Note: SVN reference [18205] has been migrated to Git commit 82928b8
2 parents 0d96193 + 82928b8 commit 068493d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

ietf/group/admin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright The IETF Trust 2010-2020, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

4+
import re
45

56
from functools import update_wrapper
67

@@ -34,6 +35,15 @@ class Meta:
3435
model = Group
3536
fields = '__all__'
3637

38+
def clean_acronym(self):
39+
''' Constrain the acronym form. Note that this doesn't look for collisions.
40+
See ietf.group.forms.GroupForm.clean_acronym()
41+
'''
42+
acronym = self.cleaned_data['acronym'].strip().lower()
43+
if not re.match(r'^[a-z][a-z0-9]+$', acronym):
44+
raise forms.ValidationError("Acronym is invalid, must be at least two characters and only contain lowercase letters and numbers starting with a letter.")
45+
return acronym
46+
3747
def clean_used_roles(self):
3848
data = self.cleaned_data['used_roles']
3949
if data is None or data == '':

0 commit comments

Comments
 (0)