summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2025-06-25 23:39:41 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2025-06-25 23:39:41 +0300
commitc89e8cea90aa0493cbdecce5c4f9a8bd5dce2c17 (patch)
tree10dcbbea7a3a3a86513e8e54d0dc2547917de0ee
parentc29548db0134d85af56b822dac52502a39d69119 (diff)
downloadtroggle-c89e8cea90aa0493cbdecce5c4f9a8bd5dce2c17.tar.gz
troggle-c89e8cea90aa0493cbdecce5c4f9a8bd5dce2c17.tar.bz2
troggle-c89e8cea90aa0493cbdecce5c4f9a8bd5dce2c17.zip
remaining shared-use machine cookie tyimeouts set
-rw-r--r--core/utils.py5
-rw-r--r--core/views/caves.py4
-rw-r--r--core/views/editor_helpers.py2
-rw-r--r--core/views/expo.py6
-rw-r--r--core/views/survex.py2
-rw-r--r--core/views/uploads.py2
6 files changed, 10 insertions, 11 deletions
diff --git a/core/utils.py b/core/utils.py
index 116e517..3dd1089 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -80,7 +80,7 @@ except:
# Opening of file for writing is going to fail currently, so decide it doesn't matter for now
pass
-def get_cookie_max_age(request=None):
+def get_cookie_max_age(request):
"""This is where we detect whether the machine the user is using is a shared-use device or a personal device.
If it is shared-use, then we set a much shorter cookie timout period.
"""
@@ -314,8 +314,7 @@ def get_git_string(user):
def shared_use_machine(request):
"""Looks for a cookie which only exists on shared use machines
"""
- print(f" - shared use cookie check {request}")
-
+
if not request: # temporary while rolling out implementation to all calling functions
return False
diff --git a/core/views/caves.py b/core/views/caves.py
index b6a9127..856c2cd 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -547,7 +547,7 @@ def edit_cave(request, path="", slug=None):
edit_response = HttpResponseRedirect("/" + cave.url)
else:
edit_response = HttpResponseRedirect(reverse("newentrance", args = [cave.url_parent(), cave.slug()]))
- edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age()) # cookie expires after get_cookie_max_age() seconds
+ edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
try:
cave_file = cave.file_output()
@@ -777,7 +777,7 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
try:
write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}", editor)
edit_response = HttpResponseRedirect("/" + cave.url)
- edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age()) # cookie expires after get_cookie_max_age() seconds
+ edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
return edit_response
except Exception as e:
efilepath, econtent, eencoding = entrance_file
diff --git a/core/views/editor_helpers.py b/core/views/editor_helpers.py
index 28cd936..cfa0fca 100644
--- a/core/views/editor_helpers.py
+++ b/core/views/editor_helpers.py
@@ -410,7 +410,7 @@ def new_image_form(request, path):
)
save_original_in_expofiles(f, year, form.cleaned_data["photographer"], host, image_rel_path, referer)
j_response = JsonResponse({"html": html_snippet})
- j_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age()) # does NOT work updating who_are_you cookie - because it is JsonResponse not HttpResponse.
+ j_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # does NOT work updating who_are_you cookie - because it is JsonResponse not HttpResponse.
return j_response
else:
# print(f"new_image_form(): not POST ")
diff --git a/core/views/expo.py b/core/views/expo.py
index 723f772..a77ecf6 100644
--- a/core/views/expo.py
+++ b/core/views/expo.py
@@ -493,8 +493,8 @@ def editexpopage(request, path):
if not filefound or result != html: # Check if content changed at all
edit_response = HttpResponseRedirect(reverse("expopage", args=[path])) # Redirect after POST
- edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age()) # cookie expires after get_cookie_max_age() seconds
- print(f"Cookie set: {editor} for {get_cookie_max_age()/(3600)} hour(s)")
+ edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
+ print(f"Cookie set: {editor} for {get_cookie_max_age(request)/(3600)} hour(s)")
try:
change_message = pageform.cleaned_data["change_message"]
write_and_commit([(filepath, result, "utf-8")], f"{change_message} - online edit of {path}", editor)
@@ -610,7 +610,7 @@ def edittxtpage(request, path, filepath):
savepath = "/" + path
print(f"redirect {savepath}")
response = redirect(savepath) # Redirect after POST
- response.set_cookie('editor_id', editor, max_age=get_cookie_max_age()) # cookie expires after get_cookie_max_age() seconds
+ response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
return response
else:
diff --git a/core/views/survex.py b/core/views/survex.py
index 230d98f..075c426 100644
--- a/core/views/survex.py
+++ b/core/views/survex.py
@@ -441,7 +441,7 @@ def svx(request, survex_file):
else:
edit_response = render(request, "svxfile.html", vmap)
- edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age() seconds
+ edit_response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
print(f"Cookie reset: {editor} for another {get_cookie_max_age(request)/3600} hour(s)")
return edit_response
diff --git a/core/views/uploads.py b/core/views/uploads.py
index 9e07978..b956480 100644
--- a/core/views/uploads.py
+++ b/core/views/uploads.py
@@ -755,5 +755,5 @@ def dwgupload(request, folder=None, gitdisable="no"):
"who_are_you": editor,
},
)
- response.set_cookie('editor_id', editor, max_age=get_cookie_max_age()) # cookie expires after get_cookie_max_age() seconds
+ response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
return response