From fe28d9ba391efb72afe8e92e2754d32a361f1212 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 27 Sep 2022 23:59:25 +0300 Subject: [PATCH] Add survex files,wallets and same-day LBEs to the logbook entry --- core/views/logbooks.py | 24 +++++++++++++++++-- templates/logbookentry.html | 46 ++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 7f26687..f24653c 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -15,7 +15,7 @@ from django.views.generic.list import ListView from troggle.core.models.troggle import Expedition, Person, PersonExpedition from troggle.core.utils import TROG from troggle.core.models.caves import LogbookEntry, PersonTrip -from troggle.core.models.survex import SurvexBlock +from troggle.core.models.survex import SurvexBlock, Wallet from .auth import login_required_if_public from troggle.parsers.logbooks import LoadLogbookForExpedition from troggle.parsers.people import GetPersonExpeditionNameLookup @@ -192,8 +192,28 @@ def logbookentry(request, date, slug): if len(this_logbookentry)>1: return render(request, 'object_list.html',{'object_list':this_logbookentry}) else: + trips = LogbookEntry.objects.filter(date=date) + wallets = set() + refwallets = Wallet.objects.filter(survexblock__date=date) + for r in refwallets: + wallets.add(r) + + allwallets = Wallet.objects.all() + # Note that w.year() only works for wallets which have a valid JSON file existing + for w in allwallets: + if w.date() == date: + wallets.add(w) + + thisexpo = this_expedition = Expedition.objects.get(year=int(date[0:4])) + if thisexpo: + expeditionday = thisexpo.get_expedition_day(date) + svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday) + else: + svxothers = None + this_logbookentry=this_logbookentry[0] - return render(request, 'logbookentry.html', {'logbookentry': this_logbookentry}) + return render(request, 'logbookentry.html', + {'logbookentry': this_logbookentry, 'trips': trips, 'svxothers': svxothers, 'wallets': wallets}) else: msg =(f' Logbook entry slug:"{slug}" not found in database on date:"{date}" ') print(msg) diff --git a/templates/logbookentry.html b/templates/logbookentry.html index 95854b4..d8a4817 100644 --- a/templates/logbookentry.html +++ b/templates/logbookentry.html @@ -59,9 +59,6 @@ {% endfor %} -{% if newQMlink %} -Add QM found on this trip -{% endif %}
@@ -72,4 +69,47 @@
+ + + {% if svxothers %}Survex files on this date:
+ + {% for item in svxothers %} + {% if item.isSurvexBlock %}    {{item.survexfile.path|safe}}
{% endif %} + {% empty %} + None found for this date.
+ {% endfor %} +
+ {% else %} + No survex files found for this date.
+ {% endif %} + {% if wallets %}Wallets on this date:
+ + {% for item in wallets %} +     {{item.walletname|safe}} + {% if item.name %} + {{item.name|safe}}
+ {% else %} + {{item.get_fnames|safe}} +
+ {% endif %} + {% empty %} + None found for this date.
+ {% endfor %} +
+ {% else %} + No wallets files found for this date.
+ {% endif %} + {% if trips %}All logbook trips on this date:
+ + {% for item in trips %} + {% if item.isLogbookEntry %}    {{item.title|safe}}
{% endif %} + {% empty %} + None found for this date, but there should be..
+ {% endfor %} +
+ {% else %} + Hmm...
+ {% endif %} + +
{% endblock %}