diff --git a/core/views/survex.py b/core/views/survex.py index 0255559..9507795 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -296,6 +296,7 @@ def svx(request, survex_file): svxincludes = re.findall(r"(?i)\*include\s+(\S+)", form.data["code"] or "") svxfile = form.survexfile # only valid once form.GetDiscCode() called + print(f"{svxfile=}") try: svxblocksall = svxfile.survexblock_set.all() except AttributeError: # some survexfiles just *include files and have no blocks themselves @@ -304,13 +305,14 @@ def svx(request, survex_file): for b in svxblocksall: if b.date: svxblocks.append(b) - print(f"{svxfile=} {svxblocks}") + print(f"- {b}") # collect all the stuff that happens on the same dates as the survex blocks dates = set() for b in svxblocks: dates.add(b.date) + print(f"- {b.date}") events = events_on_dates(dates) vmap = { @@ -323,6 +325,7 @@ def svx(request, survex_file): "difflist": difflist, "logmessage": logmessage, "form": form, + "events": events, } # vmap.update(csrf(request)) # this now refreshes to the wrong value, now that we user render(request, @@ -337,7 +340,6 @@ def events_on_dates(dates): """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. """ - print(dates) events = {} for d in dates: trips = LogbookEntry.objects.filter(date=d) @@ -350,6 +352,7 @@ def events_on_dates(dates): refwallets = allwallets.filter(survexblock__date=d) events[d] = SameDateEvents(trips=trips, svxfiles=svxfiles, wallets=refwallets) + print(events) return events # The cavern running function. This is NOT where it is run inside the form! see SvxForm.Process() for that diff --git a/templates/svxfile.html b/templates/svxfile.html index 7241f09..5d493f8 100644 --- a/templates/svxfile.html +++ b/templates/svxfile.html @@ -82,16 +82,20 @@ LOGMESSAGES </div> <span style="font-family: monospace; font-size: 130%; "> {% for sb in svxblocks %} -<details {% if forloop.first %} open{% endif %}> -<summary><b><a href="/expedition/{{sb.date|date:"Y"}}">{{sb.date|date:"Y"}}</a>{{sb.date|date:"-m-d"}}</b> {{sb.title}} '{{sb.name}}'</summary> -List of Logbook entries, wallets and other survex files on {{sb.date|date:"Y-m-d"}}. -<br /> -[Work in progress, Feb. 2023...]<br /> - {% include 'onthisdate.html' %} -</details> {% empty %} -Cannot find any survex blocks in this survex file. <br /> +Cannot find any survex blocks in this survex file (not looking at *include files). <br /> Report this to a nerd if you think this is incorrect. +<hr /> +{% endfor %} + +{% for key, value in events.items %} +<details {% if forloop.first %} open{% endif %}> +<summary><b><a href="/expedition/{{key|date:"Y"}}">{{key|date:"Y"}}</a>{{key|date:"-m-d"}}</b> </summary> +<br /> +{% with trips=value.0 svxfiles=value.1 wallets=value.2 %} + {% include 'onthisdate.html' %} +{% endwith %} +</details> {% endfor %} </span> {% endblock %}