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

not found now does 404 & moved login

This commit is contained in:
Philip Sargent
2021-05-03 20:35:35 +01:00
parent 254b465755
commit 9b9f6720e0
8 changed files with 37 additions and 35 deletions

View File

@@ -14,7 +14,7 @@ from django.contrib import admin
import django.forms as forms
from .login import login_required_if_public
from .auth import login_required_if_public
from troggle.core.models.caves import Cave
import troggle.core.views.caves
import troggle.settings as settings
@@ -121,7 +121,7 @@ def expowebpage(request, expowebpath, path):
'''Adds menus and serves an HTML page
'''
if not Path(expowebpath / path).is_file():
return render(request, 'pagenotfound.html', {'path': path})
return render(request, 'pagenotfound.html', {'path': path}, status="404")
with open(os.path.normpath(expowebpath / path), "r") as o:
html = o.read()
@@ -164,9 +164,9 @@ def mediapage(request, subpath=None, doc_root=None):
try:
return HttpResponse(content=open(filetobeopened, "rb"), content_type=getmimetype(subpath))
except IOError:
return render(request, 'pagenotfound.html', {'path': subpath})
return render(request, 'pagenotfound.html', {'path': subpath}, status="404")
else:
return render(request, 'pagenotfound.html', {'path': subpath})
return render(request, 'pagenotfound.html', {'path': subpath}, status="404")
@@ -196,7 +196,7 @@ def expopage(request, path):
if (expowebpath / path / p).is_file():
# This needs to reset the path to the new subdirectory
return HttpResponseRedirect('/'+str(Path(path) / p))
return render(request, 'pagenotfound.html', {'path': Path(path) / "index.html"})
return render(request, 'pagenotfound.html', {'path': Path(path) / "index.html"}, status="404")
if path.endswith("/"):
# we already know it is not a directory.
@@ -210,7 +210,7 @@ def expopage(request, path):
try:
return HttpResponse(content=open(filetobeopened, "rb"), content_type=getmimetype(path))
except IOError:
return render(request, 'pagenotfound.html', {'path': path})
return render(request, 'pagenotfound.html', {'path': path}, status="404")
@@ -310,7 +310,7 @@ def editexpopage(request, path):
git = settings.GIT
with open(filepath, "w") as f:
f.write(result)
print(f'WROTE {cwd}---{filename} ')
#print(f'WROTE {cwd}---{filename} ')
subprocess.call([git, "add", filename], cwd=cwd)
subprocess.call([git, "commit", "-m", 'Edit this page'], cwd=cwd)