From a215ebd62c2cc24691eb74a426dee6555a106470 Mon Sep 17 00:00:00 2001 From: Philip Sargent <philip.sargent@klebos.com> Date: Wed, 20 Jul 2022 17:02:38 +0300 Subject: [PATCH] fix QM regex for number and rearrange url code --- core/models/caves.py | 2 +- parsers/survex.py | 31 +++++++++---------------------- templates/cave_qms.html | 3 ++- templates/qm.html | 6 +++++- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/core/models/caves.py b/core/models/caves.py index ea312df..3067520 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -507,7 +507,7 @@ class QM(TroggleModel): else: blocknamestr = "" #return f'{self.cave.slug()[5:]}-{self.expoyear}-{self.blockname}{self.number}{self.grade}' - return f'{cavestr}-{expoyearstr}-{blocknamestr}{self.number}{self.grade}' + return f'{cavestr}-{expoyearstr}-{self.number}{self.grade}-{blocknamestr}' def get_completion_url(self): '''assumes html file named is in same folder as cave description file diff --git a/parsers/survex.py b/parsers/survex.py index 942dbe9..876263c 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -119,9 +119,9 @@ class LoadingSurvex(): instruments = "(waiting_patiently|slacker|Useless|nagging|unknown|Inst|instrument|rig|rigger|rigging|helper|something| compass|comp|clino|Notes|sketch|book|Tape|Dog|Pics|photo|drawing|Helper|GPS|Disto|Distox|Distox2|topodroid|point|Consultant|nail|polish|nail_polish_bitch|nail_polish_monkey|varnish|nail_polish|nail_varnish|bitch|monkey|PowerDrill|drill)" rx_teammem = re.compile(r"(?i)"+instruments+"?(?:es|s)?\s+(.*)"+instruments+"?(?:es|s)?$") rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$") - rx_qm = re.compile(r'(?i)^\s*QM(\d)\s+?([a-dA-DxX])\s+([\w\-]+)\.(\d+)\s+(([\w\-]+)\.(\d+)|\-)\s+(.+)$') + rx_qm = re.compile(r'(?i)^\s*QM(\d+)\s+?([a-dA-DxX])\s+([\w\-]+)\.(\d+)\s+(([\w\-]+)\.(\d+)|\-)\s+(.+)$') # does not recognise non numeric suffix survey point ids - rx_qm0 = re.compile(r'(?i)^\s*QM(\d)\s+(.+)$') + rx_qm0 = re.compile(r'(?i)^\s*QM(\d+)\s+(.+)$') # remember there is also QM_PATTERN used in views.other and set in settings.py rx_tapelng = re.compile(r'(?i).*(tape|length).*$') @@ -539,28 +539,15 @@ class LoadingSurvex(): # Older troggle/CSV assumes a logbook entry 'found_by' for each QM, with a date. # We don't need this anymore so we don't need to create a placeholder logbook entry. qmyear = str(survexblock.date)[:4] - blockname = survexblock.name[:7] - logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}' + blockname = survexblock.name[:6] + survexblock.name[-1:] + #logslug = f'D{int(qmyear)}_{blockname}_{int(qm_no):03d}' if survexblock.survexfile.cave: caveslug = survexblock.survexfile.cave.slug() place = survexblock.survexfile.cave else: caveslug = None place = None - - - # message = f' ! - logbook dummy "{logslug}" {str(survexblock.date)[:11]} for cave "{caveslug}" created.' - # placeholder, hadToCreate = LogbookEntry.objects.get_or_create(date__year=qmyear, - # place=place, - # title="placeholder for survex QM", - # text=message, - # entry_type="DUMMY", - # expedition_id=1, - # defaults={"date": survexblock.date,"cave_slug":caveslug, "slug": logslug}) - # print(insp+message) - # DataIssue.objects.create(parser='survex', message=message) - try: qm = QM.objects.create(number=qm_no, # nearest_station=a_survex_station_object, # can be null @@ -570,13 +557,13 @@ class LoadingSurvex(): location_description=qm_notes, block = survexblock, # only set for survex-imported QMs blockname = blockname, # only set for survex-imported QMs - # found_by = placeholder, expoyear = str(survexblock.date.year), cave = survexblock.survexfile.cave) qm.save - # message = " ! QM{} '{}' CREATED in DB in '{}'".format(qm_no, qm_nearest,survexblock.survexfile.path) - # print(insp+message) - # DataIssue.objects.create(parser='survex', message=message) + if survexblock.survexfile.cave.kataster_number == "359": + message = " ! QM{} '{}' CREATED in DB in '{}'".format(qm_no, qm_nearest,survexblock.survexfile.path) + print(insp+message) + DataIssue.objects.create(parser='survex', message=message) except: message = " ! QM{} FAIL to create {} in'{}'".format(qm_no, qm_nearest,survexblock.survexfile.path) print(insp+message) @@ -834,7 +821,7 @@ class LoadingSurvex(): if qmline: self.LoadSurvexQM(survexblock, qmline) else: - message = f' ! QM Unrecognised as a valid QM in "{survexblock.survexfile.path}" QM{qml.group(1)} {qml.group(2)}' + message = f' ! QM Unrecognised as valid in "{survexblock.survexfile.path}" QM{qml.group(1)} {qml.group(2)} : non-numeric station name?' print(message) DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx') diff --git a/templates/cave_qms.html b/templates/cave_qms.html index 358d098..50f5220 100644 --- a/templates/cave_qms.html +++ b/templates/cave_qms.html @@ -16,7 +16,8 @@ <li><a href="{% url 'caveQMs' '1623-264' %}">1623-264 QMs</a> Balkon <li><a href="{% url 'caveQMs' '1623-258' %}">1623-258 QMs</a> Tunnocks <li><a href="{% url 'caveQMs' '1623-290' %}">1623-290 QMs</a> Fischgesicht - <li><a href="{% url 'caveQMs' '1626-359' %}">1626-359 QMs</a> Homecoming (2018-dm-07) + <li><a href="{% url 'caveQMs' '1623-291' %}">1623-290 QMs</a> Happy Butterfly + <li><a href="{% url 'caveQMs' '1626-359' %}">1626-359 QMs</a> Homecoming </ul> <p>For full explanation of the current status of the QM system(s), see <a href="/handbook/troggle/scriptsqms.html">scriptsqms page</a>. diff --git a/templates/qm.html b/templates/qm.html index eb28174..deedc86 100644 --- a/templates/qm.html +++ b/templates/qm.html @@ -13,7 +13,8 @@ <li><a href="{% url 'caveQMs' '1623-264' %}">1623-264 QMs</a> Balkon <li><a href="{% url 'caveQMs' '1623-258' %}">1623-258 QMs</a> Tunnocks <li><a href="{% url 'caveQMs' '1623-290' %}">1623-290 QMs</a> Fischgesicht - <li><a href="{% url 'caveQMs' '1626-359' %}">1626-359 QMs</a> Homecoming (2018-dm-07) + <li><a href="{% url 'caveQMs' '1623-291' %}">1623-290 QMs</a> Happy Butterfly + <li><a href="{% url 'caveQMs' '1626-359' %}">1626-359 QMs</a> Homecoming </ul> <p>For full explanation of the current status of the QM system(s), see <a href="/handbook/troggle/scriptsqms.html">scriptsqms page</a>. @@ -52,6 +53,9 @@ <br> {{qm.blockname}} +<h3>QM Number</h3> +{{qm.number}} + <h3>Grade</h3> {{qm.grade}}