forked from expo/troggle
pathlib for path management & cavelist fixes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from django.shortcuts import render, redirect
|
||||
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
||||
@@ -52,15 +53,16 @@ def flatpage(request, path):
|
||||
print(("flat path noinfo", path))
|
||||
return HttpResponseRedirect(reverse("auth_login") + '?next=%s' % request.path)
|
||||
|
||||
expowebpath = Path(settings.EXPOWEB)
|
||||
if path.endswith("/") or path == "":
|
||||
#print(" - FLATPAGES the file: {} ENDSWITH ...".format(path))
|
||||
|
||||
try:
|
||||
o = open(os.path.normpath(settings.EXPOWEB + path + "index.html"), "rb")
|
||||
o = open(os.path.normpath(expowebpath / path / "index.html"), "rb")
|
||||
path = path + "index.html"
|
||||
except IOError:
|
||||
try:
|
||||
o = open(os.path.normpath(settings.EXPOWEB + path + "index.htm"), "rb")
|
||||
o = open(os.path.normpath(expowebpath / path / "index.htm"), "rb")
|
||||
path = path + "index.htm"
|
||||
except IOError:
|
||||
return render(request, 'pagenotfound.html', {'path': path})
|
||||
@@ -77,8 +79,8 @@ def flatpage(request, path):
|
||||
path = path.replace("static", settings.MEDIA_ROOT)
|
||||
filetobeopened = os.path.normpath(path)
|
||||
else:
|
||||
#print(" - NO _ROOT: {} ...".format(settings.EXPOWEB))
|
||||
filetobeopened = os.path.normpath(settings.EXPOWEB + path)
|
||||
#print(" - NO _ROOT: {} ...".format(expowebpath))
|
||||
filetobeopened = os.path.normpath(expowebpath / path)
|
||||
|
||||
#print(" - FLATPAGES full path : {} ...".format(filetobeopened))
|
||||
o = open(filetobeopened, "rb")
|
||||
|
||||
Reference in New Issue
Block a user