2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-15 03:27:26 +00:00

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
This commit is contained in:
Sam Wenham
2019-02-23 15:30:58 +00:00
parent f58b1db920
commit a1f02e575f
10 changed files with 77 additions and 18 deletions

View File

@@ -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))