diff options
Diffstat (limited to 'core/utils.py')
-rw-r--r-- | core/utils.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/core/utils.py b/core/utils.py index 904faad..5ba1b4b 100644 --- a/core/utils.py +++ b/core/utils.py @@ -198,6 +198,13 @@ def parse_aliases(aliasfile): return [(None, None)], "Fail on file reading" return aliases, report +def get_cookie(request): + NO_COOKIE_DEFAULT = 'Höhlenforscher <hohlenforscher@stonebridge.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 + print(f"-- Cookie to be used: {editor=}") + return editor def git_string(author_string): """Rewrites the supplied editor string intoa git-complient author string @@ -207,13 +214,13 @@ def git_string(author_string): author_regex = re.compile(r'^[a-zA-Z][\w\s\_\.\-]* <[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-_]+\.[a-zA-Z]{2,}>$') if author_regex.match(author_string): - print(f"Valid git-compatible author string: '{author_string}'") + print(f"++ Is valid git-compatible author string: '{author_string}'") return author_string else: editor = author_string.replace("@","_at_") editor = re.sub('[^0-9a-zA-Z_\.]+', '*', editor) editor += f" <{editor}@potatohut.expo>" - print(f"Not git-compatible author string, replacing as '{editor}'") + print(f"++ Not git-compatible author string '{author_string}', replacing as '{editor}'") return editor |