From 8e1cf1021d8b398c4c59fff7c20719a53a72c3ac Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 30 Jun 2024 20:38:02 +0300 Subject: [PATCH] using filename for entrance_slug not the field in entrance_data file --- core/models/wallets.py | 1 + parsers/caves.py | 9 +++++---- templates/editentrance.html | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/core/models/wallets.py b/core/models/wallets.py index 0382adb..dbf3d14 100644 --- a/core/models/wallets.py +++ b/core/models/wallets.py @@ -208,6 +208,7 @@ class Wallet(models.Model): if not (Path(settings.SURVEX_DATA) / sx).is_file(): message=f"{self} Survex file {sx} was not found in LOSER repo" DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl) + # check using field on the cave whether it has been renamed... def allcaves(self): """Called when parsing importing all data. Called on all new wallets, but before diff --git a/parsers/caves.py b/parsers/caves.py index f9c9b61..c2559d4 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -484,7 +484,6 @@ def read_entrance(filename, ent=None): print(message) - # Derive the letter, entrance slug and cave slug fromthe filename entslug_fn = filename[:-5] if entslug_fn[-1] in LETTERS: @@ -617,9 +616,9 @@ def read_cave(filename, mvf=None, cave=None): eslug = getXML(e, "entranceslug", maxItems=1, context=context)[0] # if eslug.endswith(('a','b','c','d','e','f')): # print(f"! Entrance {eslug}") - if eslug.endswith('a b'): - message = f' - Entrance has weird name slug:"{eslug}" cave:"{cave}" caveslug:"{slug}" filename:"cave_data/{filename}"' - DataIssue.objects.create(parser="xEntrances", message=message, url=f"{cave.url}_cave_edit/") + # if eslug.endswith('a b'): + # message = f' - Entrance has weird name slug:"{eslug}" cave:"{cave}" caveslug:"{slug}" filename:"cave_data/{filename}"' + # DataIssue.objects.create(parser="xEntrances", message=message, url=f"{cave.url}_cave_edit/") # print(message) letter = getXML(e, "letter", maxItems=1, context=context)[0] @@ -837,6 +836,7 @@ def read_cave(filename, mvf=None, cave=None): # From here on the code applies to both edited and newly-imported caves (mostly!) do_caveslugstuff() # needs cave!=None + # We no longer need the tag to define 1623 etc as we get that from the filename. areas = getXML(cavecontents, "area", context=contextguess) # can be multiple tags for area_slug in areas: if area_slug in AREACODES: # ignore sub areas which are in another tag @@ -873,6 +873,7 @@ def read_cave(filename, mvf=None, cave=None): slug = check_slug(cave.areacode, cave.kataster_number, cave.unofficial_number, cave.url) #NB cave.slug is not a field on Cave + # Thsi whole way of doing entrances can be replaced by simply knowing formthe entrance_data filename what the cave is. entrances = getXML(cavecontents, "entrance", context=context) do_entrances() # print(f"- {entrances_xslug=}") diff --git a/templates/editentrance.html b/templates/editentrance.html index 64ee9df..957351f 100644 --- a/templates/editentrance.html +++ b/templates/editentrance.html @@ -46,7 +46,7 @@ at troggle/core/forms.py ass this uses a Django magic form creation thinggy. --> {{ent.bearings|safe}} {% endif %} -

+

{% endblock %}