diff options
Diffstat (limited to 'core/views/caves.py')
-rw-r--r-- | core/views/caves.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/core/views/caves.py b/core/views/caves.py index d7699d0..795bb18 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -16,7 +16,7 @@ from django.urls import NoReverseMatch, reverse import troggle.settings as settings from troggle.core.forms import CaveAndEntranceFormSet, CaveForm, EntranceForm, EntranceLetterForm from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently -from troggle.core.models.logbooks import CaveSlug, QM +from troggle.core.models.logbooks import QM from troggle.core.models.wallets import Wallet from troggle.core.utils import write_and_commit from troggle.core.utils import current_expo @@ -51,9 +51,9 @@ todo = """ # """ # return redirect("/caves") + def get_cave_from_slug(caveslug): - """This is the old way of doing it, usingt eh CaveSlug intermediate object which does - the many:many relationship between slugs and caves - whcih we don't do (and never did in practice) + """Needs refactoring """ caves = [] @@ -74,10 +74,14 @@ def get_cave_from_slug(caveslug): if len(caves) > 1: print(f"get_cave_from_slug(): {caveslug} More than 1 \n{caves}") + return None if len(caves) <1: print(f"get_cave_from_slug(): {caveslug} Nowt found..") + return None cave = caves[0] print(f"get_cave_from_slug(): {caveslug} FOUND {cave}") + return cave + try: cave_zero = Cave.objects.get(caveslug__slug=caveslug) |