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

Handling and fixing bad dates in JSON input

This commit is contained in:
Philip Sargent
2022-09-20 22:52:31 +03:00
parent 94b49adc4e
commit 71bd07e70e
3 changed files with 49 additions and 14 deletions

View File

@@ -631,14 +631,24 @@ def scanupload(request, path=None):
# clearly we need to fix this when we first import date strings..
datestr = datestr[:-1] + '0' + datestr[-1]
print(f' - {datestr=} ')
samedate = datetime.date.fromisoformat(datestr)
try:
samedate = datetime.date.fromisoformat(datestr)
except:
try:
samedate = datetime.date.fromisoformat(datestr[:10])
except:
samedate = None
thisexpo = Expedition.objects.get(year=int(year))
expeditionday = thisexpo.get_expedition_day(samedate)
#print(f' - {thisexpo=} {expeditionday=}')
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday)
#print(f' - {thisexpo=} {expeditionday=} {svxothers=}')
trips = LogbookEntry.objects.filter(date=samedate)
if samedate:
expeditionday = thisexpo.get_expedition_day(samedate)
#print(f' - {thisexpo=} {expeditionday=}')
svxothers = SurvexBlock.objects.filter(expeditionday=expeditionday)
#print(f' - {thisexpo=} {expeditionday=} {svxothers=}')
trips = LogbookEntry.objects.filter(date=samedate)
else:
svxothers = None
trips = None
else:
svxothers = None