forked from expo/troggle
abbrv. names now accepted when parsing logbooks, survex
This commit is contained in:
@@ -146,6 +146,8 @@ def GetPersonExpeditionNameLookup(expedition):
|
||||
|
||||
#print("Calculating GetPersonExpeditionNameLookup for " + expedition.year)
|
||||
personexpeditions = PersonExpedition.objects.filter(expedition=expedition)
|
||||
short = {}
|
||||
dellist = []
|
||||
for personexpedition in personexpeditions:
|
||||
possnames = [ ]
|
||||
f = unidecode(unescape(personexpedition.person.first_name.lower()))
|
||||
@@ -158,6 +160,12 @@ def GetPersonExpeditionNameLookup(expedition):
|
||||
possnames.append(f[0] + " " + l)
|
||||
possnames.append(f[0] + l[0]) # initials e.g. gb or bl
|
||||
possnames.append(f)
|
||||
|
||||
lim = min(4, len(f)+1) # short form, e.g. Dan for Daniel. May be duplicate, e.g. several Dave
|
||||
if f[:lim] not in short:
|
||||
short[f[:lim]]= personexpedition
|
||||
else:
|
||||
dellist.append(f[:lim])
|
||||
if full not in possnames:
|
||||
possnames.append(full)
|
||||
if personexpedition.nickname not in possnames:
|
||||
@@ -180,6 +188,12 @@ def GetPersonExpeditionNameLookup(expedition):
|
||||
|
||||
for possname in duplicates:
|
||||
del res[possname]
|
||||
|
||||
for possname in dellist:
|
||||
if possname in short: #always true ?
|
||||
del short[possname]
|
||||
for shortname in short:
|
||||
res[shortname] = short[shortname]
|
||||
|
||||
Gpersonexpeditionnamelookup[expedition.name] = res
|
||||
return res
|
||||
|
||||
Reference in New Issue
Block a user