Bug fixing of cave and entrance forms removal of slugs

This commit is contained in:
Martin
2012-08-14 22:51:15 +02:00
parent ecd5bbcb1d
commit 1a0e577606
8 changed files with 63 additions and 24 deletions

View File

@@ -16,12 +16,21 @@ class CaveForm(ModelForm):
underground_centre_line = forms.CharField(required = False, widget=forms.Textarea())
notes = forms.CharField(required = False, widget=forms.Textarea())
references = forms.CharField(required = False, widget=forms.Textarea())
slug = forms.CharField(required = True)
url = forms.CharField(required = True)
class Meta:
model = Cave
exclude = ("filename",)
def clean(self):
if self.cleaned_data.get("kataster_number") == "" and self.cleaned_data.get("unofficial_number") == "":
self._errors["unofficial_number"] = self.error_class(["Either the kataster or unoffical number is required."])
if self.cleaned_data.get("kataster_number") != "" and self.cleaned_data.get("official_name") == "":
self._errors["official_name"] = self.error_class(["This field is required when there is a kataster number."])
if self.cleaned_data.get("area") == []:
self._errors["area"] = self.error_class(["This field is required."])
return self.cleaned_data
class VersionControlCommentForm(forms.Form):
description_of_change = forms.CharField(required = True, widget=forms.Textarea())
@@ -41,7 +50,6 @@ class EntranceForm(ModelForm):
northing = forms.CharField(required=False) # Trying to change this to a singl;e line entry
easting = forms.CharField(required=False) # Trying to change this to a singl;e line entry
alt = forms.CharField(required=False) # Trying to change this to a singl;e line entry
slug = forms.CharField()
class Meta:
model = Entrance
exclude = ("cached_primary_slug", "filename",)
@@ -50,6 +58,11 @@ class EntranceForm(ModelForm):
CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave'))
class EntranceLetterForm(ModelForm):
class Meta:
model = CaveAndEntrance
exclude = ('cave', 'entrance')
#class PersonForm(ModelForm):
# class Meta:
# model = Person