2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00:00

renaming confusing Class, step 1

This commit is contained in:
Philip Sargent 2023-01-30 16:07:44 +00:00
parent 3742e0f367
commit 58f7cf72d4
3 changed files with 19 additions and 21 deletions

View File

@ -104,14 +104,14 @@ class PersonTrip(TroggleModel):
ordering = ('-personexpedition',)
#order_with_respect_to = 'personexpedition'
def persontrip_next(self):
def next_personlog(self):
futurePTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
if len(futurePTs) > 0:
return futurePTs[0]
else:
return None
def persontrip_prev(self):
def prev_personlog(self):
pastPTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__lt = self.logbook_entry.date).order_by('-logbook_entry__date').all()
if len(pastPTs) > 0:
return pastPTs[0]

View File

@ -100,12 +100,12 @@ def expedition(request, expeditionname):
dateditems = list(entries) + list(blocks) # evaluates the Django query and hits db
dates = sorted(set([item.date for item in dateditems]))
allpersontrips = PersonTrip.objects.filter(personexpedition__expedition=expo)
allpersonlogentries = PersonTrip.objects.filter(personexpedition__expedition=expo)
personexpeditiondays = [ ]
for personexpedition in expo.personexpedition_set.all():
expotrips = allpersontrips.filter(personexpedition=personexpedition) # lazy
expotrips = allpersonlogentries.filter(personexpedition=personexpedition) # lazy
expoblocks = blocks.filter(survexpersonrole__personexpedition=personexpedition)
prow = [ ]
@ -168,7 +168,7 @@ def get_person_chronology(personexpedition):
res = { }
for persontrip in personexpedition.persontrip_set.all():
a = res.setdefault(persontrip.logbook_entry.date, { })
a.setdefault("persontrips", [ ]).append(persontrip)
a.setdefault("personlogentries", [ ]).append(persontrip)
for personrole in personexpedition.survexpersonrole_set.all():
if personrole.survexblock.date: # avoid bad data from another bug
@ -180,10 +180,10 @@ def get_person_chronology(personexpedition):
res2 = [ ]
for rdate in rdates:
persontrips = res[rdate].get("persontrips", [])
personlogentries = res[rdate].get("personlogentries", [])
personroles = res[rdate].get("personroles", [])
for n in range(max(len(persontrips), len(personroles) )):
res2.append(((n == 0 and rdate or "--"), (n < len(persontrips) and persontrips[n]), (n < len(personroles) and personroles[n]) ))
for n in range(max(len(personlogentries), len(personroles) )):
res2.append(((n == 0 and rdate or "--"), (n < len(personlogentries) and personlogentries[n]), (n < len(personroles) and personroles[n]) ))
return res2
@ -227,10 +227,8 @@ def logbookentry(request, date, slug):
# svxothers = None
svxothers = SurvexBlock.objects.filter(date=date)
this_logbookentry=this_logbookentry[0]
# This is the only page that uses presontrip_next and persontrip_prev
# This is the only page that uses persontrip_next and persontrip_prev
# and it is calculated on the fly in the model
# duration = time.time()-start
# print(f"--- Render after {duration:.2f} seconds")
return render(request, 'logbookentry.html',
{'logbookentry': this_logbookentry, 'trips': trips, 'svxothers': svxothers, 'wallets': wallets})
else:

View File

@ -29,30 +29,30 @@
<table class="cavers">
<tr><th>Caver</th><th>T/U</th><th>Prev</th><th>Next</th></tr>
{% for persontrip in logbookentry.persontrip_set.all %}
{% for personlogentry in logbookentry.persontrip_set.all %}
<tr>
{% if persontrip.is_logbook_entry_author %}
{% if personlogentry.is_logbook_entry_author %}
<td class="author">
{% else %}
<td>
{% endif %}
<a href="{{ persontrip.personexpedition.get_absolute_url }}">{{persontrip.personexpedition.person}}</a>
<a href="{{ personlogentry.personexpedition.get_absolute_url }}">{{personlogentry.personexpedition.person}}</a>
</td>
<td>
{% if persontrip.timeunderground %}
- T/U {{persontrip.timeunderground}}</p>
{% if personlogentry.timeunderground %}
- T/U {{personlogentry.timeunderground}}</p>
{% endif %}
</td>
<td>
{% if persontrip.persontrip_prev %}
<a href="{{ persontrip.persontrip_prev.logbook_entry.get_absolute_url }}">{{persontrip.persontrip_prev.logbook_entry.date|date:"D d M Y"}}</a>
{% if personlogentry.prev_personlog %}
<a href="{{ personlogentry.prev_personlog.logbook_entry.get_absolute_url }}">{{personlogentry.prev_personlog.logbook_entry.date|date:"D d M Y"}}</a>
{% endif %}
</td>
<td>
{% if persontrip.persontrip_next %}
<a href="{{ persontrip.persontrip_next.logbook_entry.get_absolute_url }}">{{persontrip.persontrip_next.logbook_entry.date|date:"D d M Y"}}</a>
{% if personlogentry.next_personlog %}
<a href="{{ personlogentry.next_personlog.logbook_entry.get_absolute_url }}">{{personlogentry.next_personlog.logbook_entry.date|date:"D d M Y"}}</a>
{% endif %}
</td>
@ -64,7 +64,7 @@
<div id="col1">
<div class="logbookentry">
<b>{{logbookentry.date|date:"D d M Y"}}</b>
{% for persontrip in logbookentry.persontrip_set.all %}{% if persontrip.is_logbook_entry_author %}<br />{{persontrip.personexpedition.person}}{% endif %}{% endfor %}
{% for personlogentry in logbookentry.persontrip_set.all %}{% if personlogentry.is_logbook_entry_author %}<br />{{personlogentry.personexpedition.person}}{% endif %}{% endfor %}
<p>{{logbookentry.text|safe}}</p>
</div>
</div>