Allow entrances to be edited with the correct parent url. Commit changes to caves when adding a new entrance. Order entrances alphabetically

This commit is contained in:
Martin Green
2022-08-01 16:04:22 +02:00
parent fa6758b9a0
commit f491264b9e
5 changed files with 87 additions and 51 deletions

View File

@@ -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)