2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

fix QM regex for number and rearrange url code

This commit is contained in:
Philip Sargent 2022-07-20 17:02:38 +03:00
parent 549c1649b4
commit a215ebd62c
4 changed files with 17 additions and 25 deletions

View File

@ -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

View File

@ -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')

View File

@ -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>.

View File

@ -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}}