From 390309412f7fb65b7409d369c49b9942161404c4 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 12 Oct 2013 15:33:54 +0000 Subject: [PATCH] Changed the WG edit form so that once an acronym has been set, the acronym field is read-only; also changed the form validation to not permit changes to an existing acronym. - Legacy-Id: 6432 --- ietf/wginfo/edit.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ietf/wginfo/edit.py b/ietf/wginfo/edit.py index 945129ff7..89be89523 100644 --- a/ietf/wginfo/edit.py +++ b/ietf/wginfo/edit.py @@ -50,18 +50,22 @@ class WGForm(forms.Form): self.confirm_msg = "" self.autoenable_confirm = False + if self.wg: + self.fields['acronym'].widget.attrs['readonly'] = True def clean_acronym(self): self.confirm_msg = "" self.autoenable_confirm = False + # Changing the acronym of an already existing WG will cause 404s all + # over the place, loose history, and generally muck up a lot of + # things, so we don't permit it + if self.wg: + return self.wg.acronym # no change permitted + acronym = self.cleaned_data['acronym'].strip().lower() # be careful with acronyms, requiring confirmation to take existing or override historic - - if self.wg and acronym == self.wg.acronym: - return acronym # no change, no check - 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.") @@ -69,7 +73,7 @@ class WGForm(forms.Form): if existing: existing = existing[0] - if not self.wg and existing and existing.type_id == "wg": + if existing and existing.type_id == "wg": if self.confirmed: return acronym # take over confirmed