2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-03-27 20:31:47 +00:00

make cookie default to empty string - form validation then works

This commit is contained in:
2025-01-17 18:41:54 +00:00
parent d21278c5de
commit c4eb14148a

View File

@@ -205,10 +205,18 @@ def parse_aliases(aliasfile):
return aliases, report
def get_cookie(request):
NO_COOKIE_DEFAULT = 'Unset Cookie <hohlenforscher@potatohut.expo>'
"""The initial idea of having a default turned out to be a bad idea as people just ignore the field.
if the default value is blank, then the form validation code makes the user type something in,
so having a blank is best.
"""
# NO_COOKIE_DEFAULT = 'Unset Cookie <hohlenforscher@potatohut.expo>'
print(f"-- Getting cookie...")
editor_id = request.COOKIES.get('editor_id', NO_COOKIE_DEFAULT) # if no cookie, then default string
editor = git_string(editor_id) # belt and braces, should have been validity checked on saving already
editor_id = request.COOKIES.get('editor_id', "") # if no cookie, then default string ""
if editor_id.startswith("Unset"):
# clean out laziness in users' PCs
editor_id = ""
else:
editor = git_string(editor_id) # belt and braces, should have been validity checked on saving already
print(f"-- Cookie to be used: {editor=}")
return editor