diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-07-14 11:13:06 +0200 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-07-14 11:13:06 +0200 |
commit | b6500955880c983235a98a2b96a75fe710fba0ab (patch) | |
tree | e74c57406d8d35cd9ef4db0bcd916eb9160e5d44 /core/models/survex.py | |
parent | 761a71930b1a6a8ffc329562e46ae0cc8e78645c (diff) | |
download | troggle-b6500955880c983235a98a2b96a75fe710fba0ab.tar.gz troggle-b6500955880c983235a98a2b96a75fe710fba0ab.tar.bz2 troggle-b6500955880c983235a98a2b96a75fe710fba0ab.zip |
calendar S T colour >10 per date
Diffstat (limited to 'core/models/survex.py')
-rw-r--r-- | core/models/survex.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/models/survex.py b/core/models/survex.py index 7b69b64..37e8eb5 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -228,15 +228,17 @@ class SurvexBlock(models.Model): def DayIndex(self): """This is used to set different colours for the different trips on the calendar view of the expedition""" + # print(f"SurvexBlock DayIndex {self.name} '{self.date}' {len(list(SurvexBlock.objects.filter(date=self.date)))} on this date") mx = 10 - try: - index = list(SurvexBlock.objects.filter(date=self.date)).index(self) - except: - print(f"DayIndex: BAD BAD BAD SurvexBlock items on one day '{index}' {self}") + todays = list(SurvexBlock.objects.filter(date=self.date)) + if self in todays: + index = todays.index(self) + else: + print(f"DayIndex: Synchronization error in survex blocks. Restart server or do full reset. {self}") index = 0 if index not in range(0, mx): - print(f"DayIndex: More than {mx-1} SurvexBlock items on one day '{index}' {self}") - index = 0 + print(f"DayIndex: More than {mx-1} SurvexBlock items on one day '{index}' {self}, restarting colour sequence.") + index = index % mx # return list(self.survexblock_set.all()).index(self) return index |