diff options
author | Sam Wenham <sam@wenhams.co.uk> | 2020-02-22 15:45:20 +0000 |
---|---|---|
committer | Sam Wenham <sam@wenhams.co.uk> | 2020-02-22 15:45:20 +0000 |
commit | 656ddcfe93061f2f82160ff8cc45b98d27e28bd3 (patch) | |
tree | 5e22bb56363ad7e28e2902bc7637b018706e83e0 /flatpages/views.py | |
parent | 505bc48331035b6fdc9d3ca5f9de77e5a98ba267 (diff) | |
parent | 92b273e45f96ac20fb182b9166b9f0a96f16eba3 (diff) | |
download | troggle-656ddcfe93061f2f82160ff8cc45b98d27e28bd3.tar.gz troggle-656ddcfe93061f2f82160ff8cc45b98d27e28bd3.tar.bz2 troggle-656ddcfe93061f2f82160ff8cc45b98d27e28bd3.zip |
Merge branch 'django-1.10' of ssh://expo.survex.com/~/troggle into django-1.10
Diffstat (limited to 'flatpages/views.py')
-rw-r--r-- | flatpages/views.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/flatpages/views.py b/flatpages/views.py index 6ef2404..0ba4d4e 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -33,7 +33,6 @@ def flatpage(request, path): except EntranceRedirect.DoesNotExist: pass - if path.startswith("noinfo") and settings.PUBLIC_SITE and not request.user.is_authenticated(): print("flat path noinfo", path) return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path) @@ -48,7 +47,7 @@ def flatpage(request, path): path = path + "index.htm" except IOError: return render(request, 'pagenotfound.html', {'path': path}) - else: + else: try: filetobeopened = os.path.normpath(settings.EXPOWEB + path) o = open(filetobeopened, "rb") @@ -56,7 +55,7 @@ def flatpage(request, path): return render(request, 'pagenotfound.html', {'path': path}) if path.endswith(".htm") or path.endswith(".html"): html = o.read() - + m = re.search(r"(.*)<\s*head([^>]*)>(.*)<\s*/head\s*>(.*)<\s*body([^>]*)>(.*)<\s*/body\s*>(.*)", html, re.DOTALL + re.IGNORECASE) if m: preheader, headerattrs, head, postheader, bodyattrs, body, postbody = m.groups() @@ -125,7 +124,7 @@ def editflatpage(request, path): return HttpResponse("Page could not be split into header and body") except IOError: filefound = False - + if request.method == 'POST': # If the form has been submitted... flatpageForm = FlatPageForm(request.POST) # A form bound to the POST data @@ -142,7 +141,7 @@ def editflatpage(request, path): headerargs = "" postheader = "" bodyargs = "" - postbody = "</html>" + postbody = "</html>" body = flatpageForm.cleaned_data["html"] body = body.replace("\r", "") result = u"%s<head%s>%s</head>%s<body%s>\n%s</body>%s" % (preheader, headerargs, head, postheader, bodyargs, body, postbody) @@ -153,7 +152,7 @@ def editflatpage(request, path): else: if filefound: m = re.search(r"<title>(.*)</title>", head, re.DOTALL + re.IGNORECASE) - if m: + if m: title, = m.groups() else: title = "" |