mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 00:31:55 +00:00
fixing bugs after wookey session
This commit is contained in:
parent
48171ae824
commit
f1b206ad34
@ -11,7 +11,8 @@ from django.contrib.admin.widgets import AdminDateWidget
|
||||
from troggle.core.models.troggle import Person, PersonExpedition, Expedition
|
||||
from troggle.core.models.caves import Cave, LogbookEntry, QM, Entrance, CaveAndEntrance
|
||||
|
||||
'''These are all the Forms used by troggle
|
||||
'''These are all the class-based Forms used by troggle.
|
||||
There are other, simpler, upload forms in view/uploads.py
|
||||
Some are not used and need renovating or destroying.
|
||||
'''
|
||||
|
||||
|
@ -267,6 +267,7 @@ def cavepage(request, karea, subpath):
|
||||
|
||||
except Cave.DoesNotExist:
|
||||
# probably a link to text or an image e.g. 1623/161/l/rl89a.htm i.e. an expoweb page
|
||||
# cannot assume that this is a simple cave page, for a cave we don't know.
|
||||
return expo.expopage(request, str(kpath))
|
||||
except Cave.MultipleObjectsReturned:
|
||||
caves = Cave.objects.filter(url = kpath)
|
||||
@ -276,20 +277,6 @@ def cavepage(request, karea, subpath):
|
||||
message = f'Failed to find cave: {kpath}'
|
||||
return render(request,'errors/generic.html', {'message': message})
|
||||
|
||||
def cave(request, cave_id='', offical_name=''):
|
||||
'''Displays a cave description page
|
||||
accesssed by a fairly random id which might be anything
|
||||
'''
|
||||
try:
|
||||
cave=getCave(cave_id)
|
||||
except MultipleObjectsReturned:
|
||||
caves = Cave.objects.filter(kataster_number=cave_id)
|
||||
return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves }) # not the right template, needs a specific one
|
||||
except ObjectDoesNotExist:
|
||||
return render(request, 'errors/svxcavesingle404.html', {'settings': settings, "cave":cave_id })
|
||||
except:
|
||||
return render(request, 'errors/svxcavesingle404.html', {'settings': settings })
|
||||
|
||||
return rendercave(request, cave, cave.slug(), cave_id=cave_id)
|
||||
|
||||
def caveEntrance(request, slug):
|
||||
@ -303,23 +290,13 @@ def caveEntrance(request, slug):
|
||||
else:
|
||||
return render(request,'cave_entrances.html', {'cave': cave})
|
||||
|
||||
# def caveDescription(request, slug):
|
||||
# try:
|
||||
# cave = Cave.objects.get(caveslug__slug = slug)
|
||||
# except:
|
||||
# return render(request,'errors/badslug.html', {'badslug': slug})
|
||||
|
||||
# if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated:
|
||||
# return render(request,'nonpublic.html', {'instance': cave})
|
||||
# else:
|
||||
# return render(request,'cave_uground_description.html', {'cave': cave})
|
||||
|
||||
@login_required_if_public
|
||||
def edit_cave(request, slug=None):
|
||||
'''This is the form that edits all the cave data and writes out an XML file in the :expoweb: repo folder
|
||||
The format for the file being saved is in templates/dataformat/cave.xml
|
||||
|
||||
It does save the data into into the database directly, not by parsing the file.
|
||||
It does NOT yet commit to the git repo
|
||||
'''
|
||||
message = ""
|
||||
if slug is not None:
|
||||
|
@ -125,9 +125,12 @@ def expowebpage(request, expowebpath, path):
|
||||
print(f' - 404 error in expowebpage() {path}')
|
||||
return render(request, 'pagenotfound.html', {'path': path}, status="404")
|
||||
|
||||
with open(os.path.normpath(expowebpath / path), "r") as o:
|
||||
html = o.read()
|
||||
|
||||
try:
|
||||
with open(os.path.normpath(expowebpath / path), "r") as o:
|
||||
html = o.read()
|
||||
except:
|
||||
return HttpResponse(default_head + html + '<h3>UTF-8 Parsing Failue:<br>Page could not be parsed using UTF-8:<br>failure detected in expowebpage in views.expo.py</h3> Please edit this <var>:expoweb:</var> page to replace dubious umlauts with HTML entitiies in the expected code. </body' )
|
||||
|
||||
m = re.search(r'(.*)<\s*head([^>]*)>(.*)<\s*/head\s*>(.*)<\s*body([^>]*)>(.*)<\s*/body\s*>(.*)', html, re.DOTALL + re.IGNORECASE)
|
||||
if m:
|
||||
preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups()
|
||||
|
@ -109,7 +109,7 @@ class SvxForm(forms.Form):
|
||||
filename = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
|
||||
datetime = forms.DateTimeField(widget=forms.TextInput(attrs={"readonly":True}))
|
||||
outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
|
||||
code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":36}))
|
||||
code = forms.CharField(widget=forms.Textarea(attrs={"cols":140, "rows":36}))
|
||||
|
||||
template = False
|
||||
|
||||
|
@ -417,13 +417,13 @@ def readcave(filename):
|
||||
if survex_file[0]:
|
||||
if not (Path(SURVEX_DATA) / survex_file[0]).is_file():
|
||||
message = f' ! {slug:12} survex filename does not exist :LOSER:"{survex_file[0]}" in "{filename}"'
|
||||
DataIssue.objects.create(parser='caves', message=message, url=f'/cave/{slug}/edit/')
|
||||
DataIssue.objects.create(parser='caves', message=message, url=f'/{slug}_cave_edit/')
|
||||
print(message)
|
||||
|
||||
|
||||
if description_file[0]: # if not an empty string
|
||||
message = f' - {slug:12} complex description filename "{description_file[0]}" inside "{CAVEDESCRIPTIONS}/{filename}"'
|
||||
DataIssue.objects.create(parser='caves ok', message=message, url=f'/cave/{slug}/edit/')
|
||||
DataIssue.objects.create(parser='caves ok', message=message, url=f'{slug}/edit/')
|
||||
print(message)
|
||||
|
||||
if not (Path(EXPOWEB) / description_file[0]).is_file():
|
||||
|
@ -114,7 +114,7 @@ class LoadingSurvex():
|
||||
rx_names = re.compile(r'(?i)names')
|
||||
rx_flagsnot= re.compile(r"not\s")
|
||||
rx_linelen = re.compile(r"[\d\-+.]+$")
|
||||
instruments = "(waiting_patiently|slacker|Useless|nagging|unknown|Inst|instrument|rig|rigger|rigging|helper|something| compass|comp|clino|Notes|sketch|book|Tape|Dog|Pics|photo|drawing|Helper|GPS|Disto|Distox|Distox2|topodroid|point|Consultant|nail|polish|varnish|bitch|monkey|PowerDrill|drill)"
|
||||
instruments = "(waiting_patiently|slacker|Useless|nagging|unknown|Inst|instrument|rig|rigger|rigging|helper|something| compass|comp|clino|Notes|sketch|book|Tape|Dog|Pics|photo|drawing|Helper|GPS|Disto|Distox|Distox2|topodroid|point|Consultant|nail|polish|nail_polish_bitch|nail_polish_monkey|varnish|nail_polish|nail_varnish|bitch|monkey|PowerDrill|drill)"
|
||||
rx_teammem = re.compile(r"(?i)"+instruments+"?(?:es|s)?\s+(.*)"+instruments+"?(?:es|s)?$")
|
||||
rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$")
|
||||
rx_qm = re.compile(r'(?i)^\s*QM(\d)\s+?([a-dA-DxX])\s+([\w\-]+)\.(\d+)\s+(([\w\-]+)\.(\d+)|\-)\s+(.+)$')
|
||||
@ -448,27 +448,27 @@ class LoadingSurvex():
|
||||
|
||||
def LoadSurvexRef(self, survexblock, args):
|
||||
#print(self.insp+ "*REF ---- '"+ args +"'")
|
||||
|
||||
url=f'/survexfile/{survexblock.survexfile.path}'
|
||||
# *REF but also ; Ref years from 1960 to 2039
|
||||
refline = self.rx_ref_text.match(args)
|
||||
if refline:
|
||||
# a textual reference such as "1996-1999 Not-KH survey book pp 92-95"
|
||||
# print(self.insp+ "*REF quoted text so ignored:"+ args)
|
||||
print(self.insp+ "*REF quoted text so ignored:"+ args)
|
||||
return
|
||||
|
||||
if len(args)< 4:
|
||||
message = " ! Empty or BAD *REF statement '{}' in '{}'".format(args, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
return
|
||||
|
||||
argsgps = self.rx_argsref.match(args)
|
||||
if argsgps:
|
||||
yr, letterx, wallet = argsgps.groups()
|
||||
else:
|
||||
message = " ! BAD *REF statement '{}' in '{}'".format(args, survexblock.survexfile.path)
|
||||
message = " ! Wallet *REF '{}' in '{}' ".format(args, survexblock.survexfile.path)
|
||||
print(self.insp+message)
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
return
|
||||
|
||||
if not letterx:
|
||||
@ -480,31 +480,31 @@ class LoadingSurvex():
|
||||
if not (int(yr)>1960 and int(yr)<2039):
|
||||
message = " ! Wallet year out of bounds {yr} '{refscan}' {survexblock.survexfile.path}"
|
||||
print((self.insp+message))
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
|
||||
refscan = "%s#%s%s" % (yr, letterx, wallet)
|
||||
try:
|
||||
if int(wallet)>100:
|
||||
message = " ! Wallet *REF {} - too big in '{}'".format(refscan, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
except:
|
||||
message = " ! Wallet *REF {} - not numeric in '{}'".format(refscan, survexblock.survexfile.path)
|
||||
message = " ! Wallet *REF {} - not numeric in '{}' -- parsing continues".format(refscan, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
manywallets = Wallet.objects.filter(walletname=refscan)
|
||||
if manywallets:
|
||||
survexblock.scanswallet = manywallets[0] # this is a ForeignKey field
|
||||
print(manywallets[0])
|
||||
survexblock.save()
|
||||
if len(manywallets) > 1:
|
||||
message = " ! Wallet *REF {} - {} scan folders from DB search in {}".format(refscan, len(manywallets), survexblock.survexfile.path)
|
||||
message = " ! Wallet *REF {} - {} scan folders from DB search in {} -- parsing continues".format(refscan, len(manywallets), survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
else:
|
||||
message = " ! Wallet *REF '{}' - NOT found in DB search '{}'".format(refscan, survexblock.survexfile.path)
|
||||
message = " ! Wallet *REF '{}' - NOT found in DB search '{}' -- parsing continues".format(refscan, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
DataIssue.objects.create(parser='survex', message=message, url=url)
|
||||
|
||||
def LoadSurvexQM(self, survexblock, qmline):
|
||||
insp = self.insp
|
||||
@ -668,7 +668,7 @@ class LoadingSurvex():
|
||||
return self.svxdirs[headpath.lower()]
|
||||
|
||||
def ReportNonCaveIncludes(self, headpath, includelabel):
|
||||
"""Ignore surface, kataser and gps *include survex files
|
||||
"""Ignore surface, kataser and gpx *include survex files
|
||||
"""
|
||||
if headpath in self.ignorenoncave:
|
||||
#message = f" - {headpath} is <ignorenoncave> (while creating '{includelabel}' sfile & sdirectory)"
|
||||
@ -677,11 +677,12 @@ class LoadingSurvex():
|
||||
return
|
||||
for i in self.ignoreprefix:
|
||||
if headpath.startswith(i):
|
||||
#message = f" - {headpath} starts with <ignoreprefix> (while creating '{includelabel}' sfile & sdirectory)"
|
||||
#print("\n"+message)
|
||||
message = f" - {headpath} starts with <ignoreprefix> (while creating '{includelabel}' sfile & sdirectory)"
|
||||
print("\n"+message)
|
||||
#print("\n"+message,file=sys.stderr)
|
||||
return
|
||||
message = f" ! Error: '{headpath}' not a cave or in the ignore list of surface surveys. (while creating '{includelabel}')"
|
||||
message = f" ! Error: '{headpath}' not a cave or in the ignore list of surface surveys. (while creating '{includelabel}' in db)"
|
||||
# getting this triggered for gpx/2018 but not for gpx/2017 ?!
|
||||
print("\n"+message)
|
||||
print("\n"+message,file=sys.stderr)
|
||||
DataIssue.objects.create(parser='survex', message=message)
|
||||
@ -725,7 +726,7 @@ class LoadingSurvex():
|
||||
if cave:
|
||||
newdirectory.cave = cave
|
||||
newfile.cave = cave
|
||||
#print("\n"+str(newdirectory.cave),file=sys.stderr)
|
||||
print("\n"+str(newdirectory.cave),file=sys.stderr)
|
||||
else: # probably a surface survey
|
||||
self.ReportNonCaveIncludes(headpath, svxid)
|
||||
|
||||
@ -1214,8 +1215,9 @@ class LoadingSurvex():
|
||||
sp = subprocess.run([settings.CAVERN, "--log", f'--output={outputdir}', f'{fullpath}.svx'],
|
||||
capture_output=True, check=False, text=True)
|
||||
if sp.returncode != 0:
|
||||
message = f' ! Error running {settings.CAVERN}: {fullpath}'
|
||||
DataIssue.objects.create(parser='entrances', message=message)
|
||||
message = f' ! Error running {settings.CAVERN}: {fullpath}'
|
||||
url = f'/survexfile{fullpath}.svx'.replace(settings.SURVEX_DATA, "")
|
||||
DataIssue.objects.create(parser='xEntrances', message=message, url=url)
|
||||
print(message)
|
||||
print(f'stderr:\n\n' + str(sp.stderr) + '\n\n' + str(sp.stdout) + '\n\nreturn code: ' + str(sp.returncode))
|
||||
self.caverncount += 1
|
||||
@ -1408,6 +1410,7 @@ def LoadSurvexBlocks():
|
||||
DataIssue.objects.filter(parser='survexleg').delete()
|
||||
DataIssue.objects.filter(parser='survexunits').delete()
|
||||
DataIssue.objects.filter(parser='entrances').delete()
|
||||
DataIssue.objects.filter(parser='xEntrances').delete()
|
||||
|
||||
survexfileroot = MakeSurvexFileRoot()
|
||||
# this next makes a block_object assciated with a file_object.path = SURVEX_TOPNAME
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends "cavebase.html" %}
|
||||
<!-- cave.html - this text visible because this template has been included -->
|
||||
{% block extraheaders %}
|
||||
<!-- cave.html - this text visible because this template has been included -->
|
||||
{% if cave.survex_file %}
|
||||
|
||||
<!--
|
||||
@ -527,7 +527,7 @@ div#scene {
|
||||
<p><a href="https://aardgoose.github.io/CaveView.js/">CaveView</a> display of the .3d file is temporarily disabled while we fix things (Nov.2021). See <a href="/handbook/computing/todo.html">/handbook/computing/todo.html</a>.
|
||||
<a href="/survexfile">All survex files</a>
|
||||
<a href="{% if cave.kataster_number %}{% url "cave3d" cave.kataster_number %}{% else %}{% url "cave3d" cave.unofficial_number %}{% endif %}">3d file download</a>
|
||||
<a href="{% url "svx" svxstem %}">This survex file</a>
|
||||
<a href="{% url "survexcavessingle" cave.kataster_number %}">This survex file</a>
|
||||
|
||||
<div id='scene'></div>
|
||||
{% endif %}
|
||||
|
4
urls.py
4
urls.py
@ -50,13 +50,13 @@ Test VERY CAREFULLY for each change. It is fragile.
|
||||
|
||||
if settings.EXPOFILESREMOTE:
|
||||
expofilesurls = [
|
||||
path('/<path:filepath>', expofiles_redirect, name="expofiles_redirect"), # to http://expo.survex.com/expofiles
|
||||
path('<path:filepath>', expofiles_redirect, name="expofiles_redirect"), # to http://expo.survex.com/expofiles
|
||||
path('', expofiles_redirect, {'filepath': ""}, name="expofiles_redirect"),
|
||||
]
|
||||
else:
|
||||
expofilesurls = [
|
||||
path('/<path:filepath>', expofilessingle, name="single"), # local copy of EXPOFILES
|
||||
path('', expofilessingle, {'filepath': ""}, name="single"),
|
||||
path('<path:filepath>', expofilessingle, name="single"), # local copy of EXPOFILES
|
||||
]
|
||||
|
||||
# see https://docs.djangoproject.com/en/dev/topics/auth/default/
|
||||
|
Loading…
Reference in New Issue
Block a user