mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 00:31:55 +00:00
new report to make aliases visible
This commit is contained in:
parent
b470ab66e2
commit
e6ca20b1ed
@ -122,6 +122,7 @@ class Person(TroggleModel):
|
|||||||
first_name = models.CharField(max_length=100)
|
first_name = models.CharField(max_length=100)
|
||||||
last_name = models.CharField(max_length=100)
|
last_name = models.CharField(max_length=100)
|
||||||
fullname = models.CharField(max_length=200)
|
fullname = models.CharField(max_length=200)
|
||||||
|
nickname = models.CharField(max_length=200)
|
||||||
is_vfho = models.BooleanField(help_text="VFHO is the Vereines für Höhlenkunde in Obersteier, a nearby Austrian caving club.", default=False)
|
is_vfho = models.BooleanField(help_text="VFHO is the Vereines für Höhlenkunde in Obersteier, a nearby Austrian caving club.", default=False)
|
||||||
mug_shot = models.CharField(max_length=100, blank=True,null=True)
|
mug_shot = models.CharField(max_length=100, blank=True,null=True)
|
||||||
blurb = models.TextField(blank=True,null=True)
|
blurb = models.TextField(blank=True,null=True)
|
||||||
@ -170,7 +171,7 @@ class PersonExpedition(TroggleModel):
|
|||||||
"""
|
"""
|
||||||
expedition = models.ForeignKey(Expedition,on_delete=models.CASCADE)
|
expedition = models.ForeignKey(Expedition,on_delete=models.CASCADE)
|
||||||
person = models.ForeignKey(Person,on_delete=models.CASCADE)
|
person = models.ForeignKey(Person,on_delete=models.CASCADE)
|
||||||
slugfield = models.SlugField(max_length=50,blank=True, null=True)
|
slugfield = models.SlugField(max_length=50,blank=True, null=True) # 2022 to be used in future
|
||||||
|
|
||||||
is_guest = models.BooleanField(default=False)
|
is_guest = models.BooleanField(default=False)
|
||||||
COMMITTEE_CHOICES = (
|
COMMITTEE_CHOICES = (
|
||||||
|
@ -14,6 +14,7 @@ from django.utils import timezone
|
|||||||
from troggle.core.models.troggle import Expedition, Person, PersonExpedition, DataIssue
|
from troggle.core.models.troggle import Expedition, Person, PersonExpedition, DataIssue
|
||||||
from troggle.core.models.caves import Cave, LogbookEntry, Entrance
|
from troggle.core.models.caves import Cave, LogbookEntry, Entrance
|
||||||
from troggle.core.models.survex import SurvexBlock, SurvexStation
|
from troggle.core.models.survex import SurvexBlock, SurvexStation
|
||||||
|
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||||
|
|
||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
|
|
||||||
@ -170,3 +171,16 @@ def eastings(request):
|
|||||||
stations = SurvexStation.objects.all()
|
stations = SurvexStation.objects.all()
|
||||||
|
|
||||||
return render(request,'eastings.html', {'ents': ents, 'stations': stations})
|
return render(request,'eastings.html', {'ents': ents, 'stations': stations})
|
||||||
|
|
||||||
|
def aliases(request, year):
|
||||||
|
'''Page which displays a list of all the person aliases in a specific year
|
||||||
|
'''
|
||||||
|
if not year:
|
||||||
|
year = 1998
|
||||||
|
expo = Expedition.objects.filter(year=year)[0] # returns a set, even though we know there is only one
|
||||||
|
personexpeditions = PersonExpedition.objects.filter(expedition=expo)
|
||||||
|
persons = Person.objects.all()
|
||||||
|
|
||||||
|
aliasdict = GetPersonExpeditionNameLookup(expo)
|
||||||
|
|
||||||
|
return render(request,'aliases.html', {'year': year, 'aliasdict': aliasdict,'personexpeditions': personexpeditions, 'persons': persons})
|
||||||
|
@ -112,7 +112,7 @@ def load_people_expos():
|
|||||||
vfho = True
|
vfho = True
|
||||||
|
|
||||||
lookupAttribs={'first_name':firstname, 'last_name':(lastname or "")}
|
lookupAttribs={'first_name':firstname, 'last_name':(lastname or "")}
|
||||||
nonLookupAttribs={'is_vfho':vfho, 'fullname':fullname}
|
nonLookupAttribs={'is_vfho':vfho, 'fullname':fullname, 'nickname':nickname}
|
||||||
person, created = save_carefully(Person, lookupAttribs, nonLookupAttribs)
|
person, created = save_carefully(Person, lookupAttribs, nonLookupAttribs)
|
||||||
|
|
||||||
parse_blurb(personline=personline, header=header, person=person)
|
parse_blurb(personline=personline, header=header, person=person)
|
||||||
@ -131,6 +131,14 @@ def load_people_expos():
|
|||||||
# expedition name lookup cached for speed (it's a very big list)
|
# expedition name lookup cached for speed (it's a very big list)
|
||||||
# should have a LIST of nicknames, just populate the first entry from folk.csv
|
# should have a LIST of nicknames, just populate the first entry from folk.csv
|
||||||
|
|
||||||
|
def who_is_this(year,possibleid):
|
||||||
|
expo = Expedition.objects.filter(year=year)
|
||||||
|
personexpedition = GetPersonExpeditionNameLookup(expo)[possibleid.lower()]
|
||||||
|
if personexpedition:
|
||||||
|
return personexpedition.person
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
# Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition
|
# Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition
|
||||||
# This is convoluted, the whole personexpedition concept is unnecessary.
|
# This is convoluted, the whole personexpedition concept is unnecessary.
|
||||||
|
|
||||||
@ -161,6 +169,19 @@ def GetPersonExpeditionNameLookup(expedition):
|
|||||||
possnames.append(f[0] + l[0]) # initials e.g. gb or bl
|
possnames.append(f[0] + l[0]) # initials e.g. gb or bl
|
||||||
possnames.append(f)
|
possnames.append(f)
|
||||||
|
|
||||||
|
# But these aliases do not take advantage of the variations above
|
||||||
|
if f'{f} {l}' == "Phil Underwood":
|
||||||
|
possnames.append("Phil Underpants")
|
||||||
|
if f'{f} {l}' == "Naomi Griffiths":
|
||||||
|
possnames.append("Naomi Makin")
|
||||||
|
if f'{f} {l}' == "Cat Hulse":
|
||||||
|
possnames.append("Catherine Hulse")
|
||||||
|
possnames.append("Cat Henry")
|
||||||
|
if f'{f} {l}' == "Jess Stirrups":
|
||||||
|
possnames.append("Jessica Stirrups")
|
||||||
|
if f'{f} {l}' == "Nat Dalton":
|
||||||
|
possnames.append("Nathaniel Dalton")
|
||||||
|
|
||||||
lim = min(4, len(f)+1) # short form, e.g. Dan for Daniel. May be duplicate, e.g. several Dave
|
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:
|
if f[:lim] not in short:
|
||||||
short[f[:lim]]= personexpedition
|
short[f[:lim]]= personexpedition
|
||||||
@ -173,12 +194,13 @@ def GetPersonExpeditionNameLookup(expedition):
|
|||||||
if l:
|
if l:
|
||||||
# This allows for nickname to be used for short name
|
# This allows for nickname to be used for short name
|
||||||
# eg Phil S is adding Phil Sargent to the list
|
# eg Phil S is adding Phil Sargent to the list
|
||||||
if str(personexpedition.nickname.lower() + " " + l) not in possnames:
|
n = personexpedition.nickname.lower()
|
||||||
possnames.append(personexpedition.nickname.lower() + " " + l)
|
if str(n + " " + l) not in possnames:
|
||||||
if str(personexpedition.nickname.lower() + " " + l[0]) not in possnames:
|
possnames.append(n + " " + l)
|
||||||
possnames.append(personexpedition.nickname.lower() + " " + l[0])
|
if str(n + " " + l[0]) not in possnames:
|
||||||
if str(personexpedition.nickname.lower() + l[0]) not in possnames:
|
possnames.append(n + " " + l[0])
|
||||||
possnames.append(personexpedition.nickname.lower() + l[0])
|
if str(n + l[0]) not in possnames:
|
||||||
|
possnames.append(n + l[0])
|
||||||
|
|
||||||
for possname in possnames:
|
for possname in possnames:
|
||||||
if possname in res:
|
if possname in res:
|
||||||
@ -195,6 +217,10 @@ def GetPersonExpeditionNameLookup(expedition):
|
|||||||
for shortname in short:
|
for shortname in short:
|
||||||
res[shortname] = short[shortname]
|
res[shortname] = short[shortname]
|
||||||
|
|
||||||
|
print(f'{expedition.name}', end= ' ')
|
||||||
|
for n in res:
|
||||||
|
print(f'{n},', end= ' ')
|
||||||
|
print('')
|
||||||
Gpersonexpeditionnamelookup[expedition.name] = res
|
Gpersonexpeditionnamelookup[expedition.name] = res
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
47
templates/aliases.html
Normal file
47
templates/aliases.html
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}Cave Entrances and other locations in UTM{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1>Aliases for people's names in {{year}}</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr><th>Person</th><th>slug</th><th>aliases</th></tr>
|
||||||
|
{% for pe in personexpeditions %}
|
||||||
|
<tr>
|
||||||
|
<td>{{pe.person}}</td>
|
||||||
|
<td>{{pe.slugfield}}</td>
|
||||||
|
<td>{{pe.slugfield}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr><th>alias</th><th>who</th></tr>
|
||||||
|
{% for key, value in aliasdict.items %}
|
||||||
|
<tr>
|
||||||
|
<td>'{{key}}'</td>
|
||||||
|
<td>{{value}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<p>The aliases below are specified in the folk.csv file. Only one alias is possible in that format.
|
||||||
|
<table>
|
||||||
|
<tr><th>First</th><th>Last</th><th>Full name</th><th>Nickname</th><th>expo first</th><th>expo last</th></tr>
|
||||||
|
{% for p in persons %}
|
||||||
|
<tr>
|
||||||
|
<td><b>{{p.first_name}}</b></td>
|
||||||
|
<td><b>{{p.last_name}}</b></td>
|
||||||
|
|
||||||
|
<td>{{p.fullname}}</td>
|
||||||
|
<td>{{p.nickname}}</td>
|
||||||
|
<td>{{p.first.expedition}}</td>
|
||||||
|
<td>{{p.last.expedition}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
11
urls.py
11
urls.py
@ -145,11 +145,12 @@ trogglepatterns = [
|
|||||||
|
|
||||||
|
|
||||||
# System admin and monitoring
|
# System admin and monitoring
|
||||||
path('statistics', statistics.stats, name="stats"),
|
path('statistics', statistics.stats, name="stats"),
|
||||||
path('stats', statistics.stats, name="stats"),
|
path('stats', statistics.stats, name="stats"),
|
||||||
path('pathsreport', statistics.pathsreport, name="pathsreport"),
|
path('pathsreport', statistics.pathsreport, name="pathsreport"),
|
||||||
path('dataissues', statistics.dataissues, name="dataissues"),
|
path('dataissues', statistics.dataissues, name="dataissues"),
|
||||||
path('eastings', statistics.eastings, name="eastings"),
|
path('eastings', statistics.eastings, name="eastings"),
|
||||||
|
path('aliases/<int:year>',statistics.aliases, name="aliases"),
|
||||||
|
|
||||||
path('troggle', frontpage, name="frontpage"), # control panel. Shows recent actions.
|
path('troggle', frontpage, name="frontpage"), # control panel. Shows recent actions.
|
||||||
path('todo/<path:module>', todos, name="todos"),
|
path('todo/<path:module>', todos, name="todos"),
|
||||||
|
Loading…
Reference in New Issue
Block a user