diff --git a/core/models/logbooks.py b/core/models/logbooks.py index 680036a..19cd33d 100644 --- a/core/models/logbooks.py +++ b/core/models/logbooks.py @@ -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] diff --git a/core/views/logbooks.py b/core/views/logbooks.py index 5ffae6a..47aa7e1 100644 --- a/core/views/logbooks.py +++ b/core/views/logbooks.py @@ -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: diff --git a/templates/logbookentry.html b/templates/logbookentry.html index 584da8e..d9b0de2 100644 --- a/templates/logbookentry.html +++ b/templates/logbookentry.html @@ -29,30 +29,30 @@
Caver | T/U | Prev | Next | |
---|---|---|---|---|
{% else %} | {% endif %} - {{persontrip.personexpedition.person}} + {{personlogentry.personexpedition.person}} | - {% if persontrip.timeunderground %} - - T/U {{persontrip.timeunderground}} + {% if personlogentry.timeunderground %} + - T/U {{personlogentry.timeunderground}} {% endif %} | - {% if persontrip.persontrip_prev %} - {{persontrip.persontrip_prev.logbook_entry.date|date:"D d M Y"}} + {% if personlogentry.prev_personlog %} + {{personlogentry.prev_personlog.logbook_entry.date|date:"D d M Y"}} {% endif %} | - {% if persontrip.persontrip_next %} - {{persontrip.persontrip_next.logbook_entry.date|date:"D d M Y"}} + {% if personlogentry.next_personlog %} + {{personlogentry.next_personlog.logbook_entry.date|date:"D d M Y"}} {% endif %} | @@ -64,7 +64,7 @@