2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00
This commit is contained in:
Philip Sargent 2022-10-08 00:48:21 +03:00
parent 4e9680a3ad
commit 55bc042798

View File

@ -234,34 +234,36 @@ class LoadingSurvex():
# we will have to attach them to the survexblock anyway, and then do a # we will have to attach them to the survexblock anyway, and then do a
# later check on whether they are valid when we get the date. # later check on whether they are valid when we get the date.
personrole, created = SurvexPersonRole.objects.update_or_create(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
expo = survexblock.expedition # may be None if no *date yet expo = survexblock.expedition # may be None if no *date yet
# this syntax was bizarre.. made more obvious # this syntax was bizarre.. made more obvious
if expo: if expo:
if survexblock.expeditionday: # *date has been set if not survexblock.expeditionday: # *date has been set
personrole.expeditionday = survexblock.expeditionday
else:
# should not happen # should not happen
message = "! *team {} expo ok, expedition day not in *team {} ({}) created? '{}'".format(expo.year, survexblock.survexfile.path, survexblock, created ) message = "! *team {} expo ok, expedition day not in *team {} ({}) ".format(expo.year, survexblock.survexfile.path, survexblock )
print(self.insp+message) print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path)) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
personexpedition = GetPersonExpeditionNameLookup(expo).get(tm.lower()) personexpedition = GetPersonExpeditionNameLookup(expo).get(tm.lower())
personrole.person=personexpedition.person if personexpedition:
self.currentpersonexped.append(personexpedition) personrole, created = SurvexPersonRole.objects.update_or_create(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
personrole.person=personexpedition.person
if not personexpedition: personrole.expeditionday = survexblock.expeditionday
self.currentpersonexped.append(personexpedition) # used in push/pop block code
personrole.save()
else:
# we know the date and expo, but can't find the person # we know the date and expo, but can't find the person
message = "! *team {} '{}' FAIL personexpedition lookup on *team {} ({}) in '{}' {} ".format(expo.year, tm, survexblock.survexfile.path, survexblock, created, line) message = "! *team {} '{}' FAIL personexpedition lookup on *team {} ({}) in '{}'".format(expo.year, tm, survexblock.survexfile.path, survexblock, line)
print(self.insp+message) print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path)) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
else: else:
personexpedition = None personexpedition = None
# don't know the date yet, assume the person is valid. It wull get picked up with the *date appears personrole, created = SurvexPersonRole.objects.update_or_create(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
# don't know the date yet, so cannot query the table about validity.
# assume the person is valid. It will get picked up with the *date appears
personrole.save()
personrole.save()
mteammember = self.rx_teammem.match(line) # matches the role at the beginning mteammember = self.rx_teammem.match(line) # matches the role at the beginning
if not mteammember: if not mteammember:
@ -352,34 +354,34 @@ class LoadingSurvex():
# we should make this a date RANGE for everything? # we should make this a date RANGE for everything?
def setdate_on_survexblock(year): def setdate_on_survexblock(year):
# We are assuming that deferred *team people are in the same block. Otherwise, ouch.
expo = self.get_expo_from_year(year) expo = self.get_expo_from_year(year)
survexblock.expedition = expo survexblock.expedition = expo
survexblock.expeditionday = expo.get_expedition_day(survexblock.date) survexblock.expeditionday = expo.get_expedition_day(survexblock.date)
survexblock.save() survexblock.save()
team = SurvexPersonRole.objects.filter(survexblock=survexblock) team = SurvexPersonRole.objects.filter(survexblock=survexblock)
for p in team: for pr in team:
if not p.expeditionday: # *date and *team in 'wrong' order. All working now. if not pr.expeditionday: # *date and *team in 'wrong' order. All working now.
p.expeditionday = survexblock.expeditionday pr.expeditionday = survexblock.expeditionday
p.save() pr.save()
if not p.personexpedition: # again, we didn't know the date until now if not pr.personexpedition: # again, we didn't know the date until now
pe = GetPersonExpeditionNameLookup(expo).get(p.personname.lower()) pe = GetPersonExpeditionNameLookup(expo).get(pr.personname.lower())
if pe: if pe:
# message = "! {} ({}) Fixing undated personexpedition '{}'".format(survexblock.survexfile.path, survexblock, p.personname) # message = "! {} ({}) Fixing undated personexpedition '{}'".format(survexblock.survexfile.path, survexblock, p.personname)
# print(self.insp+message) # print(self.insp+message)
# DataIssue.objects.create(parser='survex', message=message) # DataIssue.objects.create(parser='survex', message=message)
p.personexpedition = pe pr.personexpedition = pe
p.person = p.personexpedition.person pr.person = p.personexpedition.person
p.save() pr.save()
self.currentpersonexped.append(pe) # used in push/pop block code
else: else:
message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, p, survexblock.survexfile.path, survexblock, p.personname) message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, p, survexblock.survexfile.path, survexblock, p.personname)
print(self.insp+message) print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path)) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
oline = line oline = line
if len(line) > 10: if len(line) > 10:
# message = "! DATE Warning LONG DATE '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path) # message = "! DATE Warning LONG DATE '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path)