mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
restore lookup() function
This commit is contained in:
parent
859a28b4ee
commit
e71939fe00
@ -69,7 +69,7 @@ class SurvexFile(models.Model):
|
||||
|
||||
|
||||
class SurvexStationLookUpManager(models.Manager):
|
||||
"""Don't know what this does,
|
||||
"""what this does,
|
||||
https://docs.djangoproject.com/en/dev/topics/db/managers/
|
||||
This changes the .objects thinggy to use a case-insensitive match name__iexact
|
||||
so that now SurvexStation.objects.lookup() works as a case-insensitive match
|
||||
@ -104,26 +104,27 @@ class SurvexStation(models.Model):
|
||||
def __str__(self):
|
||||
return self.name and str(self.name) or "no name"
|
||||
|
||||
|
||||
#
|
||||
# Single SurvexBlock
|
||||
#
|
||||
# class SurvexBlockLookUpManager(models.Manager):
|
||||
# """Don't know what this does,
|
||||
# https://docs.djangoproject.com/en/dev/topics/db/managers/
|
||||
class SurvexBlockLookUpManager(models.Manager):
|
||||
"""what this does,
|
||||
https://docs.djangoproject.com/en/dev/topics/db/managers/
|
||||
|
||||
# This changes the .objects_set thinggy to use a case-insensitive match name__iexact
|
||||
# so that now SurvexBlock.objects.lookup() works as a case-insensitive match UNUSED
|
||||
# """
|
||||
# def lookup(self, name):
|
||||
# if name == "":
|
||||
# blocknames = []
|
||||
# else:
|
||||
# blocknames = name.split(".")
|
||||
# # block = SurvexBlock.objects.get(parent=None, survexfile__path=settings.SURVEX_TOPNAME)
|
||||
# for blockname in blocknames:
|
||||
# block = SurvexBlock.objects.get(parent=block, name__iexact=blockname)
|
||||
# return block
|
||||
This adds a method to the .objects thinggy to use a case-insensitive match name__iexact
|
||||
so that now SurvexBlock.objects.lookup() works as a case-insensitive match.
|
||||
This is used in lookup() in SurvexStationLookUpManager()
|
||||
which is used in Entrance().other_location() which is used in the Cave webpage
|
||||
"""
|
||||
def lookup(self, name):
|
||||
if name == "":
|
||||
blocknames = []
|
||||
else:
|
||||
blocknames = name.split(".")
|
||||
# block = SurvexBlock.objects.get(parent=None, survexfile__path=settings.SURVEX_TOPNAME)
|
||||
for blockname in blocknames:
|
||||
block = SurvexBlock.objects.get(parent=block, name__iexact=blockname)
|
||||
return block
|
||||
|
||||
|
||||
class SurvexBlock(models.Model):
|
||||
|
Loading…
Reference in New Issue
Block a user