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

ARGE caves, fixed bug in non-numeric ids

This commit is contained in:
Philip Sargent 2023-09-10 16:35:00 +03:00
parent 2f6017d6d3
commit 9d6552ea22
3 changed files with 21 additions and 16 deletions

View File

@ -165,24 +165,29 @@ def do_ARGE_cave(slug, caveid, url, areacode, svxid):
print(message)
return urltest[0]
numtest = Cave.objects.filter(unofficial_number=caveid.upper())
numtest = Cave.objects.filter(unofficial_number=caveid.upper(), areacode=areacode)
if numtest:
message = f" ! Cave {numtest[0]} already exists with this unofficial_number {caveid.upper()}. Can't create new ARGE cave {slug}"
message = f" ! Cave {numtest[0]} already exists with this areacode {areacode} and unofficial_number {caveid.upper()}. Can't create new ARGE cave {slug}"
DataIssue.objects.create(parser="caves", message=message, url=url)
print(message)
return numtest[0]
cave = Cave(
unofficial_number=caveid.upper(),
kataster_number=caveid.upper(), # should only set this if all digits
underground_description="ARGE cave.",
survex_file= f"{svxid}.svx",
url=url,
notes=default_note,
areacode=areacode,
cave = Cave(
underground_description="ARGE cave.",
survex_file= f"{svxid}.svx",
url=url,
notes=default_note,
areacode=areacode,
)
if cave:
cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key.
try:
kn = int(caveid)
cave.kataster_number=kn # should only set this if all digit
except:
# must be unofficial 'number' or name
cave.unofficial_number=caveid.upper()
cave.save()
try: # Now create a cave slug ID
CaveSlug.objects.update_or_create(cave=cave, slug=slug, primary=False)
@ -521,7 +526,7 @@ def read_cave(filename, cave=None):
# 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.areacode}/{cave.areacode}-{cave.url}_cave_edit/")
DataIssue.objects.create(parser="xEntrances", message=message, url=f"{cave.url}_cave_edit/")
# print(message)
letter = getXML(e, "letter", maxItems=1, context=context)[0]
@ -532,7 +537,7 @@ def read_cave(filename, cave=None):
if letter.lower() not in list(string.ascii_lowercase):
letter = "x"
message = f"- Warning - Empty 'letter' field for '{eslug}' in multiple-entrance cave '{cave}', setting to {letter}."
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.areacode}/{cave.areacode}-{cave.url}_cave_edit/")
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}_cave_edit/")
print(message)
if len(entrances) == 1 and not eslug: # may be empty: <entranceslug></entranceslug>
@ -550,7 +555,7 @@ def read_cave(filename, cave=None):
entrances_xslug[eslug] = entrance
except:
message = f"! Fail entrance loading {eslug} /entrance_data/{eslug} file does not exist or loading it failed."
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.areacode}/{cave.areacode}-{cave.url}_cave_edit/")
DataIssue.objects.create(parser="entrances", message=message, url=f"{cave.url}_cave_edit/")
print(message)
return

View File

@ -12,7 +12,7 @@
<tr><th>Cave</th><th>Cave primary</th><th>f.primary</th><th>f.path</th></tr>
{% for f in survexfiles %}
<tr>
<td><a href="/cave/{{f.cave}}">{{f.cave}}</a> {{f.cave.areacode}}{f.cave.subarea}}</td>
<td><a href="/cave/{{f.cave}}">{{f.cave}}</a> {{f.cave.areacode}}{% if f.cave.subarea %}-{{f.cave.subarea}}{% endif %}</td>
<td>{{f.cave.survex_file}}</td>
<td> {{f.primary}}.svx</td>
<td><span {% if f.pathbad %} style="color:red" {% endif %}><a href="/survexfile/{{f.path}}.svx">{{f.path}}.svx</a></span></td>

View File

@ -81,7 +81,7 @@ LOGMESSAGES
{% endif %}
</div>
underground survey length: {{svxlength|floatformat:2}} metres<br />
cave primary survexfile <a href="/survexfile/{{ survexfile.cave.survex_file }}">{{survexfile.cave.survex_file}}</a> <br>
<a href="/{{survexfile.cave.url}}">cave</a> primary survexfile <a href="/survexfile/{{ survexfile.cave.survex_file }}">{{survexfile.cave.survex_file}}</a> <br>
directory primary survexfile <a href="/survexfile/{{survexfile.primary}}.svx">{{survexfile.primary}}</a> <br />
{% for sb in svxblocks %}
block <em>{{sb}}</em> has parent block <em>{{sb.parent}}</em> (in file {{sb.parent.survexfile.path}}.svx)<br />