mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 17:47:13 +00:00
making error handling mroe robust
This commit is contained in:
@@ -482,7 +482,7 @@ def edit_cave(request, path="", slug=None):
|
|||||||
else:
|
else:
|
||||||
print(f"{slug=}")
|
print(f"{slug=}")
|
||||||
if not (cave:= get_cave_from_slug(slug)): # walrus operator
|
if not (cave:= get_cave_from_slug(slug)): # walrus operator
|
||||||
return render(request, "errors/badslug.html", {"badslug": f"for cave {caveslug} - from edit_cave()"})
|
return render(request, "errors/badslug.html", {"badslug": f"for cave {slug} - from edit_cave()"})
|
||||||
|
|
||||||
editor = get_cookie(request)
|
editor = get_cookie(request)
|
||||||
|
|
||||||
|
|||||||
@@ -718,7 +718,7 @@ def read_cave(filename, mvf=None, cave=None):
|
|||||||
if dir.is_dir():
|
if dir.is_dir():
|
||||||
return
|
return
|
||||||
if dir_l.is_dir() or dir_u.is_dir():
|
if dir_l.is_dir() or dir_u.is_dir():
|
||||||
message = f" ! Cave URL capitalisation incorrect '{dir}' is not a directory but different capitalisation is. {url=}\n - Fix by renaming cave_data/{caveid}.html which determines the cave id OR by renaming the directory and hand-fixing all the links to the files in the cave description."
|
message = f" ! Cave URL capitalisation incorrect '{dir}' is not a directory but different capitalisation is. {url=}\n - Fix by renaming cave_data/{caveid}.html which determines the cave id OR by renaming the directory and hand-fixing all the links to the files in the cave description, or simply edit the line <unofficial_number> in cave_data/{caveid}.html."
|
||||||
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.newslug()}_cave_edit/")
|
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.newslug()}_cave_edit/")
|
||||||
print(message)
|
print(message)
|
||||||
return
|
return
|
||||||
@@ -734,7 +734,7 @@ def read_cave(filename, mvf=None, cave=None):
|
|||||||
if kataster_number:
|
if kataster_number:
|
||||||
if slug == f"{areacode}-{kataster_number}":
|
if slug == f"{areacode}-{kataster_number}":
|
||||||
return slug
|
return slug
|
||||||
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}. IGNORING 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}"
|
correctslug = f"{areacode}-{kataster_number}"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -748,12 +748,12 @@ def read_cave(filename, mvf=None, cave=None):
|
|||||||
correctslug = f"{areacode}-{unofficial_number}"
|
correctslug = f"{areacode}-{unofficial_number}"
|
||||||
|
|
||||||
msgurl=f"/{correctslug[0:4]}/{correctslug}_cave_edit/"
|
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
|
DataIssue.objects.update_or_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"
|
mvtext = f"mv {filename} {correctslug}.html"
|
||||||
#print(mvtext)
|
#print(mvtext)
|
||||||
if filename != f"{correctslug}.html" :
|
if filename != f"{correctslug}.html" :
|
||||||
message = f" ! Filename is not the same as the cave slug '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} IGNORING caveslug field in the .html file."
|
message = f" ! Filename is not the same as the cave slug '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename} IGNORING <unofficial_number> field in the .html file and using the filename to get the cave slug instead."
|
||||||
DataIssue.objects.create(parser="caves", message=message, url=msgurl) # url here is for where the file actually is, for editing
|
DataIssue.objects.update_or_create(parser="caves", message=message, url=msgurl) # url here is for where the file actually is, for editing
|
||||||
if mvf: # this can be called online, not just when a databaseReset is done, so mvf may be None
|
if mvf: # this can be called online, not just when a databaseReset is done, so mvf may be None
|
||||||
mvf.write(mvtext + "\n")
|
mvf.write(mvtext + "\n")
|
||||||
print(message)
|
print(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user