summaryrefslogtreecommitdiffstats
path: root/core/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/forms.py')
-rw-r--r--core/forms.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/forms.py b/core/forms.py
index f3df10a..a277806 100644
--- a/core/forms.py
+++ b/core/forms.py
@@ -116,11 +116,21 @@ class EntranceForm(ModelForm):
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave',))
class EntranceLetterForm(ModelForm):
- '''Can't see what this does at all. called twice from views.caves
+ '''Form to link entrances to caves, along with an entrance number.
+
+ Nb. The relationship between caves and entrances has historically been a many to many relationship.
+ With entrances gaining new caves and letters when caves are joined.
'''
class Meta:
model = CaveAndEntrance
exclude = ('cave', 'entrance')
+
+ def full_clean(self):
+ super(EntranceLetterForm, self).full_clean()
+ try:
+ self.instance.validate_unique()
+ except forms.ValidationError as e:
+ self._update_errors(e)