forked from expo/troggle
fixing bugs after wookey session
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user