diff options
Diffstat (limited to 'flatpages')
-rw-r--r-- | flatpages/migrations/0001_initial.py | 4 | ||||
-rw-r--r-- | flatpages/views.py | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/flatpages/migrations/0001_initial.py b/flatpages/migrations/0001_initial.py index c292e88..07d2140 100644 --- a/flatpages/migrations/0001_initial.py +++ b/flatpages/migrations/0001_initial.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.10.8 on 2019-07-14 19:45 +# Generated by Django 1.10.8 on 2020-02-18 16:01 from __future__ import unicode_literals from django.db import migrations, models @@ -11,7 +11,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('core', '0003_auto_20190714_2029'), + ('core', '0001_initial'), ] operations = [ 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 = "" |