mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
get events on same date.progress.
This commit is contained in:
parent
6de4fa66a2
commit
6387de038b
@ -193,7 +193,7 @@ def walletslistyear(request, year):
|
||||
|
||||
year = str(year)
|
||||
manywallets = ticksyearwallet(year)
|
||||
expeditions = Expedition.objects.all()
|
||||
expeditions = Expedition.objects.all() #bad Django style
|
||||
expedition = expeditions.filter(year=year)
|
||||
print("--")
|
||||
return render(
|
||||
|
@ -4,6 +4,7 @@ import os
|
||||
import re
|
||||
import socket
|
||||
from pathlib import Path
|
||||
from collections import namedtuple
|
||||
|
||||
from django import forms
|
||||
from django.db import models
|
||||
@ -14,8 +15,10 @@ from django.shortcuts import render
|
||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||
|
||||
import troggle.settings as settings
|
||||
from troggle.core.models.logbooks import LogbookEntry
|
||||
from troggle.core.models.caves import Cave
|
||||
from troggle.core.models.survex import SurvexFile, SurvexBlock
|
||||
from troggle.core.models.wallets import Wallet
|
||||
from troggle.core.utils import only_commit
|
||||
|
||||
"""Everything that views survexfiles
|
||||
@ -303,6 +306,12 @@ def svx(request, survex_file):
|
||||
svxblocks.append(b)
|
||||
print(f"{svxfile=} {svxblocks}")
|
||||
|
||||
# collect all the stuff that happens on the same dates as the survex blocks
|
||||
|
||||
dates = set()
|
||||
for b in svxblocks:
|
||||
dates.add(b.date)
|
||||
events = events_on_dates(dates)
|
||||
|
||||
vmap = {
|
||||
"settings": settings,
|
||||
@ -322,6 +331,26 @@ def svx(request, survex_file):
|
||||
|
||||
return render(request, "svxfile.html", vmap)
|
||||
|
||||
SameDateEvents = namedtuple('SameDateEvents', ['trips', 'svxfiles', 'wallets'])
|
||||
|
||||
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)
|
||||
|
||||
svxfiles = False
|
||||
|
||||
# Wallets needs to get those identified only from JSON too,
|
||||
# see logbookeentry() in views/logbooks.py
|
||||
allwallets = Wallet.objects.all()
|
||||
refwallets = allwallets.filter(survexblock__date=d)
|
||||
|
||||
events[d] = SameDateEvents(trips=trips, svxfiles=svxfiles, wallets=refwallets)
|
||||
return events
|
||||
|
||||
# The cavern running function. This is NOT where it is run inside the form! see SvxForm.Process() for that
|
||||
def process(survex_file):
|
||||
|
@ -12,7 +12,8 @@ Total length: {{addupsurvexlength|stringformat:".1f"}} km adding up the total fo
|
||||
|
||||
<p>These are uncorrected tape lengths which include pitches and duplicates but exclude splays or surface-surveys.
|
||||
<p>
|
||||
This is work in progress (April 2022).
|
||||
This is work in progress (Feb.2023).
|
||||
<p>This includes ARGE and other surveys currently. It will be changed to only include lengths surveyed by valid Expo-attendees.
|
||||
|
||||
<table>
|
||||
<tr><th>Year</th><th>Survex<br>Survey<br>Blocks</th><th>Survex<br>Survey Legs</th><th>Total length<br>(m)</th></tr>
|
||||
|
@ -82,7 +82,8 @@ LOGMESSAGES
|
||||
</div>
|
||||
<span style="font-family: monospace; font-size: 130%; ">
|
||||
{% for sb in svxblocks %}
|
||||
<details {% if forloop.first %} open{% endif %}><summary><b>{{sb.date|date:"Y-m-d"}}</b> {{sb.title}} '{{sb.name}}'</summary>
|
||||
<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 />
|
||||
|
Loading…
Reference in New Issue
Block a user