mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 23:17:06 +00:00
handling survex files not linked in completely
This commit is contained in:
@@ -35,6 +35,9 @@ add this file in to the todo list thinggy.
|
|||||||
|
|
||||||
def populatewallet(w):
|
def populatewallet(w):
|
||||||
'''Copy survex data here just for display, not permanently
|
'''Copy survex data here just for display, not permanently
|
||||||
|
|
||||||
|
Only gets data from the survex file when it was parsed on import..
|
||||||
|
so doesn't work if there is no *ref value
|
||||||
'''
|
'''
|
||||||
survexpeople = []
|
survexpeople = []
|
||||||
blocks = SurvexBlock.objects.filter(scanswallet = w)
|
blocks = SurvexBlock.objects.filter(scanswallet = w)
|
||||||
@@ -76,15 +79,14 @@ def caveifywallet(w):
|
|||||||
w.displaynames = blocknames
|
w.displaynames = blocknames
|
||||||
|
|
||||||
def fillblankpeople(w):
|
def fillblankpeople(w):
|
||||||
# this isn't working..? why?
|
# this isn't working..? why? Because it needs a *ref and an import
|
||||||
wp = w.people()
|
wp = w.people()
|
||||||
if not wp: # an -empty list
|
|
||||||
populatewallet(w)
|
|
||||||
else:
|
|
||||||
w.persons = wp
|
w.persons = wp
|
||||||
if len(wp) == 1:
|
if len(wp) == 1:
|
||||||
|
# print(f' - {wp=}')
|
||||||
nobody = wp[0].lower()
|
nobody = wp[0].lower()
|
||||||
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ' or nobody == '':
|
if nobody == 'unknown' or nobody == 'nobody' or nobody == ' ' or nobody == '':
|
||||||
|
print(f' - {wp=} {nobody=}')
|
||||||
populatewallet(w)
|
populatewallet(w)
|
||||||
|
|
||||||
def fillblankothers(w):
|
def fillblankothers(w):
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
|||||||
complaints.append("A date is mandatory. No data can be updated or edited unless you specify a date. Look in the survex file if there is one.")
|
complaints.append("A date is mandatory. No data can be updated or edited unless you specify a date. Look in the survex file if there is one.")
|
||||||
|
|
||||||
# People
|
# People
|
||||||
if waldata["people"]==["NOBODY"] or waldata["people"]==["Unknown"]:
|
if not waldata["people"] or waldata["people"]==["NOBODY"] or waldata["people"]==["Unknown"] or waldata["people"]==[""]:
|
||||||
complaints.append("Someody must have done this. Look in the survex file, or in the logbook entries for this date, for the people who created this data.")
|
complaints.append("Someody must have done this. Look in the survex file, or in the logbook entries for this date, for the people who created this data.")
|
||||||
|
|
||||||
# survex, but get_ticks has already done much of this ??
|
# survex, but get_ticks has already done much of this ??
|
||||||
@@ -158,7 +158,16 @@ def get_complaints(complaints, waldata, svxfiles, files, wallet, wurl):
|
|||||||
sx = sx + ".svx"
|
sx = sx + ".svx"
|
||||||
svxfiles.append(sx)
|
svxfiles.append(sx)
|
||||||
if not (Path(settings.SURVEX_DATA) / sx).is_file():
|
if not (Path(settings.SURVEX_DATA) / sx).is_file():
|
||||||
file_complaint = f"{wallet} Incorrect survex file name in {wallet} wallet data. {sx} was not found in LOSER repo"
|
file_complaint = f"{wallet} Incorrect survex file name. {sx} was not found in LOSER repo"
|
||||||
|
complaints.append(file_complaint)
|
||||||
|
message = f"! {file_complaint}"
|
||||||
|
print(message)
|
||||||
|
DataIssue.objects.update_or_create(parser='scans', message=message, url=wurl) # set URL to this wallet folder
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
svxfile = SurvexFile.objects.get(path=sx)
|
||||||
|
except:
|
||||||
|
file_complaint = f"{wallet} Survex file name {sx} was not imported via a *include statement."
|
||||||
complaints.append(file_complaint)
|
complaints.append(file_complaint)
|
||||||
message = f"! {file_complaint}"
|
message = f"! {file_complaint}"
|
||||||
print(message)
|
print(message)
|
||||||
@@ -537,9 +546,6 @@ def scanupload(request, path=None):
|
|||||||
#print(f' - {path=}')
|
#print(f' - {path=}')
|
||||||
try:
|
try:
|
||||||
svxfile = SurvexFile.objects.get(path=path)
|
svxfile = SurvexFile.objects.get(path=path)
|
||||||
except:
|
|
||||||
message = f'Specified survex file not found - database apparently empty, you probably need to do a full re-import of all data.'
|
|
||||||
return render(request, 'errors/generic.html', {'message': message})
|
|
||||||
|
|
||||||
print(f' - {svxfile=}')
|
print(f' - {svxfile=}')
|
||||||
if svxfile.cave:
|
if svxfile.cave:
|
||||||
@@ -565,6 +571,11 @@ def scanupload(request, path=None):
|
|||||||
team.append(p.personname)
|
team.append(p.personname)
|
||||||
# else:
|
# else:
|
||||||
# print(f' - Wallet not matching *ref {b.scanswallet=} {wallet}')
|
# print(f' - Wallet not matching *ref {b.scanswallet=} {wallet}')
|
||||||
|
except:
|
||||||
|
message = f'Specified survex file not found - database may be empty, or this survex file is not *included anywhere.'
|
||||||
|
# return render(request, 'errors/generic.html', {'message': message})
|
||||||
|
pass
|
||||||
|
|
||||||
if dates:
|
if dates:
|
||||||
waldata["date"] = min(dates).isoformat()
|
waldata["date"] = min(dates).isoformat()
|
||||||
print(f' - - {team=} ')
|
print(f' - - {team=} ')
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ from troggle.core.views.scans import datewallet
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
contentsjson = "contents.json"
|
contentsjson = "contents.json"
|
||||||
#indexhtml = "walletindex.html"
|
|
||||||
git = settings.GIT
|
git = settings.GIT
|
||||||
|
|
||||||
# to do: create a 'low priority' field, so that any such wallet does not appear in summary reports
|
# to do: Actually read all the JSON files and set the survex file field appropriately!
|
||||||
|
|
||||||
|
|
||||||
def CheckEmptyDate(wallet):
|
def CheckEmptyDate(wallet):
|
||||||
@@ -107,7 +107,7 @@ def load_all_scans():
|
|||||||
for walletname, fpath, fisdir in GetListDir(fpath):
|
for walletname, fpath, fisdir in GetListDir(fpath):
|
||||||
if fisdir:
|
if fisdir:
|
||||||
wallet = Wallet(fpath=fpath, walletname=walletname)
|
wallet = Wallet(fpath=fpath, walletname=walletname)
|
||||||
# this is where we should load the contents.json for people so we can report on them later
|
# this is where we should load the contents.json for people, cave and date so we can report on them later
|
||||||
# this is where we should record the year explicitly
|
# this is where we should record the year explicitly
|
||||||
# line 347 of view/uploads.py and needs refactoring for loading contentsjson
|
# line 347 of view/uploads.py and needs refactoring for loading contentsjson
|
||||||
CheckEmptyDate(wallet)
|
CheckEmptyDate(wallet)
|
||||||
@@ -128,6 +128,7 @@ def load_all_scans():
|
|||||||
if Path(walletpath, contentsjson).is_file():
|
if Path(walletpath, contentsjson).is_file():
|
||||||
walletname = walletpath.name
|
walletname = walletpath.name
|
||||||
wallet, created = Wallet.objects.update_or_create(walletname=walletname)
|
wallet, created = Wallet.objects.update_or_create(walletname=walletname)
|
||||||
|
# should now also load the json and use it ! check &ref is correct or missing too
|
||||||
if created:
|
if created:
|
||||||
print(f"\n{walletname} created: only JSON, no actual uploaded scan files.", end=' ')
|
print(f"\n{walletname} created: only JSON, no actual uploaded scan files.", end=' ')
|
||||||
CheckEmptyDate(wallet)
|
CheckEmptyDate(wallet)
|
||||||
|
|||||||
Reference in New Issue
Block a user