summaryrefslogtreecommitdiffstats
path: root/core/views/caves.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-10-21 16:22:20 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-10-21 16:22:20 +0300
commite7a0c57330a9c3808531b4d401d0cedf0f0c0638 (patch)
tree83eea4cf4da7a90b1f9062bf1988ef45f9d3ef5c /core/views/caves.py
parent24029be7d3406e4c3ce7790c066b4ad6033c4202 (diff)
downloadtroggle-e7a0c57330a9c3808531b4d401d0cedf0f0c0638.tar.gz
troggle-e7a0c57330a9c3808531b4d401d0cedf0f0c0638.tar.bz2
troggle-e7a0c57330a9c3808531b4d401d0cedf0f0c0638.zip
wallets & caves now many:many
Diffstat (limited to 'core/views/caves.py')
-rw-r--r--core/views/caves.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/core/views/caves.py b/core/views/caves.py
index bd559bb..bc5d6d7 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -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"""