diff --git a/ietf/group/admin.py b/ietf/group/admin.py index fda95d968..90f17b0fc 100644 --- a/ietf/group/admin.py +++ b/ietf/group/admin.py @@ -1,6 +1,7 @@ # Copyright The IETF Trust 2010-2020, All Rights Reserved # -*- coding: utf-8 -*- +import re from functools import update_wrapper @@ -34,6 +35,15 @@ class GroupForm(forms.ModelForm): model = Group fields = '__all__' + def clean_acronym(self): + ''' Constrain the acronym form. Note that this doesn't look for collisions. + See ietf.group.forms.GroupForm.clean_acronym() + ''' + acronym = self.cleaned_data['acronym'].strip().lower() + if not re.match(r'^[a-z][a-z0-9]+$', acronym): + raise forms.ValidationError("Acronym is invalid, must be at least two characters and only contain lowercase letters and numbers starting with a letter.") + return acronym + def clean_used_roles(self): data = self.cleaned_data['used_roles'] if data is None or data == '':