diff --git a/core/forms.py b/core/forms.py index 08f7e6c..cd40822 100644 --- a/core/forms.py +++ b/core/forms.py @@ -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. ''' 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 + '