forked from expo/troggle
Handling and fixing bad dates in JSON input
This commit is contained in:
@@ -82,12 +82,15 @@ def fillblankpeople(w):
|
||||
# this isn't working..? why? Because it needs a *ref and an import
|
||||
wp = w.people()
|
||||
w.persons = wp
|
||||
if len(wp) == 1:
|
||||
# print(f' - {wp=}')
|
||||
nobody = wp[0].lower()
|
||||
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ' or nobody == '':
|
||||
print(f' - {wp=} {nobody=}')
|
||||
populatewallet(w)
|
||||
if not wp:
|
||||
populatewallet(w)
|
||||
else:
|
||||
if len(wp) == 1:
|
||||
# print(f' - {wp=}')
|
||||
nobody = wp[0].lower()
|
||||
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ' or nobody == '':
|
||||
print(f' - {wp=} {nobody=}')
|
||||
populatewallet(w)
|
||||
|
||||
def fillblankothers(w):
|
||||
earliest = datetime.datetime.now().date()
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user