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

calendar S T colour >10 per date

This commit is contained in:
Philip Sargent 2023-07-14 11:13:06 +02:00
parent 761a71930b
commit b650095588
2 changed files with 11 additions and 9 deletions

View File

@ -85,12 +85,12 @@ class LogbookEntry(TroggleModel):
if self in todays: if self in todays:
index = todays.index(self) index = todays.index(self)
else: else:
print(f"DayIndex: Synchronization error. Restart server. {self}") print(f"DayIndex: Synchronization error in logbook entries. Restart server or do full reset. {self}")
index = 0 index = 0
if index not in range(0, mx): if index not in range(0, mx):
print(f"DayIndex: More than {mx-1} LogbookEntry items on one day '{index}' {self}") print(f"DayIndex: More than {mx-1} LogbookEntry items on one day '{index}' {self}, restarting colour sequence.")
index = 0 index = index % mx
return index return index

View File

@ -228,15 +228,17 @@ class SurvexBlock(models.Model):
def DayIndex(self): def DayIndex(self):
"""This is used to set different colours for the different trips on """This is used to set different colours for the different trips on
the calendar view of the expedition""" 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 mx = 10
try: todays = list(SurvexBlock.objects.filter(date=self.date))
index = list(SurvexBlock.objects.filter(date=self.date)).index(self) if self in todays:
except: index = todays.index(self)
print(f"DayIndex: BAD BAD BAD SurvexBlock items on one day '{index}' {self}") else:
print(f"DayIndex: Synchronization error in survex blocks. Restart server or do full reset. {self}")
index = 0 index = 0
if index not in range(0, mx): if index not in range(0, mx):
print(f"DayIndex: More than {mx-1} SurvexBlock items on one day '{index}' {self}") print(f"DayIndex: More than {mx-1} SurvexBlock items on one day '{index}' {self}, restarting colour sequence.")
index = 0 index = index % mx
# return list(self.survexblock_set.all()).index(self) # return list(self.survexblock_set.all()).index(self)
return index return index