mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 05:37:14 +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(
|
self._errors["areacode"] = self.error_class(
|
||||||
["An Austrian kataster areacode, i.e. 1623, 1626, 1627, or 1624 is required."]
|
["An Austrian kataster areacode, i.e. 1623, 1626, 1627, or 1624 is required."]
|
||||||
)
|
)
|
||||||
|
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
|
|
||||||
@@ -255,10 +256,14 @@ class EntranceForm(ModelForm):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def clean(self):
|
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
|
cleaned_data = super(EntranceForm, self).clean() # where is this code hidden? How does this work??
|
||||||
# if self.cleaned_data.get("url").startswith("/"):
|
for station in ["tag_station", "other_station"]:
|
||||||
# self._errors["url"] = self.error_class(["This field cannot start with a /."])
|
print(f"{station} -- {self.data.get(station)[:4]}")
|
||||||
return self.cleaned_data
|
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
|
# # 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)
|
nextletter = chr(ord(letter)+1)
|
||||||
return check_new_slugname_ok(slug, nextletter)
|
return check_new_slugname_ok(slug, nextletter)
|
||||||
|
|
||||||
|
entletter = "" # default to stop crashes
|
||||||
|
entletterform = None
|
||||||
if not (cave:= get_cave_from_slug(caveslug)): # walrus operator
|
if not (cave:= get_cave_from_slug(caveslug)): # walrus operator
|
||||||
return render(request, "errors/badslug.html", {"badslug": f"for cave {caveslug} - from edit_entrance()"})
|
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=""
|
entranceletter=""
|
||||||
|
|
||||||
if not entform.is_valid():
|
if not entform.is_valid():
|
||||||
message = f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} entletterform valid:{entletterform.is_valid()}"
|
message = f"- POST INVALID {caveslug=} {entslug=} {path=} entform valid:{entform.is_valid()} "
|
||||||
entrance = entform.save(commit=False)
|
# entrance = entform.save(commit=False)
|
||||||
print(message)
|
print(message)
|
||||||
return render(request, "errors/generic.html", {"message": message})
|
# return render(request, "errors/generic.html", {"message": message})
|
||||||
else:
|
else:
|
||||||
|
|
||||||
print(f"'edit_entrance(): POST is valid {caveslug=} Editing {entslug=} {entranceletter=} {path=}")
|
print(f"'edit_entrance(): POST is valid {caveslug=} Editing {entslug=} {entranceletter=} {path=}")
|
||||||
|
|||||||
Reference in New Issue
Block a user