mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
Complaints now on wallet page
This commit is contained in:
parent
7c82c2d97c
commit
b20e6c5a58
@ -81,6 +81,9 @@ class PostTests(TestCase):
|
||||
def test_scan_upload(self):
|
||||
'''Expect scan upload to wallet to work on any file
|
||||
Need to login first.
|
||||
|
||||
This upload form looks for the cave, so the test fails if the database is not loaded with the cave
|
||||
identified in the wallet
|
||||
'''
|
||||
c = self.client
|
||||
from django.contrib.auth.models import User
|
||||
@ -99,8 +102,8 @@ class PostTests(TestCase):
|
||||
for ph in [ r'test_upload_',
|
||||
r'← 2020#00 →',
|
||||
r'description written',
|
||||
r'plan not required',
|
||||
r'Upload scan into wallet']:
|
||||
r'Plan not required',
|
||||
r'edit settings or upload a file']:
|
||||
phmatch = re.search(ph, content)
|
||||
self.assertIsNotNone(phmatch, "Failed to find expected text: '" + ph +"'")
|
||||
|
||||
|
@ -574,6 +574,8 @@ def GetCaveLookup():
|
||||
"""lookup function modelled on GetPersonExpeditionNameLookup
|
||||
repeated assignment each call, needs refactoring
|
||||
|
||||
Used when parsing wallets contents.json file too in views/uploads.py
|
||||
|
||||
Does NOT detect duplicates! Needs fixing.
|
||||
Needs to be a proper funciton that raises an exception if there is a duplicate.
|
||||
OR we could set it to return None if there are duplictes, and require the caller to
|
||||
@ -609,130 +611,134 @@ def GetCaveLookup():
|
||||
# and Becka's email of 25 may 2020 on new kataster numbers
|
||||
|
||||
# These might alse create more duplicate entries, so re-write it to check
|
||||
Gcavelookup["1987-02"] = Gcavelookup["267"]
|
||||
Gcavelookup["1990-01"] = Gcavelookup["171"]
|
||||
Gcavelookup["1990-02"] = Gcavelookup["172"]
|
||||
Gcavelookup["1990-03"] = Gcavelookup["173"]
|
||||
Gcavelookup["1990-04"] = Gcavelookup["174"]
|
||||
Gcavelookup["1990-05"] = Gcavelookup["175"]
|
||||
Gcavelookup["1990-06"] = Gcavelookup["176"]
|
||||
Gcavelookup["1990-07"] = Gcavelookup["177"]
|
||||
Gcavelookup["1990-08"] = Gcavelookup["178"]
|
||||
Gcavelookup["1990-09"] = Gcavelookup["179"]
|
||||
Gcavelookup["1990-10"] = Gcavelookup["180"]
|
||||
Gcavelookup["1990-11"] = Gcavelookup["181"]
|
||||
Gcavelookup["1990-12"] = Gcavelookup["182"]
|
||||
Gcavelookup["1990-13"] = Gcavelookup["183"]
|
||||
Gcavelookup["1990-14"] = Gcavelookup["184"]
|
||||
Gcavelookup["1990-18"] = Gcavelookup["188"]
|
||||
Gcavelookup["1990-adam"] = Gcavelookup["225"]
|
||||
Gcavelookup["1993-01"] = Gcavelookup["200"]
|
||||
Gcavelookup["1996-02"] = Gcavelookup["224"]
|
||||
Gcavelookup["1996-03"] = Gcavelookup["223"]
|
||||
Gcavelookup["1996-04"] = Gcavelookup["222"]
|
||||
Gcavelookup["1996wk2"] = Gcavelookup["207"]
|
||||
Gcavelookup["1996wk3"] = Gcavelookup["208"]
|
||||
Gcavelookup["1996wk5"] = Gcavelookup["219"]
|
||||
Gcavelookup["1996wk6"] = Gcavelookup["218"]
|
||||
Gcavelookup["1996wk8"] = Gcavelookup["209"]
|
||||
Gcavelookup["1996wk11"] = Gcavelookup["268"]
|
||||
Gcavelookup["96wk11"] = Gcavelookup["268"]
|
||||
Gcavelookup["1998-01"] = Gcavelookup["201"]
|
||||
Gcavelookup["1998-03"] = Gcavelookup["210"]
|
||||
Gcavelookup["1999-03"] = Gcavelookup["204"]
|
||||
Gcavelookup["1999-04"] = Gcavelookup["230"]
|
||||
Gcavelookup["1999-10"] = Gcavelookup["162"]
|
||||
Gcavelookup["1999-bo-01"] = Gcavelookup["205"]
|
||||
Gcavelookup["1999-ob-01"] = Gcavelookup["205"]
|
||||
Gcavelookup["1999-ob-03"] = Gcavelookup["226"]
|
||||
Gcavelookup["1999-ob-04"] = Gcavelookup["227"]
|
||||
Gcavelookup["2000-01"] = Gcavelookup["231"]
|
||||
Gcavelookup["2000-03"] = Gcavelookup["214"]
|
||||
Gcavelookup["2000-04"] = Gcavelookup["220"]
|
||||
Gcavelookup["2000-05"] = Gcavelookup["215"]
|
||||
Gcavelookup["2000-06"] = Gcavelookup["216"]
|
||||
Gcavelookup["2000-07"] = Gcavelookup["217"]
|
||||
Gcavelookup["2000-09"] = Gcavelookup["234"]
|
||||
Gcavelookup["2000-aa-01"] = Gcavelookup["250"]
|
||||
Gcavelookup["2001-04"] = Gcavelookup["239"]
|
||||
Gcavelookup["2001-05"] = Gcavelookup["243"]
|
||||
Gcavelookup["2002-01"] = Gcavelookup["249"]
|
||||
Gcavelookup["2002-02"] = Gcavelookup["234"]
|
||||
Gcavelookup["2002-04"] = Gcavelookup["242"]
|
||||
Gcavelookup["2002-05"] = Gcavelookup["294"]
|
||||
Gcavelookup["2003-01"] = Gcavelookup["256"]
|
||||
Gcavelookup["2003-02"] = Gcavelookup["248"]
|
||||
Gcavelookup["2003-03"] = Gcavelookup["247"]
|
||||
Gcavelookup["2003-04"] = Gcavelookup["241"]
|
||||
Gcavelookup["2003-05"] = Gcavelookup["246"]
|
||||
Gcavelookup["2003-06"] = Gcavelookup["161"]
|
||||
Gcavelookup["2003-08"] = Gcavelookup["240"]
|
||||
Gcavelookup["2003-09"] = Gcavelookup["245"]
|
||||
Gcavelookup["2003-10"] = Gcavelookup["244"]
|
||||
Gcavelookup["2004-01"] = Gcavelookup["269"]
|
||||
Gcavelookup["2004-03"] = Gcavelookup["270"]
|
||||
Gcavelookup["2004-11"] = Gcavelookup["251"]
|
||||
Gcavelookup["2004-12"] = Gcavelookup["161"]
|
||||
Gcavelookup["2004-15"] = Gcavelookup["253"]
|
||||
Gcavelookup["2004-19"] = Gcavelookup["254"]
|
||||
Gcavelookup["2004-20"] = Gcavelookup["255"]
|
||||
Gcavelookup["2005-04"] = Gcavelookup["204"]
|
||||
Gcavelookup["2005-05"] = Gcavelookup["264"]
|
||||
Gcavelookup["2005-07"] = Gcavelookup["257"]
|
||||
Gcavelookup["2006-08"] = Gcavelookup["285"]
|
||||
Gcavelookup["2006-09"] = Gcavelookup["298"]
|
||||
Gcavelookup["2007-71"] = Gcavelookup["271"]
|
||||
Gcavelookup["2010-01"] = Gcavelookup["263"]
|
||||
Gcavelookup["2010-03"] = Gcavelookup["293"]
|
||||
Gcavelookup["2011-01"] = Gcavelookup["292"]
|
||||
Gcavelookup["2012-dd-05"] = Gcavelookup["286"]
|
||||
Gcavelookup["2012-ns-13"] = Gcavelookup["292"]
|
||||
Gcavelookup["2014-neo-01"] = Gcavelookup["273"]
|
||||
Gcavelookup["2014-sd-01"] = Gcavelookup["274"]
|
||||
Gcavelookup["2014-ms-14"] = Gcavelookup["287"]
|
||||
Gcavelookup["2015-mf-06"] = Gcavelookup["288"]
|
||||
Gcavelookup["2016-jb-01"] = Gcavelookup["289"]
|
||||
Gcavelookup["2017-pw-01"] = Gcavelookup["277"]
|
||||
Gcavelookup["2018-dm-07"] = Gcavelookup["359"] # NB this is 1626
|
||||
Gcavelookup["2017_cucc_24"] = Gcavelookup["291"] # note _ not -
|
||||
Gcavelookup["2017_cucc_23"] = Gcavelookup["295"] # note _ not -
|
||||
Gcavelookup["2017_cucc_28"] = Gcavelookup["290"] # note _ not -
|
||||
Gcavelookup["bs17"] = Gcavelookup["283"]
|
||||
|
||||
Gcavelookup["1976/b11"] = Gcavelookup["198"]
|
||||
Gcavelookup["1976/b8"] = Gcavelookup["197"]
|
||||
Gcavelookup["1976/b9"] = Gcavelookup["190"]
|
||||
Gcavelookup["b11"] = Gcavelookup["1976/b11"]
|
||||
Gcavelookup["b8"] = Gcavelookup["1976/b8"]
|
||||
Gcavelookup["b9"] = Gcavelookup["1976/b9"]
|
||||
# skip any missing keys as this gets called during tests when the database is not loaded
|
||||
try:
|
||||
Gcavelookup["1987-02"] = Gcavelookup["267"]
|
||||
Gcavelookup["1990-01"] = Gcavelookup["171"]
|
||||
Gcavelookup["1990-02"] = Gcavelookup["172"]
|
||||
Gcavelookup["1990-03"] = Gcavelookup["173"]
|
||||
Gcavelookup["1990-04"] = Gcavelookup["174"]
|
||||
Gcavelookup["1990-05"] = Gcavelookup["175"]
|
||||
Gcavelookup["1990-06"] = Gcavelookup["176"]
|
||||
Gcavelookup["1990-07"] = Gcavelookup["177"]
|
||||
Gcavelookup["1990-08"] = Gcavelookup["178"]
|
||||
Gcavelookup["1990-09"] = Gcavelookup["179"]
|
||||
Gcavelookup["1990-10"] = Gcavelookup["180"]
|
||||
Gcavelookup["1990-11"] = Gcavelookup["181"]
|
||||
Gcavelookup["1990-12"] = Gcavelookup["182"]
|
||||
Gcavelookup["1990-13"] = Gcavelookup["183"]
|
||||
Gcavelookup["1990-14"] = Gcavelookup["184"]
|
||||
Gcavelookup["1990-18"] = Gcavelookup["188"]
|
||||
Gcavelookup["1990-adam"] = Gcavelookup["225"]
|
||||
Gcavelookup["1993-01"] = Gcavelookup["200"]
|
||||
Gcavelookup["1996-02"] = Gcavelookup["224"]
|
||||
Gcavelookup["1996-03"] = Gcavelookup["223"]
|
||||
Gcavelookup["1996-04"] = Gcavelookup["222"]
|
||||
Gcavelookup["1996wk2"] = Gcavelookup["207"]
|
||||
Gcavelookup["1996wk3"] = Gcavelookup["208"]
|
||||
Gcavelookup["1996wk5"] = Gcavelookup["219"]
|
||||
Gcavelookup["1996wk6"] = Gcavelookup["218"]
|
||||
Gcavelookup["1996wk8"] = Gcavelookup["209"]
|
||||
Gcavelookup["1996wk11"] = Gcavelookup["268"]
|
||||
Gcavelookup["96wk11"] = Gcavelookup["268"]
|
||||
Gcavelookup["1998-01"] = Gcavelookup["201"]
|
||||
Gcavelookup["1998-03"] = Gcavelookup["210"]
|
||||
Gcavelookup["1999-03"] = Gcavelookup["204"]
|
||||
Gcavelookup["1999-04"] = Gcavelookup["230"]
|
||||
Gcavelookup["1999-10"] = Gcavelookup["162"]
|
||||
Gcavelookup["1999-bo-01"] = Gcavelookup["205"]
|
||||
Gcavelookup["1999-ob-01"] = Gcavelookup["205"]
|
||||
Gcavelookup["1999-ob-03"] = Gcavelookup["226"]
|
||||
Gcavelookup["1999-ob-04"] = Gcavelookup["227"]
|
||||
Gcavelookup["2000-01"] = Gcavelookup["231"]
|
||||
Gcavelookup["2000-03"] = Gcavelookup["214"]
|
||||
Gcavelookup["2000-04"] = Gcavelookup["220"]
|
||||
Gcavelookup["2000-05"] = Gcavelookup["215"]
|
||||
Gcavelookup["2000-06"] = Gcavelookup["216"]
|
||||
Gcavelookup["2000-07"] = Gcavelookup["217"]
|
||||
Gcavelookup["2000-09"] = Gcavelookup["234"]
|
||||
Gcavelookup["2000-aa-01"] = Gcavelookup["250"]
|
||||
Gcavelookup["2001-04"] = Gcavelookup["239"]
|
||||
Gcavelookup["2001-05"] = Gcavelookup["243"]
|
||||
Gcavelookup["2002-01"] = Gcavelookup["249"]
|
||||
Gcavelookup["2002-02"] = Gcavelookup["234"]
|
||||
Gcavelookup["2002-04"] = Gcavelookup["242"]
|
||||
Gcavelookup["2002-05"] = Gcavelookup["294"]
|
||||
Gcavelookup["2003-01"] = Gcavelookup["256"]
|
||||
Gcavelookup["2003-02"] = Gcavelookup["248"]
|
||||
Gcavelookup["2003-03"] = Gcavelookup["247"]
|
||||
Gcavelookup["2003-04"] = Gcavelookup["241"]
|
||||
Gcavelookup["2003-05"] = Gcavelookup["246"]
|
||||
Gcavelookup["2003-06"] = Gcavelookup["161"]
|
||||
Gcavelookup["2003-08"] = Gcavelookup["240"]
|
||||
Gcavelookup["2003-09"] = Gcavelookup["245"]
|
||||
Gcavelookup["2003-10"] = Gcavelookup["244"]
|
||||
Gcavelookup["2004-01"] = Gcavelookup["269"]
|
||||
Gcavelookup["2004-03"] = Gcavelookup["270"]
|
||||
Gcavelookup["2004-11"] = Gcavelookup["251"]
|
||||
Gcavelookup["2004-12"] = Gcavelookup["161"]
|
||||
Gcavelookup["2004-15"] = Gcavelookup["253"]
|
||||
Gcavelookup["2004-19"] = Gcavelookup["254"]
|
||||
Gcavelookup["2004-20"] = Gcavelookup["255"]
|
||||
Gcavelookup["2005-04"] = Gcavelookup["204"]
|
||||
Gcavelookup["2005-05"] = Gcavelookup["264"]
|
||||
Gcavelookup["2005-07"] = Gcavelookup["257"]
|
||||
Gcavelookup["2006-08"] = Gcavelookup["285"]
|
||||
Gcavelookup["2006-09"] = Gcavelookup["298"]
|
||||
Gcavelookup["2007-71"] = Gcavelookup["271"]
|
||||
Gcavelookup["2010-01"] = Gcavelookup["263"]
|
||||
Gcavelookup["2010-03"] = Gcavelookup["293"]
|
||||
Gcavelookup["2011-01"] = Gcavelookup["292"]
|
||||
Gcavelookup["2012-dd-05"] = Gcavelookup["286"]
|
||||
Gcavelookup["2012-ns-13"] = Gcavelookup["292"]
|
||||
Gcavelookup["2014-neo-01"] = Gcavelookup["273"]
|
||||
Gcavelookup["2014-sd-01"] = Gcavelookup["274"]
|
||||
Gcavelookup["2014-ms-14"] = Gcavelookup["287"]
|
||||
Gcavelookup["2015-mf-06"] = Gcavelookup["288"]
|
||||
Gcavelookup["2016-jb-01"] = Gcavelookup["289"]
|
||||
Gcavelookup["2017-pw-01"] = Gcavelookup["277"]
|
||||
Gcavelookup["2018-dm-07"] = Gcavelookup["359"] # NB this is 1626
|
||||
Gcavelookup["2017_cucc_24"] = Gcavelookup["291"] # note _ not -
|
||||
Gcavelookup["2017_cucc_23"] = Gcavelookup["295"] # note _ not -
|
||||
Gcavelookup["2017_cucc_28"] = Gcavelookup["290"] # note _ not -
|
||||
Gcavelookup["bs17"] = Gcavelookup["283"]
|
||||
|
||||
Gcavelookup["1976/b11"] = Gcavelookup["198"]
|
||||
Gcavelookup["1976/b8"] = Gcavelookup["197"]
|
||||
Gcavelookup["1976/b9"] = Gcavelookup["190"]
|
||||
Gcavelookup["b11"] = Gcavelookup["1976/b11"]
|
||||
Gcavelookup["b8"] = Gcavelookup["1976/b8"]
|
||||
Gcavelookup["b9"] = Gcavelookup["1976/b9"]
|
||||
|
||||
Gcavelookup["2011-01-bs30"] = Gcavelookup["190"]
|
||||
Gcavelookup["bs30"] = Gcavelookup["190"]
|
||||
Gcavelookup["87"] = Gcavelookup["190"]
|
||||
Gcavelookup["2011-01"] = Gcavelookup["190"]
|
||||
|
||||
Gcavelookup["quarriesd"] = Gcavelookup["2002-08"]
|
||||
Gcavelookup["2002-x11"] = Gcavelookup["2005-08"]
|
||||
Gcavelookup["2002-x12"] = Gcavelookup["2005-07"]
|
||||
Gcavelookup["2002-x13"] = Gcavelookup["2005-06"]
|
||||
Gcavelookup["2002-x14"] = Gcavelookup["2005-05"]
|
||||
|
||||
Gcavelookup["kh"] = Gcavelookup["161"]
|
||||
Gcavelookup["161-kh"] = Gcavelookup["161"]
|
||||
Gcavelookup["204-steinBH"] = Gcavelookup["204"]
|
||||
Gcavelookup["stonebridge"] = Gcavelookup["204"]
|
||||
Gcavelookup["hauchhole"] = Gcavelookup["234"]
|
||||
Gcavelookup["hauch"] = Gcavelookup["234"]
|
||||
Gcavelookup["234-hauch"] = Gcavelookup["234"]
|
||||
Gcavelookup["tunnocks"] = Gcavelookup["258"]
|
||||
Gcavelookup["balcony"] = Gcavelookup["264"]
|
||||
Gcavelookup["balkon"] = Gcavelookup["264"]
|
||||
Gcavelookup["fgh"] = Gcavelookup["290"]
|
||||
Gcavelookup["gsh"] = Gcavelookup["291"]
|
||||
Gcavelookup["2011-01-bs30"] = Gcavelookup["190"]
|
||||
Gcavelookup["bs30"] = Gcavelookup["190"]
|
||||
Gcavelookup["87"] = Gcavelookup["190"]
|
||||
Gcavelookup["2011-01"] = Gcavelookup["190"]
|
||||
|
||||
Gcavelookup["quarriesd"] = Gcavelookup["2002-08"]
|
||||
Gcavelookup["2002-x11"] = Gcavelookup["2005-08"]
|
||||
Gcavelookup["2002-x12"] = Gcavelookup["2005-07"]
|
||||
Gcavelookup["2002-x13"] = Gcavelookup["2005-06"]
|
||||
Gcavelookup["2002-x14"] = Gcavelookup["2005-05"]
|
||||
|
||||
Gcavelookup["kh"] = Gcavelookup["161"]
|
||||
Gcavelookup["161-kh"] = Gcavelookup["161"]
|
||||
Gcavelookup["204-steinBH"] = Gcavelookup["204"]
|
||||
Gcavelookup["stonebridge"] = Gcavelookup["204"]
|
||||
Gcavelookup["hauchhole"] = Gcavelookup["234"]
|
||||
Gcavelookup["hauch"] = Gcavelookup["234"]
|
||||
Gcavelookup["234-hauch"] = Gcavelookup["234"]
|
||||
Gcavelookup["tunnocks"] = Gcavelookup["258"]
|
||||
Gcavelookup["balcony"] = Gcavelookup["264"]
|
||||
Gcavelookup["balkon"] = Gcavelookup["264"]
|
||||
Gcavelookup["fgh"] = Gcavelookup["290"]
|
||||
Gcavelookup["gsh"] = Gcavelookup["291"]
|
||||
|
||||
Gcavelookup["homecoming"] = Gcavelookup["2018-dm-07"]
|
||||
Gcavelookup["heimkommen"] = Gcavelookup["2018-dm-07"]
|
||||
Gcavelookup["99ob02"] = Gcavelookup["1999-ob-02"]
|
||||
Gcavelookup["homecoming"] = Gcavelookup["2018-dm-07"]
|
||||
Gcavelookup["heimkommen"] = Gcavelookup["2018-dm-07"]
|
||||
Gcavelookup["99ob02"] = Gcavelookup["1999-ob-02"]
|
||||
except:
|
||||
pass
|
||||
|
||||
addmore = {}
|
||||
for id in Gcavelookup:
|
||||
|
@ -3,8 +3,10 @@ import subprocess
|
||||
import json
|
||||
import settings
|
||||
import urllib
|
||||
import operator
|
||||
|
||||
from pathlib import Path
|
||||
from functools import reduce
|
||||
|
||||
from django import forms
|
||||
|
||||
@ -15,6 +17,7 @@ from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render
|
||||
from django.template import Context, loader
|
||||
from django.core.files.storage import FileSystemStorage, default_storage
|
||||
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
||||
|
||||
|
||||
#from troggle import settings
|
||||
@ -27,6 +30,7 @@ from troggle.core.models.troggle import Expedition, Person, PersonExpedition
|
||||
from troggle.core.models.caves import LogbookEntry, QM, Cave, PersonTrip
|
||||
from troggle.core.models.survex import DrawingFile
|
||||
from troggle.core.views.scans import oldwallet, walletindex
|
||||
from troggle.core.views.caves import getCave
|
||||
|
||||
from .auth import login_required_if_public
|
||||
#from django.views.decorators.csrf import ensure_csrf_cookie, csrf_exempt
|
||||
@ -35,6 +39,10 @@ from .auth import login_required_if_public
|
||||
'''
|
||||
|
||||
todo = '''
|
||||
- Register uploaded filenames in the Django db without needing to wait for a reset & bulk file import
|
||||
|
||||
- Refactor scanupload() as it contains all the wallets 'complaints' code from the old script wallets.py
|
||||
|
||||
- Need to validate uploaded file as being a valid image file, not a dubious script or hack
|
||||
|
||||
- Write equivalent GPX upload form system, similar to scanupload() but in expofiles/gpslogs/
|
||||
@ -47,7 +55,6 @@ todo = '''
|
||||
|
||||
- Enable folder creation in dwguploads or as a separate form
|
||||
|
||||
- Register uploaded filenames in the Django db without needing to wait for a reset & bulk file import
|
||||
'''
|
||||
|
||||
class FilesForm(forms.Form): # not a model-form, just a form-form
|
||||
@ -91,6 +98,85 @@ xlate = {"url": "description url",
|
||||
"survex": "survex file",
|
||||
}
|
||||
|
||||
def get_complaints(complaints, waldata, svxfiles, files):
|
||||
'''Taken from old script wallets.py and edited to make more comprehensible
|
||||
Loads the survex files names and processes all complaints
|
||||
'''
|
||||
survex_complaint = ""
|
||||
|
||||
if waldata["survex file"]:
|
||||
if not type(waldata["survex file"])==list: # a string also is a sequence type, so do it this way
|
||||
waldata["survex file"] = [waldata["survex file"]]
|
||||
for svx in waldata["survex file"]:
|
||||
svxfiles.append(svx)
|
||||
if not (Path(settings.SURVEX_DATA) / svx).is_file():
|
||||
file_complaint = f"{wallet} Incorrect survex file name in wallet data: {svx} not found in LOSER repo"
|
||||
complaints.append(file_complaint)
|
||||
message = f"! {file_complaint}"
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='scans', message=message, url=wurl) # set URL to this wallet folder
|
||||
|
||||
if waldata["survex not required"] and waldata["survex file"] != "":
|
||||
survex_complaint = "Survex is stated as not required and yet there is a survex file!"
|
||||
if not waldata["survex not required"] and waldata["survex file"] == "":
|
||||
survex_complaint = "A survex file is required, but has not been specified!"
|
||||
if survex_complaint:
|
||||
complaints.append(survex_complaint)
|
||||
|
||||
# Notes required
|
||||
if not waldata["electronic survey"]:
|
||||
notes_scanned = reduce(operator.or_, [f.startswith("note") for f in files], False)
|
||||
notes_scanned = reduce(operator.or_, [f.endswith("note") for f in files], notes_scanned)
|
||||
if not notes_scanned:
|
||||
complaints.append("The notes needs scanning (or renaming): no noteNN.jpg or XXnote.jpg file found; and this is not an electronic survey.")
|
||||
|
||||
# Plan drawing required
|
||||
plan_scanned = reduce(operator.or_, [f.startswith("plan") for f in files], False)
|
||||
plan_scanned = reduce(operator.or_, [f.endswith("plan") for f in files], plan_scanned)
|
||||
plan_drawing_required = not (plan_scanned or waldata["plan drawn"] or waldata["plan not required"])
|
||||
if plan_drawing_required:
|
||||
complaints.append("The plan needs drawing (or renaming, or tick 'Plan drawn' checkbox or 'Plan not required' checkbox): no planNN.jpg or XXplan.jpg file found.")
|
||||
|
||||
# Elev drawing required
|
||||
elev_scanned = reduce(operator.or_, [f.startswith("elev") for f in files], False)
|
||||
elev_scanned = reduce(operator.or_, [f.endswith("elev") for f in files], elev_scanned)
|
||||
elev_drawing_required = not (elev_scanned or waldata["elev drawn"] or waldata["elev not required"])
|
||||
if elev_drawing_required:
|
||||
complaints.append("The elevation needs drawing (or renaming, or tick 'Elev drawn' checkbox or 'Elev not required' checkbox): no elevNN.jpg or XXelev.jpg file found.")
|
||||
|
||||
# Electronic Surveys
|
||||
if not waldata["electronic survey"]:
|
||||
if elev_drawing_required or plan_drawing_required:
|
||||
complaints.append("Tunnel or Therion drawing files need drawing. Or if this an electronic survey, please tick the 'Electronic survey' checkbox.")
|
||||
|
||||
# Description
|
||||
if not waldata["description written"]:
|
||||
complaints.append("The guidebook description needs writing into the survex file. Tick the 'Cave description written' checkbox when this is done.")
|
||||
# QMs
|
||||
if not waldata["qms written"]:
|
||||
complaints.append("The QMs needs writing into the survex file. Tick the 'QMs written' checkbox when this is done.")
|
||||
|
||||
|
||||
# Website
|
||||
if not waldata["website updated"]:
|
||||
complaints.append("The cave description website is marked as needing updating using the guidebook description from the survex file. Tick the 'Website updated' checkbox when this is done.")
|
||||
|
||||
# FInd the cave, if it exists
|
||||
try:
|
||||
caveobject = getCave(waldata["cave"])
|
||||
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.')
|
||||
except Cave.MultipleObjectsReturned:
|
||||
complaints.append(f'The cave ID \'{waldata["cave"]}\' is AMBIGUOUS. Please fix it.')
|
||||
caveobject = None
|
||||
except ObjectDoesNotExist:
|
||||
complaints.append(f'The cave ID \'{waldata["cave"]}\' is not recognised. Please fix it.')
|
||||
caveobject = None
|
||||
|
||||
|
||||
return complaints, caveobject
|
||||
|
||||
# @login_required_if_public
|
||||
def scanupload(request, path=None):
|
||||
'''Upload scanned image files into a wallet on /expofiles
|
||||
@ -98,6 +184,9 @@ def scanupload(request, path=None):
|
||||
|
||||
This does NOT use a Django model linked to a Django form. Just a simple Django form.
|
||||
You will find the Django documentation on forms very confusing, This is simpler.
|
||||
|
||||
This subsumes much of the code which was in the old wallets.py script and so this function is very long
|
||||
indeed and needs refactoring.
|
||||
'''
|
||||
filesaved = False
|
||||
actual_saved = []
|
||||
@ -270,35 +359,29 @@ def scanupload(request, path=None):
|
||||
if not waldata["description url"]:
|
||||
waldata["description url"]=""
|
||||
if waldata["cave"]:
|
||||
cave = waldata["cave"]
|
||||
cave = waldata["cave"] # text string
|
||||
if waldata["name"]:
|
||||
psg = waldata["name"]
|
||||
|
||||
if waldata["survex file"]:
|
||||
#print(f'+++ ${waldata["survex file"]}$ {type(waldata["survex file"])}')
|
||||
if not type(waldata["survex file"])==list: # a string also is a sequence type, so do it this way
|
||||
#print(f'+++ NOT A LIST: {waldata["survex file"]} {type(waldata["survex file"])}')
|
||||
waldata["survex file"] = [waldata["survex file"]]
|
||||
|
||||
for svx in waldata["survex file"]:
|
||||
svxfiles.append(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
|
||||
|
||||
#Survex and survex complaints
|
||||
complaints, caveobject = get_complaints([], waldata, svxfiles, files)
|
||||
|
||||
|
||||
for f in checkboxes:
|
||||
if waldata[f]:
|
||||
checked[f] = "checked"
|
||||
|
||||
|
||||
context = {'year': year, 'prev': prev, 'next': next, 'prevy': prevy, 'nexty': nexty,
|
||||
'files': files, 'dirs': dirs, 'waldata': waldata, 'svxfiles': svxfiles,
|
||||
'checked': checked,
|
||||
'create': create,
|
||||
'complaints': complaints,
|
||||
'caveobject': caveobject,
|
||||
'people': waldata["people"], 'peoplesize': str(len(str(waldata["people"]))),
|
||||
'filesaved': filesaved, 'actual_saved': actual_saved }
|
||||
|
||||
return render(request, 'scanuploadform.html',
|
||||
return render(request, 'walletform.html',
|
||||
{'form': form, 'wallet': wallet, **context,
|
||||
'date': waldata["date"],
|
||||
'url': waldata["description url"], 'urlsize': str(len(str(waldata["description url"]))),
|
||||
@ -312,7 +395,7 @@ def scanupload(request, path=None):
|
||||
'people': "", 'peoplesize': 12,
|
||||
'filesaved': filesaved, 'actual_saved': actual_saved }
|
||||
|
||||
return render(request, 'scanuploadform.html',
|
||||
return render(request, 'walletform.html',
|
||||
{'form': form, 'wallet': wallet, **context,
|
||||
'date': "",
|
||||
'url': "", 'urlsize': 12,
|
||||
|
Loading…
Reference in New Issue
Block a user