2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 23:57:11 +00:00

better validation for survey stations tag/other on an entrance, and bugs fixed

This commit is contained in:
2025-07-13 19:30:53 +03:00
parent 6cf7bbb7d9
commit ea0a5b153f
2 changed files with 14 additions and 7 deletions

View File

@@ -147,6 +147,7 @@ class CaveForm(ModelForm):
self._errors["areacode"] = self.error_class(
["An Austrian kataster areacode, i.e. 1623, 1626, 1627, or 1624 is required."]
)
return cleaned_data
@@ -255,10 +256,14 @@ class EntranceForm(ModelForm):
)
def clean(self):
# if self.cleaned_data.get("url"): # can remove this as the form does not have a url field any more, which was never used anyway
# if self.cleaned_data.get("url").startswith("/"):
# self._errors["url"] = self.error_class(["This field cannot start with a /."])
return self.cleaned_data
cleaned_data = super(EntranceForm, self).clean() # where is this code hidden? How does this work??
for station in ["tag_station", "other_station"]:
print(f"{station} -- {self.data.get(station)[:4]}")
if self.data.get(station)[:5] not in ["1623.", "1626.", "1627.", "1624.", ""]:
self._errors[station] = self.error_class(
["An Austrian kataster areacode, i.e. 1623, 1626, 1627, or 1624 prefix is required."]
)
return self.cleaned_data
# # This next line is sufficient to create an entire entry for for the cave fields automatically