2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 08:37:16 +00:00

Replace assert() with DataIssue message

This commit is contained in:
Philip Sargent
2021-03-29 02:06:19 +01:00
parent c81f17c24b
commit 0f024b27f0
6 changed files with 46 additions and 79 deletions

View File

@@ -112,8 +112,12 @@ class Expedition(TroggleModel):
def get_expedition_day(self, date):
expeditiondays = self.expeditionday_set.filter(date=date)
if expeditiondays:
assert len(expeditiondays) == 1
return expeditiondays[0]
if len(expeditiondays) == 1:
return expeditiondays[0]
else:
message ='! - more than one datum in an expeditionday: {}'.format(date)
DataIssue.objects.create(parser='expedition', message=message)
return expeditiondays[0]
res = ExpeditionDay(expedition=self, date=date)
res.save()
return res