2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

bugfix and making more robust

This commit is contained in:
Philip Sargent 2023-11-05 15:20:45 +02:00
parent d524f94c47
commit 2c67351424
3 changed files with 50 additions and 56 deletions

View File

@ -208,7 +208,9 @@ class EntranceLetterForm(ModelForm):
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.
"""
entranceletter = forms.CharField(required=False, widget=forms.TextInput(attrs={"size": "2"}))
# This only needs to be required=True for the second and subsequent entrances, not the first. Tricky.
entranceletter = forms.CharField(required=True, widget=forms.TextInput(attrs={"size": "2"}))
class Meta:
model = CaveAndEntrance

View File

@ -519,7 +519,7 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
entranceletter = entletterform.cleaned_data["entranceletter"]
else:
print(f"- POST INVALID {caveslug=} {entslug=} {path=} entletterform invalid.")
return render(request, "errors/badslug.html", {"entletter problem in edit_entrances()"})
return render(request, "errors/badslug.html", {"badslug": "entletter problem in edit_entrances()"})
# if entform.is_valid() and entletterform.is_valid():
if entform.is_valid():
entrance = entform.save(commit=False)

View File

@ -292,7 +292,7 @@ def LoadPositions():
print(message)
topdata = os.fspath(Path(settings.SURVEX_DATA) / settings.SURVEX_TOPNAME)
print(f" - Generating a list of Pos from {topdata}.svx and then loading...")
print(f" - Generating a list of Pos from {topdata}.3d and then loading...")
found = 0
print("\n") # extra line because cavern overwrites the text buffer somehow
@ -341,8 +341,7 @@ def LoadPositions():
stash_data_issue(parser="positions", message=message, url=f"/entrance_data/{pospath}_edit")
print(message)
return
posfile = open(pospath)
with open(pospath) as posfile:
posfile.readline() # Drop header
sbdict = {}
@ -392,11 +391,4 @@ def LoadPositions():
if dups > 0:
print(f" - {dups} Duplicated SurvexStation entrances found")
# for p in mappoints:
# if p not in found_points:
# print(f"Valid point {p} NOT found in {positions_filename}")
# print(f" - {len(mappoints)} mappoints, {len(found_points)} found_points")
# for sid in found_points:
# if found_points[sid] > 1:
# print(f" - {sid} - {found_points[sid]}")
store_data_issues()