2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 21:37:13 +00:00

replace GetCaveByReference

This commit is contained in:
Philip Sargent
2020-06-28 01:50:34 +01:00
parent 899ba13df4
commit 122cdd7fc8
5 changed files with 155 additions and 102 deletions

View File

@@ -201,15 +201,16 @@ class Cave(TroggleModel):
pass
return lowestareas[0]
def getCaveByReference(reference):
areaname, code = reference.split("-", 1)
area = Area.objects.get(short_name = areaname)
foundCaves = list(Cave.objects.filter(area = area, kataster_number = code).all()) + list(Cave.objects.filter(area = area, unofficial_number = code).all())
#print((list(foundCaves)))
if len(foundCaves) == 1:
return foundCaves[0]
else:
return False
# This seems to be peculiarly broken, and is now replaced for logbooks.
# def getCaveByReference(reference):
# areaname, code = reference.split("-", 1)
# area = Area.objects.get(short_name = areaname)
# foundCaves = list(Cave.objects.filter(area = area, kataster_number = code).all()) + list(Cave.objects.filter(area = area, unofficial_number = code).all())
# #print((list(foundCaves)))
# if len(foundCaves) == 1:
# return foundCaves[0]
# else:
# return False
class OtherCaveName(TroggleModel):
name = models.CharField(max_length=160)