2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 16:51:54 +00:00

enable non-cave html and images redirection

This commit is contained in:
Philip Sargent 2021-04-01 21:44:03 +01:00
parent d6409b22c2
commit c8cc1673e0
2 changed files with 12 additions and 6 deletions

View File

@ -15,6 +15,7 @@ from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
import troggle.settings as settings
#import troggle.core.models as models
from troggle.core.views import expo
from troggle.core.models import Expedition, DataIssue
from troggle.core.models_caves import CaveSlug, Cave, CaveAndEntrance, QM, EntranceSlug, Entrance, Area, SurvexStation, GetCaveLookup
from troggle.core.forms import CaveForm, CaveAndEntranceFormSet, VersionControlCommentForm, EntranceForm, EntranceLetterForm
@ -138,7 +139,11 @@ def cave3d(request, cave_id=''):
return response
def cavepage(request, karea, subpath):
'''Displays a cave description page'''
'''Displays a cave description page
There are A LOT OF URLS to e.g. /1623/161/l/rl89a.htm which are IMAGES and html files
in cave descriptions. These need to be handled HERE
'''
path = karea + subpath
print(" ! cavepage:'{}' kataster area:'{}' rest of path:'{}'".format(path, karea, subpath))
@ -146,13 +151,13 @@ def cavepage(request, karea, subpath):
cave = Cave.objects.get(url = path) # ideally this will be unique
slug = cave.slug()
print(" - cavepage:'{}' cave:'{}' cave-slug:'{}'".format(path, str(cave), slug))
#cave = Cave.objects.get(caveslug__slug = slug)
if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated():
return render(request,'nonpublic.html', {'instance': cave, 'cave_editable': slug})
else:
return render(request,'cave.html', {'cave': cave, 'cave_editable': slug})
except Cave.DoesNotExist:
return render(request, 'pagenotfound.html', {'path': path})
# probably a link to text or an image e.g. 1623/161/l/rl89a.htm i.e. an expoweb page
return expo.expopage(request, path)
except Cave.MultipleObjectsReturned:
caves = Cave.objects.filter(url = path)
return render(request, 'svxcaveseveral.html', {'settings': settings, "caves":caves })

View File

@ -18,8 +18,8 @@ from troggle.core.models_caves import Cave
import troggle.core.views.caves
import troggle.settings as settings
'''Formerly a separate package 'flatpages' written by Martin Green 2011.
This was NOT django.contrib.flatpages which stores HTML in the database, so the name was chnaged to expopages.
'''Formerly a separate package called 'flatpages' written by Martin Green 2011.
This was NOT django.contrib.flatpages which stores HTML in the database, so the name was changed to expopages.
Then it was incorporated into troggle directly, rather than being an unnecessary external package.
'''
@ -92,7 +92,7 @@ def expowebpage(request, expowebpath, path):
'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu})
def mediapage(request, subpath=None, doc_root=None):
'''This is for special prefixe paths /photos/ /site_media/, /static/ etc.
'''This is for special prefix paths /photos/ /site_media/, /static/ etc.
as defined in urls.py . If given a directory, gives a failure page.
'''
# print(" - XXXXX_ROOT: {} ...{}".format(doc_root, subpath))
@ -108,6 +108,7 @@ def mediapage(request, subpath=None, doc_root=None):
return render(request, 'pagenotfound.html', {'path': subpath})
def expopage(request, path):
'''Either renders an HTML page from expoweb with all the menus,
or serves an unadorned binary file with mime type