mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 09:57:22 +00:00
bug fixes and coping with a list of cave ids in JSON
This commit is contained in:
@@ -205,8 +205,13 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
||||
if waldata["cave"]:
|
||||
try:
|
||||
caveid = waldata["cave"]
|
||||
caveid = caveid.replace("/","-")
|
||||
caveobject = getCave(caveid)
|
||||
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"]:
|
||||
# complaints.append(f'The URL of cave description \"{waldata["description url"]}\" does not match the one on record for this cave which is: "{caveobject.url}". If the wallet is not for a cave, put a useful URL here.')
|
||||
@@ -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,9 +484,12 @@ def scanupload(request, path=None):
|
||||
|
||||
if dirs:
|
||||
dirs = sorted(dirs)
|
||||
|
||||
waldata = read_json()
|
||||
|
||||
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}')
|
||||
if not Path(jsonfile).is_file():
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user