From 76fe0c0379bdeda00441603609e24b83f00a67d3 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 22 Nov 2025 11:46:21 +0200 Subject: [PATCH] got author OK --- core/views/logbooks.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/views/logbooks.py b/core/views/logbooks.py index d639dab..c43519f 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -416,21 +416,29 @@ def write_entries(entries, year, editor): print(f"CANNOT write this file {filepath}. Exception dumping json. Ask a nerd to fix this: {e}") raise e - def serialize_logentry(): + def serialize_logentry(le): # REPLACE this with hand-built serializer which includes .author, .who which were added to the entries but re not in the model Class directly # see below for Gemini code to do that. Going to bed now. + + author_link = PersonLogEntry.objects.select_related('personexpedition').get( + logbook_entry=le, + is_logbook_entry_author=True # Adjust filter based on your logic + ) + author = author_link.personexpedition.person + print(author) + jsondict = serialize("json", [le], fields=('slug', 'date', 'expedition', 'title', 'cave', 'place', 'other_people', 'time_underground', 'text')) return jsondict dirpath = settings.EXPOWEB / "years" / year / LOGBOOK_ENTRIES - for le in entries: + for le in entries[:4]: filename = f"{le.slug}-{le.pk:03}.json" filepath = dirpath / filename # description = f" {le.slug} :: {le.date} - {le.title}" ensure_dir_exists(filepath) - jsondict = serialize_logentry() + jsondict = serialize_logentry(le) write_json_file() git_add(filename, dirpath) @@ -438,9 +446,6 @@ def write_entries(entries, year, editor): git_commit(dirpath, commit_msg, editor) return True - # Gemini has the answer, get what I need from this: - - def export_entry_with_author_details(request, entry_id): try: