diff --git a/core/views_caves.py b/core/views_caves.py index 4a79652..9fcf9b4 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -30,39 +30,39 @@ def caveindex(request): def cave(request, cave_id='', offical_name=''): cave=getCave(cave_id) - if cave.non_public and not request.user.is_authenticated(): + if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): return render_with_context(request,'nonpublic.html', {'instance': cave, 'cavepage': True}) else: return render_with_context(request,'cave.html', {'cave': cave, 'cavepage': True}) def caveEntrance(request, slug): cave = Cave.objects.get(slug = slug) - if cave.non_public and not request.user.is_authenticated(): + if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): return render_with_context(request,'nonpublic.html', {'instance': cave}) else: return render_with_context(request,'cave_entrances.html', {'cave': cave}) def caveDescription(request, slug): cave = Cave.objects.get(slug = slug) - if cave.non_public and not request.user.is_authenticated(): + if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): return render_with_context(request,'nonpublic.html', {'instance': cave}) else: return render_with_context(request,'cave_uground_description.html', {'cave': cave}) def caveQMs(request, slug): cave = Cave.objects.get(slug = slug) - if cave.non_public and not request.user.is_authenticated(): + if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): return render_with_context(request,'nonpublic.html', {'instance': cave}) else: return render_with_context(request,'cave_qms.html', {'cave': cave}) def caveLogbook(request, slug): cave = Cave.objects.get(slug = slug) - if cave.non_public and not request.user.is_authenticated(): + if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): return render_with_context(request,'nonpublic.html', {'instance': cave}) else: return render_with_context(request,'cave_logbook.html', {'cave': cave}) def caveSlug(request, slug): cave = Cave.objects.get(slug = slug) - if cave.non_public and not request.user.is_authenticated(): + if cave.non_public and settings.PUBLIC_SITE and not request.user.is_authenticated(): return render_with_context(request,'nonpublic.html', {'instance': cave}) else: return render_with_context(request,'cave.html', {'cave': cave}) diff --git a/core/views_logbooks.py b/core/views_logbooks.py index 2cf9163..0aee9c6 100644 --- a/core/views_logbooks.py +++ b/core/views_logbooks.py @@ -5,7 +5,7 @@ import troggle.settings as settings import django.db.models from troggle.parsers.logbooks import LoadLogbookForExpedition from troggle.parsers.people import GetPersonExpeditionNameLookup -#from troggle.core.forms import PersonForm, getTripForm, get_name +from troggle.core.forms import getTripForm#, get_name, PersonForm from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, HttpResponse from django.template import Context, loader diff --git a/flatpages/views.py b/flatpages/views.py index e9db223..f46488e 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -15,7 +15,6 @@ import os import re def flatpage(request, path): - print "gggggg", path try: r = Redirect.objects.get(originalURL = path) return HttpResponseRedirect(r.newURL) # Redirect after POST @@ -36,6 +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 return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path) if path.endswith("/") or path == "": @@ -45,29 +45,34 @@ def flatpage(request, path): except IOError: try: o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb") - path = path + "index.html" + path = path + "index.htm" except IOError: - raise Http404 + return render_with_context(request, 'pagenotfound.html', {'path': path}) else: try: o = open(os.path.normpath(settings.EXPOWEB + path), "rb") except IOError: - raise Http404 + return render_with_context(request, 'pagenotfound.html', {'path': path}) if path.endswith(".htm") or path.endswith(".html"): html = o.read() - m = re.search(r"
(.*).*(.*)", html, re.DOTALL) - mwithid = re.search(r'(.*).*(.*)', html, re.DOTALL) + m = re.search(r"(.*).*]*>(.*)", html, re.DOTALL + re.IGNORECASE) if m: head, body = m.groups() - bodyid = None - elif mwithid: - head, bodyid, body = mwithid.groups() else: return HttpResponse(html + "Page could not be split into header and body") + m = re.search(r"