mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 08:07:07 +00:00
remaining shared-use machine cookie tyimeouts set
This commit is contained in:
@@ -80,7 +80,7 @@ except:
|
|||||||
# Opening of file for writing is going to fail currently, so decide it doesn't matter for now
|
# Opening of file for writing is going to fail currently, so decide it doesn't matter for now
|
||||||
pass
|
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.
|
"""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.
|
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):
|
def shared_use_machine(request):
|
||||||
"""Looks for a cookie which only exists on shared use machines
|
"""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
|
if not request: # temporary while rolling out implementation to all calling functions
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -547,7 +547,7 @@ def edit_cave(request, path="", slug=None):
|
|||||||
edit_response = HttpResponseRedirect("/" + cave.url)
|
edit_response = HttpResponseRedirect("/" + cave.url)
|
||||||
else:
|
else:
|
||||||
edit_response = HttpResponseRedirect(reverse("newentrance", args = [cave.url_parent(), cave.slug()]))
|
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:
|
try:
|
||||||
cave_file = cave.file_output()
|
cave_file = cave.file_output()
|
||||||
@@ -777,7 +777,7 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
|
|||||||
try:
|
try:
|
||||||
write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}", editor)
|
write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}", editor)
|
||||||
edit_response = HttpResponseRedirect("/" + cave.url)
|
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
|
return edit_response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
efilepath, econtent, eencoding = entrance_file
|
efilepath, econtent, eencoding = entrance_file
|
||||||
|
|||||||
@@ -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)
|
save_original_in_expofiles(f, year, form.cleaned_data["photographer"], host, image_rel_path, referer)
|
||||||
j_response = JsonResponse({"html": html_snippet})
|
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
|
return j_response
|
||||||
else:
|
else:
|
||||||
# print(f"new_image_form(): not POST ")
|
# print(f"new_image_form(): not POST ")
|
||||||
|
|||||||
@@ -493,8 +493,8 @@ def editexpopage(request, path):
|
|||||||
|
|
||||||
if not filefound or result != html: # Check if content changed at all
|
if not filefound or result != html: # Check if content changed at all
|
||||||
edit_response = HttpResponseRedirect(reverse("expopage", args=[path])) # Redirect after POST
|
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
|
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()/(3600)} hour(s)")
|
print(f"Cookie set: {editor} for {get_cookie_max_age(request)/(3600)} hour(s)")
|
||||||
try:
|
try:
|
||||||
change_message = pageform.cleaned_data["change_message"]
|
change_message = pageform.cleaned_data["change_message"]
|
||||||
write_and_commit([(filepath, result, "utf-8")], f"{change_message} - online edit of {path}", editor)
|
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
|
savepath = "/" + path
|
||||||
print(f"redirect {savepath}")
|
print(f"redirect {savepath}")
|
||||||
response = redirect(savepath) # Redirect after POST
|
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
|
return response
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ def svx(request, survex_file):
|
|||||||
else:
|
else:
|
||||||
edit_response = render(request, "svxfile.html", vmap)
|
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)")
|
print(f"Cookie reset: {editor} for another {get_cookie_max_age(request)/3600} hour(s)")
|
||||||
|
|
||||||
return edit_response
|
return edit_response
|
||||||
|
|||||||
@@ -755,5 +755,5 @@ def dwgupload(request, folder=None, gitdisable="no"):
|
|||||||
"who_are_you": editor,
|
"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
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user