fix author display for logbook entry

This commit is contained in:
Philip Sargent 2022-12-18 21:20:30 +00:00
parent 8ce86aabee
commit f1d5df9933
2 changed files with 8 additions and 59 deletions

View File

@ -59,21 +59,11 @@ BLOG_PARSER_SETTINGS = {
} }
DEFAULT_LOGBOOK_FILE = "logbook.html" DEFAULT_LOGBOOK_FILE = "logbook.html"
DEFAULT_LOGBOOK_PARSER = "parser_html" DEFAULT_LOGBOOK_PARSER = "parser_html"
# All years since 2010 use the default value for Logbook parser # All years since 2002 use the default value for Logbook parser
LOGBOOK_PARSER_SETTINGS = { LOGBOOK_PARSER_SETTINGS = {
"2019": ("logbook.html", "parser_html"),
"2010": ("logbook.html", "parser_html"),
# "2009": ("2009logbook.txt", "wiki_parser"), # converted to html # "2009": ("2009logbook.txt", "wiki_parser"), # converted to html
# "2008": ("2008logbook.txt", "wiki_parser"), # converted to html # "2008": ("2008logbook.txt", "wiki_parser"), # converted to html
"2009": ("logbook.html", "parser_html"),
"2008": ("logbook.html", "parser_html"),
"2007": ("logbook.html", "parser_html"),
"2006": ("logbook.html", "parser_html"),
# "2006": ("logbook/logbook_06.txt", "wiki_parser"), # converted to html # "2006": ("logbook/logbook_06.txt", "wiki_parser"), # converted to html
"2006": ("logbook.html", "parser_html"),
"2005": ("logbook.html", "parser_html"),
"2004": ("logbook.html", "parser_html"),
"2003": ("logbook.html", "parser_html"),
"2002": ("logbook.html", "parser_html"), "2002": ("logbook.html", "parser_html"),
"2001": ("log.htm", "parser_html_01"), "2001": ("log.htm", "parser_html_01"),
"2000": ("log.htm", "parser_html_01"), "2000": ("log.htm", "parser_html_01"),
@ -136,6 +126,7 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
if tripperson and tripperson[0] != '*': if tripperson and tripperson[0] != '*':
tripperson = re.sub(rx_round_bracket, "", tripperson).strip() tripperson = re.sub(rx_round_bracket, "", tripperson).strip()
# these aliases should be moved to people.py GetPersonExpeditionNameLookup(expedition)
if tripperson =="Wiggy": if tripperson =="Wiggy":
tripperson = "Phil Wigglesworth" tripperson = "Phil Wigglesworth"
if tripperson =="Animal": if tripperson =="Animal":
@ -148,6 +139,8 @@ def GetTripPersons(trippeople, expedition, logtime_underground, tid=None):
tripperson = "Rob Watson" tripperson = "Rob Watson"
if tripperson =="Tinywoman": if tripperson =="Tinywoman":
tripperson = "Nadia" tripperson = "Nadia"
if tripperson =="tcacrossley":
tripperson = "Tom Crossley"
personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower()) personyear = GetPersonExpeditionNameLookup(expedition).get(tripperson.lower())
@ -297,51 +290,6 @@ def ParseDate(tripdate, year):
logdataissues["tripdate"]=message logdataissues["tripdate"]=message
return datetime.date(1970, 1, 1) return datetime.date(1970, 1, 1)
# # (2006 - not any more), 2008 - 2009
# def wiki_parser(year, expedition, txt, seq=""):
# global logentries
# global logdataissues
# logbook_entry_count = 0
# trippara = re.findall(r"===(.*?)===([\s\S]*?)(?====)", txt)
# for triphead, triptext in trippara:
# logbook_entry_count += 1
# tid = set_trip_id(year,logbook_entry_count)
# tripheadp = triphead.split("|")
# if not (len(tripheadp) == 3):
# message = " ! - Bad no of items in tripdate in logbook: " + tripdate + " - " + tripheadp
# DataIssue.objects.create(parser='logbooks', message=message)
# logdataissues["tripdate"]=message
# tripdate, tripplace, trippeople = tripheadp
# tripsplace = tripplace.split(" - ")
# tripcave = tripsplace[0].strip()
# if len(tripsplace) == 1:
# tripsplace = tripsplace[0]
# else:
# tripsplace = tripsplace[1]
# #tul = re.findall(r"T/?U:?\s*(\d+(?:\.\d*)?|unknown)\s*(hrs|hours)?", triptext)
# tul = re.findall(r"T/U:?\s*(\d+[.]?\d*)\s*(hr|hrs|hours)?.*", triptext)
# if tul:
# tu = tul[0][0]
# else:
# tu = ""
# print(f"! LOGBOOK {year} {logbook_entry_count:2} {len(triptext):4} T/U:{tu} '{tripcave} - {tripsplace}' ")
# ldate = ParseDate(tripdate.strip(), year)
# tripid = set_trip_id(year,logbook_entry_count)
# ltriptext = re.sub(r"\n", "<br /><br />\n", triptext)
# ltriptext = ltriptext.replace("<br /><br />\n<br /><br />\n","<br /><br />\n")
# triptitle = f'{tripcave} - {tripsplace}'
# entrytuple = (ldate, tripcave, triptitle, ltriptext,
# trippeople, expedition, tu, tripid)
# logentries.append(entrytuple)
# 2002, 2004 - now # 2002, 2004 - now
def parser_html(year, expedition, txt, seq=""): def parser_html(year, expedition, txt, seq=""):
global logentries global logentries

View File

@ -13,7 +13,7 @@
</p> </p>
{% if logbookentry.cave %} {% if logbookentry.cave %}
<p>place: <a href="{{ logbookentry.cave.get_absolute_url }}">{{logbookentry.place}}</p> <p>place: <a href="{{ logbookentry.cave.get_absolute_url }}">{{logbookentry.place|safe}}</p>
{% else %} {% else %}
<p>{{logbookentry.place|safe}}</p> <p>{{logbookentry.place|safe}}</p>
{% endif %} {% endif %}
@ -31,7 +31,7 @@
<tr><th>Caver</th><th>T/U</th><th>Prev</th><th>Next</th></tr> <tr><th>Caver</th><th>T/U</th><th>Prev</th><th>Next</th></tr>
{% for persontrip in logbookentry.persontrip_set.all %} {% for persontrip in logbookentry.persontrip_set.all %}
<tr> <tr>
{% if persontrip.personexpedition == logbookentry.author %} {% if persontrip.is_logbook_entry_author %}
<td class="author"> <td class="author">
{% else %} {% else %}
<td> <td>
@ -64,6 +64,7 @@
<div id="col1"> <div id="col1">
<div class="logbookentry"> <div class="logbookentry">
<b>{{logbookentry.date|date:"D d M Y"}}</b> <b>{{logbookentry.date|date:"D d M Y"}}</b>
{% for persontrip in logbookentry.persontrip_set.all %}{% if persontrip.is_logbook_entry_author %}<br />{{persontrip.personexpedition.person}}{% endif %}{% endfor %}
<p>{{logbookentry.text|safe}}</p> <p>{{logbookentry.text|safe}}</p>
</div> </div>
</div> </div>