bugfix for missing dates

This commit is contained in:
Philip Sargent 2022-09-16 21:26:03 +03:00
parent 0ab3a4ff44
commit ddfc677a1e

View File

@ -593,23 +593,29 @@ def scanupload(request, path=None):
waldata["description url"]=""
# find trips and survex files of the same date
datestr = waldata["date"].replace('.','-')
try:
samedate = datetime.date.fromisoformat(datestr)
except ValueError:
# probably a single digit day number. HACKUS MAXIMUS.
# 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)
if waldata["date"]:
datestr = waldata["date"].replace('.','-')
try:
samedate = datetime.date.fromisoformat(datestr)
except ValueError:
# probably a single digit day number. HACKUS MAXIMUS.
# 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)
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)
else:
svxothers = None
trips = None
trips = LogbookEntry.objects.filter(date=samedate)
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=}')
#Survex and survex complaints, comes from json file on disc, not as pre-populated as above
complaints, caveobject = get_complaints([], waldata, svxfiles, files, wallet, wurl)
# print(f' - {caveobject=}')