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

remove 'primary' concept from entrance slugs. tested.

This commit is contained in:
2023-03-28 17:08:55 +01:00
parent 6ca5d5bfa8
commit bbc13c4eb9
4 changed files with 15 additions and 22 deletions

View File

@@ -48,13 +48,13 @@ def dummy_entrance(k, slug, msg="DUMMY"):
if ent:
ent.save() # must save to have id before foreign keys work.
try: # Now create a entrance slug ID
EntranceSlug(entrance=ent, slug=slug, primary=False)
EntranceSlug(entrance=ent, slug=slug)
except:
message = f" ! {k:11s} {msg}-{slug} entrance create failure"
DataIssue.objects.create(parser="caves", message=message, url=f"{slug}")
print(message)
ent.cached_primary_slug = slug
ent.cached_slug = slug
ent.filename = slug + ".html"
ent.save()
return ent
@@ -362,13 +362,12 @@ def readentrance(filename):
bearings=bearings[0],
url=url[0],
filename=filename,
cached_primary_slug=slugs[0],
cached_slug=slugs[0],
)
primary = True
for slug in slugs:
# print("entrance slug:{} filename:{}".format(slug, filename))
try:
EntranceSlug.objects.update_or_create(entrance=e, slug=slug, primary=primary)
EntranceSlug.objects.update_or_create(entrance=e, slug=slug)
except:
# need to cope with duplicates
message = f" ! FAILED to get precisely one ENTRANCE when updating using: cave_entrance/{filename}"
@@ -383,7 +382,6 @@ def readentrance(filename):
if k.slug() is not None:
print(" ! - OVERWRITING this one: slug:" + str(k.slug()))
k.notes = "DUPLICATE entrance found on import. Please fix\n" + k.notes
primary = False
# else: # more than one item in long list. But this is not an error, and the max and min have been checked by getXML
# slug = Path(filename).stem
# message = f' ! ABORT loading this entrance. in "{filename}"'