From d3ddcba313c2cd677a1c9106f2d64c98e52c8f04 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 15 Mar 2022 23:00:23 +0000 Subject: [PATCH] bug fixes --- core/views/uploads.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/core/views/uploads.py b/core/views/uploads.py index 038f2d0..0acd326 100644 --- a/core/views/uploads.py +++ b/core/views/uploads.py @@ -140,37 +140,39 @@ def scanupload(request, wallet=None): if dirs: dirs = sorted(dirs) - waldata = [] + waldata = {} if contents_path.is_file(): with open(contents_path) as json_file: try: waldata = json.load(json_file) except: - message = f"! Failed to load {contents_path} JSON file" + message = f"! {wallet} Failed to load {contents_path} JSON file" print(message) DataIssue.objects.create(parser='scans', message=message, url=wurl) # set URL to this wallet folder raise - if not waldata["people"]: - waldata["people"]=["NOBODY"] cave ="" psg = "" - if waldata["cave"]: - cave = waldata["cave"] - if waldata["name"]: - psg = waldata["name"] - if waldata["survex file"]: - if not isinstance(waldata["survex file"], list): - waldata["survex file"] = [waldata["survex file"]] - - for svx in waldata["survex file"]: - print(f'{svx}') - if not (Path(settings.SURVEX_DATA) / svx).is_file(): - message = f"! Incorrect survex file in wallet data: {svx} not found in LOSER repo" - print(message) - DataIssue.objects.create(parser='scans', message=message, url=wurl) # set URL to this wallet folder - + if waldata: + if not waldata["people"]: + waldata["people"]=["NOBODY"] + + if waldata["cave"]: + cave = waldata["cave"] + if waldata["name"]: + psg = waldata["name"] + if waldata["survex file"]: + if not isinstance(waldata["survex file"], list): + waldata["survex file"] = [waldata["survex file"]] + + for svx in waldata["survex file"]: + print(f'{svx}') + if not (Path(settings.SURVEX_DATA) / svx).is_file(): + message = f"! {wallet} Incorrect survex file in wallet data: {svx} not found in LOSER repo" + print(message) + DataIssue.objects.create(parser='scans', message=message, url=wurl) # set URL to this wallet folder + context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty, 'files': files, 'dirs': dirs, 'waldata': waldata, 'create': create, 'filesaved': filesaved, 'actual_saved': actual_saved } @@ -226,6 +228,7 @@ def photoupload(request, folder=None): if form.is_valid(): f = request.FILES["uploadfiles"] multiple = request.FILES.getlist('uploadfiles') + # NO CHECK that the files being uploaded are image files fs = FileSystemStorage(dirpath) actual_saved = [] @@ -279,7 +282,7 @@ def dwgupload(request, folder=None, gitdisable='no'): ''' if name in [ '.gitignore', ]: return False - if Path(name).suffix.lower() in ['.xml', '.th', '.th2', '', '.svg', '.txt', '.jpg', '.jpeg', '.png', '.pdf', '.topo']: + if Path(name).suffix.lower() in ['.xml', '.th', '.th2', '', '.svg', '.txt', '.jpg', '.jpeg', '.png', '.pdf', '.top', '.topo']: return True # dangerous, we should check the actual file binary signature return False