Changes needed to stop the survex parser having to go through the data twice

Taken from the Django 1.10 upgrade branch
This commit is contained in:
Sam Wenham
2020-02-21 15:57:07 +00:00
parent f5fe2d9e33
commit e77aa9fb84
3 changed files with 186 additions and 79 deletions

View File

@@ -535,13 +535,15 @@ class Cave(TroggleModel):
def getCaveByReference(reference):
areaname, code = reference.split("-", 1)
print(areaname, code)
#print(areaname, code)
area = Area.objects.get(short_name = areaname)
print(area)
foundCaves = list(Cave.objects.filter(area = area, kataster_number = code).all()) + list(Cave.objects.filter(area = area, unofficial_number = code).all())
#print(area)
foundCaves = list(Cave.objects.filter(area = area, kataster_number = code).all()) + list(Cave.objects.filter(area = area, unofficial_number = code).all())
print(list(foundCaves))
assert len(foundCaves) == 1
return foundCaves[0]
if len(foundCaves) == 1:
return foundCaves[0]
else:
return False
class OtherCaveName(TroggleModel):
name = models.CharField(max_length=160)