Fixed QMs in Admin control panel &remv. OtherCave

This commit is contained in:
Philip Sargent
2020-07-23 02:16:08 +01:00
parent 64727e0d3a
commit 809633bdd3
4 changed files with 27 additions and 28 deletions

View File

@@ -11,7 +11,7 @@ from django.template.defaultfilters import slugify
from django.utils.timezone import get_current_timezone, make_aware
from troggle.core.models import DataIssue, Expedition
from troggle.core.models_caves import Cave, OtherCaveName, LogbookEntry, PersonTrip, GetCaveLookup
from troggle.core.models_caves import Cave, LogbookEntry, PersonTrip, GetCaveLookup
from parsers.people import GetPersonExpeditionNameLookup
from utils import save_carefully
@@ -50,35 +50,31 @@ def GetTripPersons(trippeople, expedition, logtime_underground):
return res, author
def GetTripCave(place):
#need to be fuzzier about matching here. Already a very slow function...
# print "Getting cave for " , place
try:
katastNumRes=[]
katastNumRes=list(Cave.objects.filter(kataster_number=int(place)))
except ValueError:
pass
message = " ! - ValueError on finding place " + str(place) + " entered. " + tripdate + " - " + year
DataIssue.objects.create(parser='logbooks', message=message)
logdataissues["author"]=message
officialNameRes=list(Cave.objects.filter(official_name=place))
tripCaveRes=officialNameRes+katastNumRes
if len(tripCaveRes)==1:
# print "Place " , place , "entered as" , tripCaveRes[0]
return tripCaveRes[0]
elif OtherCaveName.objects.filter(name=place):
tripCaveRes=OtherCaveName.objects.filter(name__icontains=place)[0].cave
# print "Place " , place , "entered as" , tripCaveRes
return tripCaveRes
elif len(tripCaveRes)>1:
print(("Ambiguous place " + str(place) + " entered. Choose from " + str(tripCaveRes)))
correctIndex=eval(input("type list index of correct cave"))
return tripCaveRes[correctIndex]
message = " ! - Ambiguous place " + str(place) + " entered. " + tripdate + " - " + year + " " + str(tripCaveRes)
DataIssue.objects.create(parser='logbooks', message=message)
logdataissues["author"]=message
return tripCaveRes[0]
else:
print(("No cave found for place " , place))
print((" " , place))
message = " ! - No cave found for place:" + str(place) + tripdate + " - " + year
DataIssue.objects.create(parser='logbooks', message=message)
logdataissues["author"]=message
return None
logentries = [] # the entire logbook for one year is a single object: a list of entries
noncaveplaces = [ "QMplaceholder", "Journey", "Loser Plateau", "UNKNOWN", 'plateau',
'base camp', 'basecamp', 'top camp', 'topcamp' ]