2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 12:37:10 +00:00

Better tag locations

This commit is contained in:
2023-10-07 02:26:52 +03:00
parent c3642f1ae4
commit 5f67af35f0
9 changed files with 144 additions and 90 deletions

View File

@@ -10,6 +10,7 @@ from django.db import transaction
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup
from troggle.core.models.logbooks import CaveSlug
from troggle.core.models.survex import SurvexStation
from troggle.core.models.troggle import DataIssue
from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS, EXPOWEB, SURVEX_DATA
@@ -424,15 +425,22 @@ def boolify(boolstrs):
def validate_station(station):
"""It is possible to break troggle entirely by getting this wrong.
These station identifiers are matched against other statsions using .endswith()
These station identifiers are matched against other stations using .endswith()
in parsers/locations.py
so a simple number here will match hundreds of SUrvexStation objects
It should be, e.g. "1623.p240"
We will test them against survex stations after we have loaded them.
"""
if station == "":
return True
# CANNOT test against locations as we have not read the survex files yet. Hmph.
# Must have the right format in its name
dot = station.find(".")
if dot == -1:
print(dot)
# no full stop found. Bad station identifier.
raise
else:
@@ -540,6 +548,7 @@ def read_entrance(filename, ent=None):
ent.url=url[0]
for st in [ent.exact_station, ent.other_station, ent.tag_station]:
#validate_station(st)
try:
validate_station(st)
except:
@@ -547,9 +556,6 @@ def read_entrance(filename, ent=None):
#http://localhost:8000/1623/2023-EBH-01/1623-2023-EBH-01:1623-2023-EBH-01_entrance_edit
DataIssue.objects.create(parser="entrances", message=message, url=f"/1623/{slug}/{slug}:{slug}_entrance_edit")
print(message)
# ent_issues = DataIssue.objects.filter(parser="entrances")
# print(f".. We now have {len(ent_issues)} entrance DataIssues")
return None
ent.save()
return ent
@@ -811,6 +817,8 @@ def read_cave(filename, cave=None):
message = f' ! {slug:12} survex filename does not exist :LOSER:"{survex_file[0]}" in "{filename}"'
DataIssue.objects.create(parser="caves", message=message, url=f"/{slug[0:4]}/{slug}_cave_edit/")
print(message)
# else:
# print(f"{slug:12} survex filename UNSET")
if description_file[0]: # if not an empty string