mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 00:31:55 +00:00
Make people listed in wallets url-linkable
This commit is contained in:
parent
eae919e5b2
commit
fcfa59cdf7
@ -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:
|
||||
|
@ -53,6 +53,7 @@ def make_valid_date(date):
|
||||
return None
|
||||
|
||||
if datestr: # might have been None
|
||||
if datestr != "None":
|
||||
print(f"! - Failed to understand date, none of our tricks worked {datestr=} ")
|
||||
return None
|
||||
|
||||
|
@ -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('#',':')}"
|
||||
|
@ -23,7 +23,7 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Red star <span style="color: red">*</span> against a name indicates that no survex file is explicitly associated with the cave.
|
||||
Red star <span style="color: red">*</span> against a name indicates that no survex file is explicitly associated with the cave (but there might be a *fix somewhere)
|
||||
|
||||
<h3>1623</h3>
|
||||
<div style="column-count: 3;">
|
||||
|
@ -31,8 +31,13 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
||||
|
||||
<td style="padding:2px">{% if wallet.walletdate %}{{wallet.walletdate}}{% else %} {% endif %}</td>
|
||||
<td style="padding:2px">{% if wallet.name %}{{wallet.name|truncatechars:20}}{% else %}<em>{% if wallet.displaynames %} {% for dn in wallet.displaynames %}{{dn}}{%if not forloop.last %}, {% endif %} {% endfor %}{% else %} {% endif %}</em>{% endif %}</td>
|
||||
<td style="padding:2px">{% if wallet.slugpeople %}<em>{%for p in wallet.slugpeople%}<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}{% endfor %}</em>{% else %}{{wallet.persons }}{% endif %}</td>
|
||||
<td align="center" style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.singlescan_set.all|length}}</a></td>
|
||||
<td style="padding:2px">
|
||||
{% if wallet.slugpeople %}
|
||||
<em>{%for p in wallet.slugpeople%}<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}{% endfor %}</em>
|
||||
{% endif %}
|
||||
{%for p in wallet.persons%}
|
||||
<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}
|
||||
{% endfor %}</td> <td align="center" style="padding:2px"><a href="{{wallet.get_absolute_url}}">{{wallet.singlescan_set.all|length}}</a></td>
|
||||
<td style="padding:2px">
|
||||
{% for survexblock in wallet.survexblock_set.all %}
|
||||
<a href="{% url "svx" survexblock.survexfile.path %}">{{survexblock}}</a>
|
||||
@ -49,5 +54,5 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<br />Names in italics are taken from the associated survex file blocks, names not in italics are listed explicitly on the wallet.
|
||||
{% endblock %}
|
@ -30,7 +30,13 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
||||
|
||||
<td style="padding:2px" >{% if wallet.walletdate %}{{wallet.walletdate}}{% else %} {% endif %}</td>
|
||||
<td style="padding:2px">{% if wallet.name %}{{wallet.name|truncatechars:20}}{% else %}<em>{% if wallet.displaynames %} {% for dn in wallet.displaynames %}{{dn}}{%if not forloop.last %}, {% endif %} {% endfor %}{% else %} {% endif %}</em>{% endif %}</td>
|
||||
<td style="padding:2px">{% if wallet.slugpeople %}<em>{%for p in wallet.slugpeople%}<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}{% endfor %}</em>{% else %}{{wallet.persons }}{% endif %}</td>
|
||||
<td style="padding:2px">
|
||||
{% if wallet.slugpeople %}
|
||||
<em>{%for p in wallet.slugpeople%}<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}{% endfor %}</em>
|
||||
{% endif %}
|
||||
{%for p in wallet.persons%}
|
||||
<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}
|
||||
{% endfor %}</td>
|
||||
<td style="padding:2px">
|
||||
{% if wallet.cave %}
|
||||
{% if wallet.caveobj.slug %}
|
||||
@ -58,6 +64,6 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<br />Names in italics are taken from the associated survex file blocks, names not in italics are listed explicitly on the wallet.
|
||||
|
||||
{% endblock %}
|
@ -39,7 +39,13 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
||||
|
||||
<td style="padding:2px">{% if wallet.walletdate %}{{wallet.walletdate}}{% else %} {% endif %}</td>
|
||||
<td style="padding:2px">{% if wallet.name %}{{wallet.name|truncatechars:20}}{% else %}<em>{% if wallet.displaynames %} {% for dn in wallet.displaynames %}{{dn}}{%if not forloop.last %}, {% endif %} {% endfor %}{% else %} {% endif %}</em>{% endif %}</td>
|
||||
<td style="padding:2px">{% if wallet.slugpeople %}<em>{%for p in wallet.slugpeople%}<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}{% endfor %}</em>{% else %}{{wallet.persons }}{% endif %}</td>
|
||||
<td style="padding:2px">
|
||||
{% if wallet.slugpeople %}
|
||||
<em>{%for p in wallet.slugpeople%}<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}{% endfor %}</em>
|
||||
{% endif %}
|
||||
{%for p in wallet.persons%}
|
||||
<a href="/person/{{p.slug}}">{{p.fullname}}</a>{%if not forloop.last %}, {% endif %}
|
||||
{% endfor %}</td>
|
||||
<td style="padding:2px">
|
||||
{% if wallet.cave %}
|
||||
{% if wallet.caveobj.slug %}
|
||||
@ -67,5 +73,5 @@ traced to produce Tunnel or Therion drawings and eventually the final complete c
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
<br />Names in italics are taken from the associated survex file blocks, names not in italics are listed explicitly on the wallet.
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user