mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-03-30 06:29:49 +01:00
initial method for identifying potato hut laptops as cookie
This commit is contained in:
@@ -283,7 +283,7 @@ def is_admin_user(user):
|
||||
return False
|
||||
if user.username in ["expoadmin"]:
|
||||
return True
|
||||
if user.is_superuser: # set in parsers/users.py i.e. WOokey, Philip S.
|
||||
if user.is_superuser: # set in parsers/users.py i.e. Wookey, Philip S.
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -426,21 +426,24 @@ def write_binary_file(filepath, content):
|
||||
write_files([(filepath, content, "")]) # null encoding does "wb"
|
||||
|
||||
def ensure_dir_exists(filepath):
|
||||
if filepath.is_dir():
|
||||
raise OSError(
|
||||
f"CANNOT write this file {filepath} as this is an existing DIRECTORY."
|
||||
)
|
||||
try:
|
||||
filepath.parent.mkdir(parents=True, exist_ok=True)
|
||||
# os.makedirs(os.path.dirname(filepath), exist_ok = True)
|
||||
except PermissionError as e:
|
||||
raise PermissionError(
|
||||
f"CANNOT make the directory.\nPERMISSIONS incorrectly set on server for this file {filepath}. Ask a nerd to fix this: {e}"
|
||||
)
|
||||
except Exception as e:
|
||||
raise OSError(
|
||||
f"CANNOT make the directory for {filepath}. Ask a nerd to fix this: {e}"
|
||||
)
|
||||
"""Takes a filepath for a file and all the parent directiories,
|
||||
makes any directories necessary to make the filepath valid
|
||||
"""
|
||||
if filepath.is_dir():
|
||||
raise OSError(
|
||||
f"CANNOT write this file {filepath} as this is an existing DIRECTORY."
|
||||
)
|
||||
try:
|
||||
filepath.parent.mkdir(parents=True, exist_ok=True)
|
||||
# os.makedirs(os.path.dirname(filepath), exist_ok = True)
|
||||
except PermissionError as e:
|
||||
raise PermissionError(
|
||||
f"CANNOT make the directory.\nPERMISSIONS incorrectly set on server for this file {filepath}. Ask a nerd to fix this: {e}"
|
||||
)
|
||||
except Exception as e:
|
||||
raise OSError(
|
||||
f"CANNOT make the directory for {filepath}. Ask a nerd to fix this: {e}"
|
||||
)
|
||||
|
||||
def write_files(files):
|
||||
for filepath, content, encoding in files:
|
||||
@@ -528,6 +531,7 @@ def find_nearest_point(points, target_point):
|
||||
TODO FIND OUT
|
||||
1. is this SRTM data ? TICK. Yes.
|
||||
2. what is the zero altitude datum? Geoid or ellisoid ? Do we need to subtract 47m ??
|
||||
3. remove all these numbers from the .py file as it is confusing the code length calcs
|
||||
|
||||
In our dataset, the survey stations are all within 30m of an srtm reference point.
|
||||
So we can safely ignore points more than 100m away in either x or y directions.
|
||||
|
||||
@@ -11,7 +11,7 @@ from troggle.core.models.logbooks import LogbookEntry, writelogbook # , PersonL
|
||||
|
||||
# from databaseReset import reinit_db # don't do this. databaseRest runs code *at import time*
|
||||
from troggle.core.models.troggle import Expedition
|
||||
from troggle.core.utils import current_expo
|
||||
from troggle.core.utils import current_expo, COOKIE_MAX_AGE
|
||||
from troggle.parsers.imports import (
|
||||
import_caves,
|
||||
import_drawingsfiles,
|
||||
@@ -36,6 +36,12 @@ todo = """
|
||||
to the website.
|
||||
"""
|
||||
|
||||
def public_laptop(request):
|
||||
"""Just sets a cookie. Visit this web page from Crowley, Anathema, Aziraphale, Pulsifer etc.
|
||||
"""
|
||||
response = HttpResponse("Cookie has been set on this machine, which now defines it as a public laptop. So login cookie lifetimes will now be short.")
|
||||
response.set_cookie("public_laptop", "this is a public laptop", max_age=COOKIE_MAX_AGE) # Cookie expires in 1 hour
|
||||
return response
|
||||
|
||||
def todos(request, module):
|
||||
"""produces todo text from module
|
||||
|
||||
Reference in New Issue
Block a user