From ddfc677a1e4852e884bcf117f653479e6de3cc9c Mon Sep 17 00:00:00 2001 From: Philip Sargent <philip.sargent@klebos.com> Date: Fri, 16 Sep 2022 21:26:03 +0300 Subject: [PATCH] bugfix for missing dates --- core/views/uploads.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/core/views/uploads.py b/core/views/uploads.py index 158da24..975e8f1 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -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=}')