Making the dummy entrance thing clear

This commit is contained in:
Philip Sargent (laptop) 2023-05-02 17:42:58 +03:00
parent 175307773b
commit ef467ad481
3 changed files with 31 additions and 15 deletions

View File

@ -61,7 +61,7 @@ class CaveForm(ModelForm):
survex_file = forms.CharField(
required=False, label="Survex file eg. caves-1623/000/000.svx", widget=forms.TextInput(attrs={"size": "45"})
)
url = forms.CharField(required=True, label="URL eg. 1623/000/000.html", widget=forms.TextInput(attrs={"size": "45"}))
url = forms.CharField(required=True, label="URL eg. 1623/000/000 (no .html)", widget=forms.TextInput(attrs={"size": "45"}))
length = forms.CharField(required=False, label="Length (m)")
depth = forms.CharField(required=False, label="Depth (m)")
extent = forms.CharField(required=False, label="Extent (m)")

View File

@ -281,12 +281,15 @@ def cavepage(request, karea, subpath):
accessed by kataster area number specifically
OR
accessed by cave.url specifically set in data, e.g.
"1623/000/000.html" <= cave-data/1623-000.html
"1623/000/000" <= cave-data/1623-000.html
"1623/41/115.htm" <= cave-data/1623-115.html
so we have to query the database to fine the URL as we cannot rely on the url actually telling us the cave by inspection.
NOTE that old caves have ".html" (or ".htm") in the URL as they used to be actual files. But since 2006 these URLs
refer to virtual pages generated on the fly by troggle, so the".html" is confusing and redundant.
There are A LOT OF URLS to e.g. /1623/161/l/rl89a.htm which are IMAGES and html files
in cave descriptions. These need to be handled HERE
There are also A LOT OF URLS to e.g. /1623/161/l/rl89a.htm which are IMAGES and real html files
in cave descriptions. These need to be handled HERE too (accident of history).
"""
kpath = karea + subpath
# print(f" ! cavepage:'{kpath}' kataster area:'{karea}' rest of path:'{subpath}'")

View File

@ -64,25 +64,38 @@ def dummy_entrance(k, slug, msg="DUMMY"):
message = f" ! {k:11s} {msg}-{slug} {k} entrance create failure"
DataIssue.objects.create(parser="entrances", message=message, url=f"{slug}")
print(message)
raise
raise # caught and handled by calling routine.
def set_dummy_entrance(id, slug, cave, msg="DUMMY"):
"""Called only when reading the cave and entrance html files
Entrance field either missing or holds a null string instead of a filename in a cave_data file."""
Called when the Entrance field in a cave_data file is either missing or
holds a null string instead of a filename.
Previously, the lack of an entrance where an entrance was expected, caused troggle to crash in several places.
But it is more robust now, so this is not necessary... we hope.
Also, Cave and Entrance editing now expects there to be a real file (since April 2023), so creating this
dummy is actually harmful. So this is commented out, pending removal after further experience.
global variable entrances_xslug is simply a cache of references to Entrance objects
to speed things up when parsing a lot of caves and entrances. All DB actions are time-consuming
so
"""
global entrances_xslug
message = f" - Note: Missing Entrance for entrance '{id}' on cave '{cave}'"
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}")
try:
#Note the below line, just creates a dastabase entry, sets the global variable entrances_xslug and not a file, this then breaks entrance editing by the website. I am not sure if we want entrances automagically created. Therefore I have commented it out. Perhaps entrances_xslug is being saved with the worng filename, breaking edit_caves. MJG
#entrance = dummy_entrance(id, slug, msg="DUMMY")
#entrances_xslug[slug] = entrance
#CaveAndEntrance.objects.update_or_create(cave=cave, entrance_letter="", entrance=entrance)
#message = f" - Note: Dummy Entrance successfully set for entrance {id} on cave {cave}"
message = f" - Note: Missing Entrance for entrance {id} on cave {cave}"
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}")
# print(message)
# I am not sure if we want entrances automagically created.
# Therefore I have commented it out. MJG
# entrance = dummy_entrance(id, slug, msg="DUMMY")
# entrances_xslug[slug] = entrance
# CaveAndEntrance.objects.update_or_create(cave=cave, entrance_letter="", entrance=entrance)
pass
except:
# raise
message = f' ! Entrance Dummy setting failure, slug:"{slug}" cave id :"{id}" '
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}")
print(message)