2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 22:57:07 +00:00

wallets & caves now many:many

This commit is contained in:
2023-10-21 16:22:20 +03:00
parent 24029be7d3
commit e7a0c57330
11 changed files with 112 additions and 67 deletions

View File

@@ -40,6 +40,20 @@ todo = """
https://zerotobyte.com/how-to-use-django-select-related-and-prefetch-related/
"""
def get_cave_leniently(caveid):
try:
c = getCave(caveid)
if c:
return c
except:
# print(f"get_cave_leniently FAIL {caveid}")
try:
c = getCave("1623-"+caveid)
if c:
return c
except:
return None
def getCaves(cave_id):
"""Only gets called if a call to getCave() raises a MultipleObjects exception
@@ -59,7 +73,8 @@ def getCaves(cave_id):
def getCave(cave_id):
"""Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm.
"""Returns a cave object when given a cave name or number.
It is used by views including cavehref, ent, wallets and qm.
TO DO: search GCavelookup first, which should raise a MultpleObjectsReturned exception if there
are duplicates"""