2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 05:37:14 +00:00

fixing cave_edit

This commit is contained in:
2024-06-28 18:31:23 +03:00
parent 5fff060487
commit 03fa36576b
2 changed files with 24 additions and 9 deletions

View File

@@ -556,7 +556,7 @@ def read_entrance(filename, ent=None):
ent.save()
return ent
def read_cave(filename, mvf, cave=None):
def read_cave(filename, mvf=None, cave=None):
"""Reads an entrance description from the .html file
Convoluted. Sorry. Needs rewriting
@@ -684,10 +684,15 @@ def read_cave(filename, mvf, cave=None):
pass
def check_slug(areacode, kataster_number, unofficial_number, url):
"""There is a <caveslug> field in the .html file, but we now ignore it as we use the
filename itself to set the slug.
However we do check it for sanity, pending its removal eventually."""
# context = f"/{cave.areacode}/{slug}_cave_edit/"
if kataster_number:
if slug == f"{areacode}-{kataster_number}":
return slug
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}. CHANGE caveslug field in the .html file."
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}. IGNORING caveslug field in the .html file."
correctslug = f"{areacode}-{kataster_number}"
else:
@@ -697,14 +702,16 @@ def read_cave(filename, mvf, cave=None):
message = f" ! Cave Slug capitalisation incorrect (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}."
correctslug = slug.lower()
else:
message = f" ! Cave Slug mismatch (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} CHANGE caveslug field in the .html file."
correctslug = slug # hack to stopit crashing
DataIssue.objects.create(parser="caves", message=message, url=f"{slug}_cave_edit/") # url here is for where the file actually is, for editing
message = f" ! Cave Slug mismatch (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} IGNORING caveslug field in the .html file."
correctslug = f"{areacode}-{unofficial_number}"
msgurl=f"/{correctslug[0:4]}/{correctslug}_cave_edit/"
DataIssue.objects.create(parser="caves", message=message, url=msgurl) # url here is for the href link to edit the bad data in the DataIssues page
mvtext = f"mv {filename} {correctslug}.html"
#print(mvtext)
if filename != f"{correctslug}.html" :
message = f" ! Filename is not the same as the cave slug '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} so use troggle/mvscript.sh to fix."
DataIssue.objects.create(parser="caves", message=message, url=f"{slug}_cave_edit/") # url here is for where the file actually is, for editing
DataIssue.objects.create(parser="caves", message=message, url=msgurl) # url here is for where the file actually is, for editing
mvf.write(mvtext + "\n")
print(message)
return correctslug
@@ -823,8 +830,7 @@ def read_cave(filename, mvf, cave=None):
cave.url = f"{cave.areacode}/{cave.number()}/{cave.number()}.html"
check_directory(cave.areacode, cave.number(), cave.url, cave)
# This next line has no effect because the cave slug is not actually a field on the Cave object so we can't fix it here. to-do!
slug = check_slug(cave.areacode, cave.kataster_number, cave.unofficial_number, cave.url)
slug = check_slug(cave.areacode, cave.kataster_number, cave.unofficial_number, cave.url) #NB cave.slug is not a field on Cave
entrances = getXML(cavecontents, "entrance", context=context)
do_entrances()