From c5b08ce80f6ea17556bbc45844706c94a9b542e9 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 15 Jan 2025 20:21:49 +0000 Subject: [PATCH] stumbled on bug when no entries in logbook, fixed. --- core/models/logbooks.py | 14 +++++---- parsers/logbooks.py | 65 ++++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/core/models/logbooks.py b/core/models/logbooks.py index 8c8edbc..fd6bbfe 100644 --- a/core/models/logbooks.py +++ b/core/models/logbooks.py @@ -57,14 +57,16 @@ class LogbookEntry(TroggleModel):
{% for personlogentry in logbook_entry.personlogentry_set.all %}{% if personlogentry.is_logbook_entry_author %}{% if personlogentry.nickname_used %}{{personlogentry.nickname_used|safe}}{% else %}{{personlogentry.personexpedition.person|safe}}{% endif %},{% endif %}{% endfor %}{% for personlogentry in logbook_entry.personlogentry_set.all %}{% if personlogentry.is_logbook_entry_author %}{% else %}{% if personlogentry.nickname_used %}{{personlogentry.nickname_used|safe}}{% else %}{{personlogentry.personexpedition.person|safe}}{% endif %},{% endif %}{% endfor %}{% if logbook_entry.other_people %}, {{logbook_entry.other_people}}{% endif %}
''' - author = ( + if author := ( PersonLogEntry.objects.filter(logbook_entry=self, is_logbook_entry_author=True) .first() - ) - if author.nickname_used: - expoer = author.nickname_used + ): + if author.nickname_used: + expoer = author.nickname_used + else: + expoer = author.personexpedition.person.name() else: - expoer = author.personexpedition.person.name() + expoer = "nobody" names = f"{expoer}" participants = ( @@ -119,7 +121,7 @@ def writelogbook(year, filename): t = loader.get_template("logbook2005style.html") logbookfile = t.render({"logbook_entries": logbook_entries}) except: - print(" ! Very Bad Error RENDERING template " + template) + print(" ! Very Bad Error RENDERING template ", t) raise # print(" - template rendered") try: diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 3d96b3b..08e2710 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -58,6 +58,11 @@ LOGBOOK_PARSER_SETTINGS = { LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB ENTRIES = { + "2029": 0, + "2028": 0, + "2027": 0, + "2026": 0, + "2025": 0, "2024": 125, "2023": 131, "2022": 94, @@ -379,8 +384,10 @@ def parser_html(year, expedition, txt, seq=""): dupl = {} # extract front material and stash for later use when rebuilding from list of entries - headmatch = re.match(r"(?i)(?s).*]*>(.*?)]*>(.*?) 0: frontpath = Path(settings.EXPOWEB, LOGBOOKS_DIR, year, "frontmatter.html") @@ -390,8 +397,10 @@ def parser_html(year, expedition, txt, seq=""): front.write(headpara + "\n") # extract END material and stash for later use when rebuilding from list of entries - endmatch = re.match(r"(?i)(?s).*([\s\S]*?)(?=([\s\S]*?)(?= 0: print(f"\n - {year} endpara:\n'{endpara}'") @@ -399,7 +408,10 @@ def parser_html(year, expedition, txt, seq=""): with open(endpath, "w") as end: end.write(endpara + "\n") - tripparas = re.findall(r"([\s\S]*?)(?=([\s\S]*?)(?=