diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-01-29 20:59:56 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-01-29 20:59:56 +0000 |
commit | 226cbb6b5cb9d38b2856a3007745c8045ed9efae (patch) | |
tree | 17a5c3d522a5598815f570abb4ce19aef1f88f67 /core/models/logbooks.py | |
parent | a1c34f488daac73ad027f03f74a6c725a5ff53d9 (diff) | |
download | troggle-226cbb6b5cb9d38b2856a3007745c8045ed9efae.tar.gz troggle-226cbb6b5cb9d38b2856a3007745c8045ed9efae.tar.bz2 troggle-226cbb6b5cb9d38b2856a3007745c8045ed9efae.zip |
Fixed coloured T and S on expo calendar
Diffstat (limited to 'core/models/logbooks.py')
-rw-r--r-- | core/models/logbooks.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/models/logbooks.py b/core/models/logbooks.py index 468b100..b7aa5e3 100644 --- a/core/models/logbooks.py +++ b/core/models/logbooks.py @@ -21,6 +21,7 @@ from django.template import Context, loader from django.urls import reverse import settings +#from troggle.core.models.caves import CaveSlug from troggle.core.models.survex import SurvexStation from troggle.core.models.troggle import (DataIssue, Expedition, Person, PersonExpedition, TroggleModel) @@ -36,7 +37,7 @@ class LogbookEntry(TroggleModel): """Single parsed entry from Logbook """ date = models.DateField()#MJG wants to turn this into a datetime such that multiple Logbook entries on the same day can be ordered.ld() - expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information) + # expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)#MJG wants to KILL THIS (redundant information) expedition = models.ForeignKey(Expedition,blank=True, null=True,on_delete=models.SET_NULL) # yes this is double- title = models.CharField(max_length=200) cave_slug = models.SlugField(max_length=50, blank=True, null=True) @@ -70,7 +71,14 @@ class LogbookEntry(TroggleModel): LogbookEntry.objects.get(id=self.id-1) def DayIndex(self): - return list(self.expeditionday.logbookentry_set.all()).index(self) + """This is used to set different colours for the different trips on + the calendar view of the expedition""" + index = list(LogbookEntry.objects.filter(date=self.date)).index(self) + if index not in range(0,10): + print(f"Unexpected LogbookEntry DayIndex '{index}' {self}") + index = 0 + return index + class PersonTrip(TroggleModel): """Single Person going on a trip, which may or may not be written up. |