From a0ef426cdbb5da3e6d005d03e5caaa88f1c6cf7c Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 15 Mar 2024 16:37:30 +0000 Subject: [PATCH] fix year in menu for older survexfiles --- core/views/survex.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/core/views/survex.py b/core/views/survex.py index b24b51b..c51a2c5 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -387,9 +387,9 @@ def svx(request, survex_file): events = events_on_dates(svxblocks) - + year = year_for_svx(svxblocks) vmap = { - "year": current_expo(), + "year": year, "settings": settings, "warning": warning, "has_3d": has_3d, @@ -411,6 +411,16 @@ def svx(request, survex_file): SameDateEvents = namedtuple('SameDateEvents', ['trips', 'svxfiles', 'wallets', 'blocks']) +def year_for_svx(svxblocks): + y = settings.EPOCH + for b in svxblocks: + if b.date: + if b.date > y: + y = b.date + return str(y.year) + + + def events_on_dates(svxblocks): """Returns a dictionary of indexed by date. For each date there is a named tuple of 3 lists: logbookentries, survexfiles (NB files, not blocks), and wallets.