mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 23:01:52 +00:00
New log report by title
This commit is contained in:
parent
f4c25ba163
commit
35b04d096e
@ -218,6 +218,61 @@ def personexpedition(request, slug="", year=""):
|
|||||||
print(msg)
|
print(msg)
|
||||||
return render(request, "errors/generic.html", {"message": msg})
|
return render(request, "errors/generic.html", {"message": msg})
|
||||||
|
|
||||||
|
def logreport(request, year=1999):
|
||||||
|
"""
|
||||||
|
Remember that 'personexpedition__expedition' is interpreted by Django to mean the
|
||||||
|
'expedition' object which is connected by a foreign key to the 'personexpedition'
|
||||||
|
object, which is a field of the PersonLogEntry object:
|
||||||
|
PersonLogEntry.objects.filter(personexpedition__expedition=expo)
|
||||||
|
|
||||||
|
"""
|
||||||
|
print(f"logreport(): begun")
|
||||||
|
|
||||||
|
expeditions = Expedition.objects.all() # top menu only, evaluated only when template renders
|
||||||
|
dates = None
|
||||||
|
dateditems = None
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
expo = Expedition.objects.get(year=int(year))
|
||||||
|
except:
|
||||||
|
message = (
|
||||||
|
"Expedition not found - database apparently empty, you probably need to do a full re-import of all data."
|
||||||
|
)
|
||||||
|
return render(request, "errors/generic.html", {"message": message})
|
||||||
|
|
||||||
|
entries = expo.logbookentry_set.all() # lazy list
|
||||||
|
dateditems = list(entries) # evaluates the Django query and hits db
|
||||||
|
dates = sorted(set([item.date for item in dateditems]))
|
||||||
|
|
||||||
|
try:
|
||||||
|
for entry in dateditems:
|
||||||
|
|
||||||
|
people = PersonLogEntry.objects.filter(logbook_entry=entry)
|
||||||
|
entry.who = []
|
||||||
|
for p in people:
|
||||||
|
if p.is_logbook_entry_author:
|
||||||
|
entry.author = p
|
||||||
|
else:
|
||||||
|
entry.who.append(p)
|
||||||
|
|
||||||
|
|
||||||
|
print(f"logreport(): trying..")
|
||||||
|
context = {
|
||||||
|
"year": year,
|
||||||
|
"expedition": expo,
|
||||||
|
"expeditions": expeditions,
|
||||||
|
"settings": settings,
|
||||||
|
"dateditems": dateditems,
|
||||||
|
"dates": dates,
|
||||||
|
}
|
||||||
|
print(f"logreport(): rendering..")
|
||||||
|
return render(request, "logreport.html", context)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
msg = f' Logbook report for year:"{year}" not implemented yet\n{e}\n {context}'
|
||||||
|
print(msg)
|
||||||
|
return render(request, "errors/generic.html", {"message": msg})
|
||||||
|
|
||||||
def logbookentry(request, date, slug):
|
def logbookentry(request, date, slug):
|
||||||
# start = time.time()
|
# start = time.time()
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
<li> <a href="/wallets/year/{{expedition.year}}">wallet completion status</a> for this Expo
|
<li> <a href="/wallets/year/{{expedition.year}}">wallet completion status</a> for this Expo
|
||||||
<li> <a href="/aliases/{{expedition.year}}">alias names</a> for this Expo
|
<li> <a href="/aliases/{{expedition.year}}">alias names</a> for this Expo
|
||||||
<li> <a href="/years/{{expedition.year}}/{{expedition.logbookfile}}">full logbook</a> for this Expo
|
<li> <a href="/years/{{expedition.year}}/{{expedition.logbookfile}}">full logbook</a> for this Expo
|
||||||
|
<li> <a href="/logreport/{{expedition.year}}">logbook report</a> for this Expo
|
||||||
<li> <a href="/logbookedit/">new logbook entry</a> for this Expo
|
<li> <a href="/logbookedit/">new logbook entry</a> for this Expo
|
||||||
{% if logged_in %}
|
{% if logged_in %}
|
||||||
<p>Reparse and reload this year's logbook by clicking here: <a href="/expedition/{{expedition.year}}?reload">RELOAD</a>
|
<p>Reparse and reload this year's logbook by clicking here: <a href="/expedition/{{expedition.year}}?reload">RELOAD</a>
|
||||||
|
72
templates/logreport.html
Normal file
72
templates/logreport.html
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block title %}Log Report {{year}} for {{expedition.name}}{% endblock %}
|
||||||
|
{% block related %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<!-- templates/logreport.html - this text visible because this template has been included -->
|
||||||
|
|
||||||
|
<h2>Logbook report for {{expedition.name}}</h2>
|
||||||
|
|
||||||
|
<p><b>Other years:</b>
|
||||||
|
{% for otherexpedition in expeditions %}
|
||||||
|
{% if otherexpedition == expedition %}
|
||||||
|
| <b>{{otherexpedition.year}}</b>
|
||||||
|
{% else %}
|
||||||
|
| <a href="/logreport/{{otherexpedition.year}}">{{ otherexpedition.year }}</a>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h3 id="trips"> {{expedition.name}} - Logbook entries per day</h3>
|
||||||
|
|
||||||
|
<table class="expeditionlogbooks">
|
||||||
|
<tr><th>Date</th><th>Logged trips and diary entries</th><th>Cave</th><th>Text..</th><th>Author</th><th>Who else</th></tr>
|
||||||
|
{% regroup dateditems|dictsort:"date" by date as dates %}
|
||||||
|
{% for date in dates %}
|
||||||
|
{% for entry in date.list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{date.grouper|date:"D d M Y"}}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ entry.get_absolute_url }}">{{entry.title|truncatechars:30|safe|striptags}}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if entry.cave %}
|
||||||
|
<a href="/{{ entry.cave.url }}">{{entry.cave|safe}}</a><br/>
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{entry.text|striptags|safe|truncatechars:30}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="/personexpedition/{{entry.author.personexpedition.person}}/{{year}}">{{entry.author.nickname_used}}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if entry.who %}
|
||||||
|
{% for w in entry.who %}
|
||||||
|
<a href="/personexpedition/{{w.personexpedition.person}}/{{year}}">{{w.nickname_used}}</a>,
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<p>See also the
|
||||||
|
<ul>
|
||||||
|
<li> <a href="/expedition/{{expedition.year}}">full calendar page</a> for this Expo (slow page)
|
||||||
|
<li> <a href="/years/{{expedition.year}}/">documentation index</a> for this Expo
|
||||||
|
<li> <a href="/wallets/year/{{expedition.year}}">wallet completion status</a> for this Expo
|
||||||
|
<li> <a href="/aliases/{{expedition.year}}">alias names</a> for this Expo
|
||||||
|
<li> <a href="/years/{{expedition.year}}/{{expedition.logbookfile}}">full logbook</a> for this Expo
|
||||||
|
<li> <a href="/logbookedit/">new logbook entry</a> for this Expo
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3> {{expedition.name}} </h3>
|
||||||
|
{% endblock %}
|
3
urls.py
3
urls.py
@ -15,7 +15,7 @@ from troggle.core.views.expo import (pubspage, indexpage, editexpopage, expofile
|
|||||||
expofilessingle, expopage, map, mapfile,
|
expofilessingle, expopage, map, mapfile,
|
||||||
mediapage, spider)
|
mediapage, spider)
|
||||||
from troggle.core.views.logbooks import (QMs_jsonListView, Expeditions_jsonListView,
|
from troggle.core.views.logbooks import (QMs_jsonListView, Expeditions_jsonListView,
|
||||||
Expeditions_tsvListView, expedition,
|
Expeditions_tsvListView, expedition, logreport,
|
||||||
get_logbook_entries, get_people,
|
get_logbook_entries, get_people,
|
||||||
logbookentry, notablepersons, person,
|
logbookentry, notablepersons, person,
|
||||||
personexpedition)
|
personexpedition)
|
||||||
@ -149,6 +149,7 @@ trogglepatterns = [
|
|||||||
# Logbook entries
|
# Logbook entries
|
||||||
re_path(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbookentry,name="logbookentry"),
|
re_path(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbookentry,name="logbookentry"),
|
||||||
re_path(r'^logbook$', exportlogbook, name='exportlogbook'),
|
re_path(r'^logbook$', exportlogbook, name='exportlogbook'),
|
||||||
|
path('logreport/<slug:year>', logreport, name='logreport'),
|
||||||
|
|
||||||
# Internal. editfile.html template uses these internally
|
# Internal. editfile.html template uses these internally
|
||||||
re_path(r'^getPeople/(?P<expeditionslug>.*)', get_people, name = "get_people"),
|
re_path(r'^getPeople/(?P<expeditionslug>.*)', get_people, name = "get_people"),
|
||||||
|
Loading…
Reference in New Issue
Block a user