From 76f7b1077704f24ed1b257f029fc6d2ad902b82f Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 26 Jul 2025 14:31:11 +0200 Subject: [PATCH] Revised text on pending cave creation --- parsers/caves.py | 136 +++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 69 deletions(-) diff --git a/parsers/caves.py b/parsers/caves.py index df55e05..a77e3b2 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -35,10 +35,6 @@ todo = """ re.findall("<%(itemname)s>(.*?)" % {"itemname": itemname}, text, re.S) in modern form and pre-compile it. -- crashes on MariaDB in databasereset.py on server when deleting Caves and complains Area needs a - non null parent, But this is not true. The only solution we have found is to let it crash, then - stop and restart MariaDB (requires a logon able to sudo) and then restart the databasereset.py - again. (status as of July 2022). May not happen now that class Area is removed (Sept.2023). """ AREACODES = {"1623", "1624", "1626", "1627"} # NB set not dict ARGEAREAS = {"1626", "1627", "1624"} # NB set not dict @@ -75,18 +71,7 @@ def report_absent_entrace(id, slug, cave, msg="DUMMY"): 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}' - Is this a problem?" print(message) DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}") @@ -105,25 +90,13 @@ def create_new_cave(svxpath, svxid=None, msg=None): # e.g. svxpath = "caves-1623/666/beast" .svx - from the *inlcude tree # e.g. svxid = "caves-1623/666/beast" print(f"Create new cave at {svxpath} - {msg}") - # - survex_file = "" if svxid: - sv = Path(settings.SURVEX_DATA, svxid + ".svx") - if sv.is_file: - survex_file = svxid + ".svx" + sv = svxid else: - sv = Path(settings.SURVEX_DATA, svxpath + ".svx") - if sv.is_file: - survex_file = svxpath + ".svx" - - if survex_file: - # message = f"Found a survex file {survex_file=} {svxpath=} {svxid=} " - # DataIssue.objects.create(parser="caves", message=message) - # print(message, file=sys.stderr) - # print(message) - pass - else: - message = f"NOT found a survex file {svxpath=} {svxid=}" + sv = svxpath + survex_file = settings.SURVEX_DATA / sv / ".svx" + if not survex_file.is_file: + message = f"NOT found a survex file {sv} in create_new_cave() {svxpath=} {svxid=}" DataIssue.objects.create(parser="caves", message=message) print(message, file=sys.stderr) print(message) @@ -143,7 +116,7 @@ def create_new_cave(svxpath, svxid=None, msg=None): k = f"{areacode}-{caveid}" - caves = Cave.objects.filter(unofficial_number=caveid, areacode =areacode) + caves = Cave.objects.filter(unofficial_number=caveid, areacode=areacode) if caves: message = f" ! Already exists, caveid:{k} in areacode {areacode} {caves} - {msg}" DataIssue.objects.create(parser="caves", message=message) @@ -306,43 +279,68 @@ def do_pending_cave(slug, caveid, url, areacode, msg=None): DataIssue.objects.create(parser="caves", message=message, url=url) print(message) return + default_note = f""" + This cave in is the "pending" state. +

This can happen for 3 reasons: +

+ but no Cave Description exists yet [see below].

+ + INSTRUCTIONS:
+ Open 'This survex file' elsewhere on this page to find the date and info. Then +

    - default_note = "A reference has been found to this cave id in a survex file in the loser repo, or in a wallet metadata" - default_note += " in a JSON file in the drawings repo, but no Cave Description exists in expoweb (in /cave_data/)


    \n" - default_note += "INSTRUCTIONS: FIRST read the notes in pendingcaves.txt
    " - default_note += "Next open 'This survex file' (link above the CaveView panel) to find the date and info. Then " - default_note += '

    \n\n - (0) look in the cave number index for notes on this cave, ' - default_note += "

    \n\n - (1) search in the survex file for the *ref to find a " - default_note += "relevant wallet, e.g.2009#11 and read the notes image files
    \n - " - default_note += ( - "

    \n\n - (2) search in the Expo for that year e.g. 2009 to find a " - ) - default_note += "relevant logbook entry, remember that the date may have been recorded incorrectly, " - default_note += ( - "so check for trips i.e. logbook entries involving the same people as were listed in the survex file, " - ) - default_note += ( - "and you should also check the scanned copy of the logbook (linked from each logbook entry page) " - ) - default_note += "just in case a vital trip was not transcribed, then
    \n - " - default_note += ( - "click on 'Edit this cave' and copy the information you find in the survex file and the logbook" - ) - default_note += "and delete all the text in the 'Notes' section - which is the text you are reading now." - default_note += "

    \n\n - Only two fields on this form are essential. " - default_note += "Documentation of all the fields on 'Edit this cave' form is in handbook/survey/caveentryfields" - default_note += "

    \n\n - " - default_note += "You will also need to create a new entrance from the 'Edit this cave' page. Ignore the existing dummy one, it will evaporate on the next full import." - default_note += "

    \n\n - " - default_note += "When you Submit it will create a new file in expoweb/cave_data/ " - default_note += ( - "

    \n\n - Now you can edit the entrance info: click on Edit below for the dummy entrance. " - ) - default_note += "and then Submit to save it (if you forget to do this, a dummy entrance will be created for your new cave description)." - default_note += "

    \n\n - Finally, you need to find a nerd to edit the file 'expoweb/cave_data/pendingcaves.txt' " - default_note += ( - f"to remove the line
    {slug}
    as it is no longer 'pending' but 'done. Well Done." - ) +
  1. search in the survex file ({survex_file}) for the *ref to find + a relevant wallet, e.g.2009#11 and + read the notes image files n the wallet. +
      +
    • Scroll down to the bottom of the wallet page where you will find a list of logbook entries, + wallets and survex files which have all been dated to the same day. + Check all these to see if there is any other relevant information about this cave. +


    + +
  2. search in the Expo for that year e.g. 2009 to find a relevant logbook entry, + remember that the date may have been recorded incorrectly, so check for trips + i.e. logbook entries involving the same people as were listed in the survex file, + and you should also check the scanned copy of the logbook (linked from each logbook entry page) + just in case a vital trip was not fully transcribed (sketch images are missing for many years in the online logbooks). + +
  3. check the cave number index just in case there are notes for this cave,

    +
+ Then +
    +
  1. click on 'Edit this cave' [menu item on the left hand side of this page] to type in the Cave Description + and copy the information you find in the survex file, the wallet and the logbook and + delete all the dummy default text in the 'Notes' section of the Cave Description - which is the text you are reading now. + +
  2. Read the documentation of all the fields on 'Edit this cave' form. + It is in handbook/survey/caveentryfields

    + +
  3. You will also need to create a new entrance from the 'Edit this cave' page. + Ignore the existing dummy one, it will evaporate on the next full import.

    + +
  4. When you Submit the Cave form it will create a new file in expoweb/cave_data/

    + +
  5. Only now can you edit the entrance info: + click on Edit below for the dummy entrance. and then Submit to save it.

    + + - Finally, if there was an entry in the pending list, + edit the file 'expoweb/cave_data/pendingcaves.txt' to remove + the line referring to
    {caveid}
    as it is no longer 'pending' but 'done'. + Do this using this link: edit the pending list. Well Done. +
+ +

Explanatory footnote

+ A reference to this cave would be in + +
  • A survex file, which is stored in the :loser: repo. +
  • A wallet, which is stored in the walletjson folder inside the :drawings: repo. +
  • the pending caves file in the :expoweb: repo. Read the notes in pendingcaves.txt + + """ urltest = Cave.objects.filter(url=url) if urltest: message = f" ! Cave {urltest[0]} already exists with this url {url}. Can't create new cave {slug}"