diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2025-01-16 17:36:24 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2025-01-16 17:36:24 +0000 |
commit | d2fade5a3d5ea24fdad37425ccb223d18d646c5d (patch) | |
tree | 7965cd0735221b41dde06adf66b77ac11b33ccd8 | |
parent | eb22047c08a05613c70470f607c460827491528f (diff) | |
download | troggle-d2fade5a3d5ea24fdad37425ccb223d18d646c5d.tar.gz troggle-d2fade5a3d5ea24fdad37425ccb223d18d646c5d.tar.bz2 troggle-d2fade5a3d5ea24fdad37425ccb223d18d646c5d.zip |
making error handling mroe robust
-rw-r--r-- | core/views/caves.py | 2 | ||||
-rw-r--r-- | parsers/caves.py | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/core/views/caves.py b/core/views/caves.py index d5e0fe3..f4591d4 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -482,7 +482,7 @@ def edit_cave(request, path="", slug=None): else: print(f"{slug=}") 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) diff --git a/parsers/caves.py b/parsers/caves.py index 241e30a..28e952f 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -718,7 +718,7 @@ def read_cave(filename, mvf=None, cave=None): if dir.is_dir(): return 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/") print(message) return @@ -734,7 +734,7 @@ def read_cave(filename, mvf=None, cave=None): 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}. 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}" else: @@ -748,12 +748,12 @@ def read_cave(filename, mvf=None, cave=None): 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 + 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" #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} IGNORING caveslug field in the .html file." - DataIssue.objects.create(parser="caves", message=message, url=msgurl) # url here is for where the file actually is, for editing + 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.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 mvf.write(mvtext + "\n") print(message) |