mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
bug fixes and coping with a list of cave ids in JSON
This commit is contained in:
parent
47878d264b
commit
61f9863a06
@ -161,7 +161,7 @@ class SurvexPersonRole(models.Model):
|
||||
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.person) + " - " + str(self.survexblock)
|
||||
return str(self.personname) + " - " + str(self.survexblock)
|
||||
|
||||
class Wallet(models.Model):
|
||||
'''We do not keep the JSON values in the database, we query them afresh each time,
|
||||
|
@ -84,7 +84,7 @@ def fillblankpeople(w):
|
||||
w.persons = wp
|
||||
if len(wp) == 1:
|
||||
nobody = wp[0].lower()
|
||||
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ':
|
||||
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ' or nobody == '':
|
||||
populatewallet(w)
|
||||
|
||||
def fillblankothers(w):
|
||||
@ -93,7 +93,7 @@ def fillblankothers(w):
|
||||
datewallet(w, earliest)
|
||||
|
||||
c = w.cave()
|
||||
if not c:
|
||||
if not c or c == "":
|
||||
caveifywallet(w)
|
||||
|
||||
def fixsurvextick(w, ticks):
|
||||
|
@ -205,7 +205,12 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
||||
if waldata["cave"]:
|
||||
try:
|
||||
caveid = waldata["cave"]
|
||||
caveid = caveid.replace("/","-")
|
||||
if type(caveid) is list:
|
||||
for i in caveid:
|
||||
i = i.replace("/","-")
|
||||
caveobject = getCave(i) # only th elast one gets recorded.. ouch.
|
||||
else:
|
||||
caveid = caveid
|
||||
caveobject = getCave(caveid)
|
||||
print(f'getCave for id "{waldata["cave"]}" {caveobject}')
|
||||
# if not caveobject.url == waldata["description url"]:
|
||||
@ -248,7 +253,9 @@ def scanupload(request, path=None):
|
||||
|
||||
def read_json():
|
||||
'''Read JSON from the wallet metadata file in the repo
|
||||
or fills with blank data if that files can't be read'''
|
||||
or fills with blank data if that files can't be read
|
||||
|
||||
Should sanitise to ensure no spurious backslashes e.g. in windows style paths'''
|
||||
waldata = {}
|
||||
if contents_path.is_file():
|
||||
create = False # yes wallet exists because JSON exists, even if no files in the surveyscans folder, or even if that folder does not exist
|
||||
@ -477,8 +484,11 @@ def scanupload(request, path=None):
|
||||
|
||||
if dirs:
|
||||
dirs = sorted(dirs)
|
||||
|
||||
try:
|
||||
waldata = read_json()
|
||||
except:
|
||||
message = f'Nasty failure in parsing wallets metadata in {contents_path}. Probably backslash not forward slash in filename path'
|
||||
return render(request, 'errors/generic.html', {'message': message})
|
||||
|
||||
jsonfile = Path(settings.DRAWINGS_DATA, "walletjson") / wallet[0:4] / wallet / "contents.json"
|
||||
# print(f'! - FORM scanupload - jsonfile {jsonfile}')
|
||||
@ -501,8 +511,8 @@ def scanupload(request, path=None):
|
||||
# waldata["people"] = list(waldata["people"])
|
||||
|
||||
|
||||
if not waldata["date"] or not waldata["people"] or waldata["people"] == ["Unknown"]: # json file does not exist, blank data, or people not typed into JSON file
|
||||
# refactor into separate functions for no date set or no people set
|
||||
if not waldata["date"] or not waldata["people"] or waldata["people"] == ["Unknown"] or waldata["people"] == [""] or waldata["cave"] == "": # json file does not exist, blank data, or people not typed into JSON file
|
||||
# refactor into separate functions for no date set or no people set or no cave set
|
||||
# print(f'No date set')
|
||||
print(f'\n - Incomplete, empty or default wallet data {wallet} {waldata=}')
|
||||
refs=[]
|
||||
@ -551,11 +561,13 @@ def scanupload(request, path=None):
|
||||
QSpeople = SurvexPersonRole.objects.filter(survexblock=b)
|
||||
print(f' - - {QSpeople=}')
|
||||
for p in QSpeople:
|
||||
print(f' - - {p.personname} ')
|
||||
team.append(p.personname)
|
||||
# else:
|
||||
# print(f' - Wallet not matching *ref {b.scanswallet=} {wallet}')
|
||||
if dates:
|
||||
waldata["date"] = min(dates).isoformat()
|
||||
print(f' - - {team=} ')
|
||||
team = list(set(team))
|
||||
waldata["people"] = team
|
||||
|
||||
|
@ -230,6 +230,7 @@ class LoadingSurvex():
|
||||
if mteammember:
|
||||
for tm in self.rx_person.split(mteammember.group(2)):
|
||||
if tm:
|
||||
tm = tm.strip('\"\'')
|
||||
personexpedition = survexblock.expedition and GetPersonExpeditionNameLookup(survexblock.expedition).get(tm.lower())
|
||||
if (personexpedition, tm) not in teammembers:
|
||||
teammembers.append((personexpedition, tm))
|
||||
|
Loading…
Reference in New Issue
Block a user