summaryrefslogtreecommitdiffstats
path: root/flatpages/views.py
diff options
context:
space:
mode:
authorSam Wenham <sam@wenhams.co.uk>2019-02-23 15:30:58 +0000
committerSam Wenham <sam@wenhams.co.uk>2019-02-23 15:30:58 +0000
commita1f02e575f6c379fd1a66cbfdefe8b9f29800297 (patch)
tree5f9f1791ea31f765974087ae879f248f3a3c18be /flatpages/views.py
parentf58b1db9208b5a7509699b2a34f70fb275fb8b65 (diff)
downloadtroggle-a1f02e575f6c379fd1a66cbfdefe8b9f29800297.tar.gz
troggle-a1f02e575f6c379fd1a66cbfdefe8b9f29800297.tar.bz2
troggle-a1f02e575f6c379fd1a66cbfdefe8b9f29800297.zip
Prevent troggle adding the menu if there is one in the file
Add a Docker compose file to bring up a dev troggle easily Various PEP improvments
Diffstat (limited to 'flatpages/views.py')
-rw-r--r--flatpages/views.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/flatpages/views.py b/flatpages/views.py
index 6503d40..672ec0c 100644
--- a/flatpages/views.py
+++ b/flatpages/views.py
@@ -35,7 +35,7 @@ def flatpage(request, path):
if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated():
- print "flat path noinfo", path
+ print("flat path noinfo", path)
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
if path.endswith("/") or path == "":
@@ -67,13 +67,15 @@ def flatpage(request, path):
title, = m.groups()
else:
title = ""
- linksmatch = re.match('(.*)<ul id="links">', body, re.DOTALL + re.IGNORECASE)
- if linksmatch:
- body, = linksmatch.groups()
+ has_menu = False
+ menumatch = re.match('(.*)<div id="menu">', body, re.DOTALL + re.IGNORECASE)
+ if menumatch:
+ has_menu = True
+ #body, = menumatch.groups()
if re.search(r"iso-8859-1", html):
body = unicode(body, "iso-8859-1")
body.strip
- return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm")})
+ return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm"), 'has_menu': has_menu})
else:
return HttpResponse(o.read(), content_type=getmimetype(path))