summaryrefslogtreecommitdiffstats
path: root/core/views
diff options
context:
space:
mode:
Diffstat (limited to 'core/views')
-rw-r--r--core/views/caves.py27
-rw-r--r--core/views/expo.py9
-rw-r--r--core/views/survex.py2
3 files changed, 9 insertions, 29 deletions
diff --git a/core/views/caves.py b/core/views/caves.py
index 9e40c51..325c593 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -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:
diff --git a/core/views/expo.py b/core/views/expo.py
index c6ef01b..b6644f3 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -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()
diff --git a/core/views/survex.py b/core/views/survex.py
index c0f63ef..21603bc 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -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