summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/models/caves.py12
-rw-r--r--core/models/wallets.py3
-rw-r--r--core/views/scans.py81
3 files changed, 70 insertions, 26 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index 2769cdb..3e2511b 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -598,9 +598,13 @@ def GetCaveLookup():
("2007-71", "1623-271"),
("2010-01", "1623-263"),
("2010-03", "1623-293"),
+ ("2012-70", "1623-296"),
+ ("1623-2012-70", "1623-296"),
+ ("2012-dd-05", "1623-286"),
+ ("2012-dd-08", "1623-297"),
# ("2011-01", "1623-292"), seems to be a mistake
("2012-dd-05", "1623-286"),
- ("2012-0w-01", "2012-ow-01"),
+ ("2012-0w-01", "2012-ow-01"), # typo zero for 'O'
("2012-ns-13", "1623-292"),
("2014-neo-01", "1623-273"),
("2014-sd-01", "1623-274"),
@@ -624,8 +628,8 @@ def GetCaveLookup():
("2011-01-bs30", "1623-190"),
("bs30", "1623-190"),
("2011-01", "1623-190"),
- ("2002-x11", "2005-08"),
- ("2002-x12", "2005-07"),
+ ("2002-x11", "1623-2005-08"),
+ ("2002-x12", "1623-2005-07"),
("2002-x13", "1623-2005-06"),
("2002-x14", "2005-05"),
("kh", "1623-161"),
@@ -676,7 +680,7 @@ def GetCaveLookup():
else:
message = f" * Coding or cave existence mistake, cave for id '{alias}' does not exist. Expecting to set alias '{key}' to it"
print(message)
- DataIssue.objects.create(parser="aliases", message=message)
+ DataIssue.objects.update_or_create(parser="aliases", message=message)
addmore = {}
for id in Gcavelookup:
diff --git a/core/models/wallets.py b/core/models/wallets.py
index 9725a88..dd8567d 100644
--- a/core/models/wallets.py
+++ b/core/models/wallets.py
@@ -53,7 +53,8 @@ def make_valid_date(date):
return None
if datestr: # might have been None
- print(f"! - Failed to understand date, none of our tricks worked {datestr=} ")
+ if datestr != "None":
+ print(f"! - Failed to understand date, none of our tricks worked {datestr=} ")
return None
archaic_wallets = [
diff --git a/core/views/scans.py b/core/views/scans.py
index 4159618..6efcce1 100644
--- a/core/views/scans.py
+++ b/core/views/scans.py
@@ -43,12 +43,12 @@ def populatewallet(w):
Only gets data from the survex file when it was parsed on import, or edited (& thus parsed) online,
so doesn't work if there was no *ref value
"""
- slugpeople = []
+ slugpeople = set()
blocks = SurvexBlock.objects.filter(scanswallet=w)
for b in blocks:
for personrole in b.survexpersonrole_set.all():
- slugpeople.append(personrole.person) # Person objects, not the names anymore
- w.slugpeople = list(set(slugpeople))
+ slugpeople.add(personrole.person) # Person objects, not the names anymore
+ w.slugpeople = slugpeople
def caveifywallet(w):
@@ -80,9 +80,9 @@ def fillblankpeople(w):
if no one explicitly attached.
the JSON string which may OR MAY NOT be formatted as a list.
- w.slugpeople is set only if there is no explicit string of people's name in the wallet
- w.persons is set only if there is an explicit list of peoples' names in the wallet
- The template choses which to display depending on whether w.slugpeople exists or not.
+ w.slugpeople is from the survexfiles
+ w.persons is from the explicit list of peoples' names in the wallet
+ The template choses how to display them.
"""
def nobody(wplist):
if len(wplist) > 1:
@@ -94,7 +94,7 @@ def fillblankpeople(w):
else:
return False
- wp = w.people() # just a list of names as strings, direct from JSON. Replace with list of Person objects in parser?
+ wp = w.people() # just a list of names as strings, direct from JSON.
if not isinstance(wp, list): # might be None
print(f"{w} NOT A LIST {type(wp)}: {wp}")
populatewallet(w)
@@ -109,9 +109,13 @@ def fillblankpeople(w):
if nobody(wp):
populatewallet(w) # sets w.slugpeople
else:
- w.persons = wp
+ w.persons = parse_name_list(w)
+ populatewallet(w) # sets w.slugpeople
+ if hasattr(w, "slugpeople"):
+ w.persons = w.persons.difference(w.slugpeople)
return
+
def is_cave(wallet, id):
if not id:
return False
@@ -162,18 +166,43 @@ def fillblankothers(w):
w.caveobj = Gcavelookup[wcaveid.strip("' []'")]
-
-
def fixsurvextick(w, ticks):
ticks["S"] = w.fixsurvextick(ticks["S"])
-
+def parse_name_list(w):
+ """Given a list of strings, which are names, and the year of an expo,
+ return a set of Persons
+ """
+ namelist = w.people()
+ peeps = set()
+ expo = Expedition.objects.get(year=w.year())
+ crew = GetPersonExpeditionNameLookup(expo)
+
+ for n in namelist:
+ # if n.lower().startswith("lydia"):
+ # print(f"{w} {n=} ")
+ # for x in crew:
+ # if x.lower()==n.lower():
+ # print(f"{w} {n=} {x=}")
+
+ if n.lower() in crew:
+ peeps.add(crew[n.lower()].person)
+ else:
+ if n.startswith("*"): #ignore people flagged as guests or not-expo anyway, such as ARGE
+ pass
+ nobod = n.lower()
+ if nobod == "unknown" or nobod == "nobody" or nobod == " " or nobod == "":
+ pass
+ else:
+ wurl = f"/walletedit/{w.walletname.replace('#',':')}"
+ message = f"{w} name '{n.lower()}' NOT found in GetPersonExpeditionNameLookup({w.year()}) ?!"
+ print(message)
+ DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
+ return peeps
+
def walletslistperson(request, slug):
"""Page which displays a list of all the wallets for a specific person
- HORRIBLE linear search through everything. Index and do SQL query properly
- Currently ONLY getting wallets with survex files attached, not free-text searching the wallet.people list
"""
- # GetPersonExpeditionNameLookup
# Remember that 'personexpedition__expedition' is interpreted by Django to mean the
# 'expedition' object which is connected by a foreign key to the 'personexpedition'
@@ -183,29 +212,39 @@ def walletslistperson(request, slug):
def personwallet(p):
manywallets = set()
+ # Get the persons from the survexblocks on the survexfiles attached to the wallet directly
sps = SurvexPersonRole.objects.filter(person=p)
for sp in sps:
w = sp.survexblock.scanswallet
if w:
manywallets.add(w)
-
+
+ # Now read the text strings in the list of wallet people and identify the person
pes = PersonExpedition.objects.filter(person=p)
for person_expo in pes:
expo = person_expo.expedition
year = expo.year
+ crew = GetPersonExpeditionNameLookup(expo)
wallets = Wallet.objects.filter(walletyear__year=year)
for w in wallets:
- if w in manywallets: # already seen it
+ if w in manywallets:
+ # we already know this is a wallet we need to report on
continue
- w.persons = w.people() # ephemeral attribute 'persons' for web page
- crew = GetPersonExpeditionNameLookup(expo)
- for n in w.persons:
+ for n in w.people():
+ # if n.lower().startswith("lydia"):
+ # print(f"{w} {n=} ")
+ # for x in crew:
+ # if x.lower()==n.lower():
+ # print(f"{w} {n=} {x=}")
+
if n.lower() in crew:
if crew[n.lower()] == person_expo:
manywallets.add(w)
# print(f"{w} Found a non-survex wallet for {person_expo}")
else:
+ if n.startswith("*"): #ignore people flagged as guests or not-expo anyway, such as ARGE
+ pass
nobod = n.lower()
if nobod == "unknown" or nobod == "nobody" or nobod == " " or nobod == "":
pass
@@ -337,8 +376,8 @@ def cavewallets(request, caveid):
# print(f' - Found one ! {z.walletname=} {zcaveid=}')
wallets.add(z)
elif cleanid in ['surface', 'unknown', '']:
- message = f" ! In {z.walletname} cavewallets, ignoring '{cleanid}' as not a cave"
- print(message)
+ # message = f" ! In {z.walletname} cavewallets, ignoring '{cleanid}' as not a cave"
+ # print(message)
pass
else:
wurl = f"/walletedit/{z.walletname.replace('#',':')}"