summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2025-01-17 18:41:54 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2025-01-17 18:41:54 +0000
commitc4eb14148ab757645a8824e6da96024ffa3ee192 (patch)
treef55d95056ec6fc01fd985a08c7921aea3f0c1046
parentd21278c5dec14a77130e7c6888d5f54d8467e0ed (diff)
downloadtroggle-c4eb14148ab757645a8824e6da96024ffa3ee192.tar.gz
troggle-c4eb14148ab757645a8824e6da96024ffa3ee192.tar.bz2
troggle-c4eb14148ab757645a8824e6da96024ffa3ee192.zip
make cookie default to empty string - form validation then works
-rw-r--r--core/utils.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/core/utils.py b/core/utils.py
index 50330f1..23d6a85 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -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