summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-02-27 19:14:08 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2023-02-27 19:14:08 +0000
commit154722f765d99c014ddd43f8cbce47799bdc3cce (patch)
tree00359e6228e5e0e920b328f52b206a5c177ebdf1
parent6387de038ba063e96d4cadc26d28fda1c0423720 (diff)
downloadtroggle-154722f765d99c014ddd43f8cbce47799bdc3cce.tar.gz
troggle-154722f765d99c014ddd43f8cbce47799bdc3cce.tar.bz2
troggle-154722f765d99c014ddd43f8cbce47799bdc3cce.zip
logbook trips, and some wallets working.
-rw-r--r--core/views/survex.py7
-rw-r--r--templates/svxfile.html18
2 files changed, 16 insertions, 9 deletions
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 %}
+{% empty %}
+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/{{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"}}.
+<summary><b><a href="/expedition/{{key|date:"Y"}}">{{key|date:"Y"}}</a>{{key|date:"-m-d"}}</b> </summary>
<br />
-[Work in progress, Feb. 2023...]<br />
- {% include 'onthisdate.html' %}
+{% with trips=value.0 svxfiles=value.1 wallets=value.2 %}
+ {% include 'onthisdate.html' %}
+{% endwith %}
</details>
-{% empty %}
-Cannot find any survex blocks in this survex file. <br />
-Report this to a nerd if you think this is incorrect.
{% endfor %}
</span>
{% endblock %}