diff --git a/parsers/caves.py b/parsers/caves.py
index f70cdcd..34a2301 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -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: