2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 16:51:54 +00:00

moved aliases to people module, faster db too

This commit is contained in:
Philip Sargent 2023-01-28 14:03:46 +00:00
parent 9e71be8169
commit d9a4069662
2 changed files with 21 additions and 30 deletions

View File

@ -125,24 +125,7 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
if tripperson and tripperson[0] != "*":
tripperson = re.sub(rx_round_bracket, "", tripperson).strip()
# these aliases should be moved to people.py GetPersonExpeditionNameLookup(expedition)
if tripperson == "Wiggy":
tripperson = "Phil Wigglesworth"
if tripperson == "Animal":
tripperson = "Mike Richardson"
if tripperson == "MikeTA":
tripperson = "Mike Richardson"
if tripperson == "CavingPig":
tripperson = "Elaine Oliver"
if tripperson == "nobrotson":
tripperson = "Rob Watson"
if tripperson == "Tinywoman":
tripperson = "Nadia"
if tripperson == "tcacrossley":
tripperson = "Tom Crossley"
if tripperson == "Samouse1":
tripperson = "Todd Rye"
# Whacky aliases all handled in GetPersonExpeditionNameLookup()
personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower())
if not personyear:
message = f" ! - {expedition.year} No name match for: '{tripperson}' in entry {tid=} for this expedition year."

View File

@ -8,7 +8,6 @@ from django.conf import settings
from unidecode import unidecode
from troggle.core.models.troggle import DataIssue, Expedition, Person, PersonExpedition
from troggle.core.utils import save_carefully
"""These functions do not match how the stand-alone folk script works. So the script produces an HTML file which has
href links to pages in troggle which troggle does not think are right.
@ -74,17 +73,15 @@ def load_people_expos():
headers = next(personreader)
header = dict(list(zip(headers, list(range(len(headers))))))
# make expeditions
print(" - Loading expeditions")
years = headers[5:]
nexpos = Expedition.objects.count()
if nexpos <= 0:
print(" - Creating expeditions")
for year in years:
lookupAttribs = {"year": year}
nonLookupAttribs = {"name": f"CUCC expo {year}"}
e = Expedition.objects.create(**nonLookupAttribs, **lookupAttribs)
for year in years:
lookupAttribs = {"year": year}
nonLookupAttribs = {"name": f"CUCC expo {year}"}
save_carefully(Expedition, lookupAttribs, nonLookupAttribs)
# make persons
print(" - Loading personexpeditions")
for personline in personreader:
@ -116,7 +113,7 @@ def load_people_expos():
lookupAttribs = {"first_name": firstname, "last_name": (lastname or "")}
nonLookupAttribs = {"is_vfho": vfho, "fullname": fullname, "nickname": nickname}
person, created = save_carefully(Person, lookupAttribs, nonLookupAttribs)
person = Person.objects.create(**nonLookupAttribs, **lookupAttribs)
parse_blurb(personline=personline, header=header, person=person)
@ -126,7 +123,7 @@ def load_people_expos():
if attended == "1" or attended == "-1":
lookupAttribs = {"person": person, "expedition": expedition}
nonLookupAttribs = {"nickname": nickname, "is_guest": (personline[header["Guest"]] == "1")}
save_carefully(PersonExpedition, lookupAttribs, nonLookupAttribs)
pe = PersonExpedition.objects.create(**nonLookupAttribs, **lookupAttribs)
print("", flush=True)
@ -289,8 +286,19 @@ def GetPersonExpeditionNameLookup(expedition):
possnames.append("eric c. landgraf")
possnames.append("eric c landgraf")
if f"{f} {l}" == "Nadia Raeburn".lower():
possnames.append("tinywoman")
possnames.append("nadia rc")
possnames.append("nadia raeburn-cherradi")
if f"{f} {l}" == "Phil Wigglesworth".lower():
possnames.append("wiggy")
if f"{f} {l}" == "Elaine Oliver".lower():
possnames.append("cavingpig")
if f"{f} {l}" == "Tom Crossley".lower():
possnames.append("tcacrossley")
if f"{f} {l}" == "Rob Watson".lower():
possnames.append("nobrotson")
if f"{f} {l}" == "Todd Rye".lower():
possnames.append("samouse1")
for i in [3, 4, 5, 6]:
lim = min(i, len(f) + 1) # short form, e.g. Dan for Daniel.