From 3452c2c5d424f39e0dfc02d9c4121cfc434cd216 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 31 Mar 2021 16:14:36 +0100 Subject: [PATCH] flatpages to expopages --- core/views_expo.py | 6 ++--- .../{editflatpage.html => editexpopage.html} | 0 templates/flatpage.html | 2 +- templates/menu.html | 4 ++-- templates/pagenotfound.html | 2 +- urls.py | 23 ++++++++++--------- 6 files changed, 19 insertions(+), 18 deletions(-) rename templates/{editflatpage.html => editexpopage.html} (100%) diff --git a/core/views_expo.py b/core/views_expo.py index d43cf19..fb4c06c 100644 --- a/core/views_expo.py +++ b/core/views_expo.py @@ -55,7 +55,7 @@ def expofilesdir(request, dirpath, filepath): fileitems.append((Path(urlpath) / f.parts[-1], str(f.parts[-1]), getmimetype(f))) return render(request, 'dirdisplay.html', { 'filepath': urlpath, 'fileitems':fileitems, 'diritems': diritems,'settings': settings }) -def flatpage(request, path): +def expopage(request, path): '''Either renders an HTML page from expoweb with all the menus, or serves an unadorned binary file with mime type @@ -174,7 +174,7 @@ def getmimetype(path): @login_required_if_public @ensure_csrf_cookie -def editflatpage(request, path): +def editexpopage(request, path): try: r = Cave.objects.get(url = path) return troggle.core.views_caves.editCave(request, r.cave.slug) @@ -241,7 +241,7 @@ def editflatpage(request, path): else: body = "### File not found ###\n" + str(filepath) flatpageForm = FlatPageForm({"html": body, "title": "Missing"}) - return render(request, 'editflatpage.html', {'path': path, 'form': flatpageForm, }) + return render(request, 'editexpopage.html', {'path': path, 'form': flatpageForm, }) class FlatPageForm(forms.Form): title = forms.CharField(widget=forms.TextInput(attrs={'size':'60'})) diff --git a/templates/editflatpage.html b/templates/editexpopage.html similarity index 100% rename from templates/editflatpage.html rename to templates/editexpopage.html diff --git a/templates/flatpage.html b/templates/flatpage.html index ebe5b1b..cf6d860 100644 --- a/templates/flatpage.html +++ b/templates/flatpage.html @@ -5,7 +5,7 @@ {{ body|safe }} {% if homepage %} {% if editable %} - Edit + Edit {% endif %} {% else %} {% if not has_menu %} diff --git a/templates/menu.html b/templates/menu.html index e36136f..f9fdf4c 100644 --- a/templates/menu.html +++ b/templates/menu.html @@ -3,7 +3,7 @@
  • Home
  • Main Index
  • Handbook
  • -
  • Online systems
  • +
  • Online systems
  • Reports
  • Areas
  • Caves
  • @@ -11,7 +11,7 @@
  • -{% if editable %}
  • Edit this page
  • {% endif %} +{% if editable %}
  • Edit this page
  • {% endif %} {% if cave_editable %}
  • Edit this cave
  • {% endif %} {% endif %} diff --git a/templates/pagenotfound.html b/templates/pagenotfound.html index 2791dd9..9d54ae6 100644 --- a/templates/pagenotfound.html +++ b/templates/pagenotfound.html @@ -2,7 +2,7 @@ {% block title %}Page not found {{ path }}{% endblock %} {% block body %}

    Page not found {{ path }}

    -

    Probably a mistake. But you can use this link +

    Probably a mistake. But you can use this link

    or 'Edit this page' in the menu on the left to create this page if you aare logged in.

    If you can't see that option in the menu, then you are not logged in and you can't create anything. diff --git a/urls.py b/urls.py index 2297535..79651c3 100644 --- a/urls.py +++ b/urls.py @@ -10,7 +10,7 @@ from troggle.core import views_other, views_caves, views_logbooks, views_statist from troggle.core.views_other import troggle404 from troggle.core.views_caves import ent, prospecting_image from troggle.core.views_statistics import pathsreport, stats -from troggle.core.views_expo import expofiles_redirect, expofilessingle, flatpage, editflatpage +from troggle.core.views_expo import expofiles_redirect, expofilessingle, expopage, editexpopage """This sets the actualurlpatterns[] and urlpatterns[] lists which django uses to resolve urls - in both directions as these are declarative. @@ -33,16 +33,16 @@ The API urls return TSV or JSON and are new in July 2020. if settings.EXPOFILESREMOTE: expofilesurls = [ - url(r'^/*(?P.*)$', expofiles_redirect, name="expofiles_redirect"), # to expo.survex.com/expofiles + url(r'^(?P.*)$', expofiles_redirect, name="expofiles_redirect"), # to expo.survex.com/expofiles ] else: expofilesurls = [ - url(r'^/*(?P.*)$', expofilessingle, name="single"), # local copy of EXPOFILES + url(r'^(?P.*)$', expofilessingle, name="single"), # local copy of EXPOFILES ] -actualurlpatterns = [ - url(r'^expofiles', include(expofilesurls)), +trogglepatterns = [ + url(r'^expofiles/', include(expofilesurls)), url(r'^troggle$', views_other.frontpage, name="frontpage"), # control panel. Shows recent actions. url(r'^caves$', views_caves.caveindex, name="caveindex"), @@ -142,18 +142,19 @@ actualurlpatterns = [ # {'document_root': settings.PHOTOS_ROOT, 'show_indexes':True}), # url(r'^site_media/(?P.*)$', view_surveys.expofilessingle, name="single"), # MEDIA_ROOT: CSS and JS - url(r'^(site_media/.*)$', flatpage, name="flatpage"), # MEDIA_ROOT: CSS and JS + url(r'^(site_media/.*)$', expopage, name="expopage"), # MEDIA_ROOT: CSS and JS # url(r'^static/(?P.*)$', view_surveys.expofilessingle, name="single"), # MEDIA_ROOT: CSS and JS - url(r'^(static/.*)$', flatpage, name="flatpage"), # STATIC: CSS and JS + url(r'^(static/.*)$', expopage, name="expopage"), # STATIC: CSS and JS - url(r'^(.*)_edit$', editflatpage, name="editflatpage"), - url(r'^(.*)$', flatpage, name="flatpage"), # CATCHALL assumed relative to EXPOWEB, some expofiles getting here.. + url(r'^(.*)_edit$', editexpopage, name="editexpopage"), + url(r'^(.*)$', expopage, name="expopage"), # CATCHALL assumed relative to EXPOWEB ] -#Allow DIR_ROOT prefix to all urls +# do not allow DIR_ROOT prefix to all urls urlpatterns = [ - url('^%s' % settings.DIR_ROOT, include(actualurlpatterns)) + # url('^%s' % settings.DIR_ROOT, include(trogglepatterns)) + url('', include(trogglepatterns)) ] # When apache is running these prempt Django so Django never sees them.