mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 22:27:03 +00:00
better validation for survey stations tag/other on an entrance, and bugs fixed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -657,6 +657,8 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
nextletter = chr(ord(letter)+1)
|
||||
return check_new_slugname_ok(slug, nextletter)
|
||||
|
||||
entletter = "" # default to stop crashes
|
||||
entletterform = None
|
||||
if not (cave:= get_cave_from_slug(caveslug)): # walrus operator
|
||||
return render(request, "errors/badslug.html", {"badslug": f"for cave {caveslug} - from edit_entrance()"})
|
||||
|
||||
@@ -720,10 +722,10 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
||||
entranceletter=""
|
||||
|
||||
if not entform.is_valid():
|
||||
message = f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} entletterform valid:{entletterform.is_valid()}"
|
||||
entrance = entform.save(commit=False)
|
||||
message = f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} "
|
||||
# entrance = entform.save(commit=False)
|
||||
print(message)
|
||||
return render(request, "errors/generic.html", {"message": message})
|
||||
# return render(request, "errors/generic.html", {"message": message})
|
||||
else:
|
||||
|
||||
print(f"'edit_entrance(): POST is valid {caveslug=} Editing {entslug=} {entranceletter=} {path=}")
|
||||
|
||||
Reference in New Issue
Block a user