2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-02-14 16:19:46 +00:00

refactoring cookie age as a function not a constant

This commit is contained in:
2025-06-14 20:36:31 +03:00
parent d8cdf7bc5a
commit 40fb066e2b
11 changed files with 30 additions and 23 deletions

View File

@@ -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, COOKIE_MAX_AGE
from troggle.core.utils import current_expo, COOKIE_SHORT_TIMEOUT
from troggle.parsers.imports import (
import_caves,
import_drawingsfiles,
@@ -38,9 +38,11 @@ todo = """
def public_laptop(request):
"""Just sets a cookie. Visit this web page from Crowley, Anathema, Aziraphale, Pulsifer etc.
This hack to be replaced in due course by a proper call from a user saying whether they are using a shared machine or not.
"""
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
response = HttpResponse(f"Cookie has been set on this machine, which now defines it as a public laptop. So the login cookie lifetimes will now be short:{COOKIE_SHORT_TIMEOUT/(60*60)} hour(s)")
response.set_cookie("public_laptop", "this is a public laptop", max_age=COOKIE_SHORT_TIMEOUT) # Cookie expires in 1 hour
return response
def todos(request, module):