diff --git a/frontends/etiquette_flask/backend/common.py b/frontends/etiquette_flask/backend/common.py index 89879bb..04e4d83 100644 --- a/frontends/etiquette_flask/backend/common.py +++ b/frontends/etiquette_flask/backend/common.py @@ -65,7 +65,11 @@ def decorate_and_route(*route_args, **route_kwargs): # same one multiple times. The _fully_decorated will track that. if not hasattr(endpoint, '_fully_decorated'): endpoint = flasktools.ensure_response_type(endpoint) - endpoint = decorators.give_theme_cookie(endpoint) + endpoint = flasktools.give_theme_cookie( + endpoint, + cookie_name='etiquette_theme', + default_theme='slate', + ) endpoint = decorators.catch_etiquette_exception(endpoint) endpoint = session_manager.give_token(endpoint) diff --git a/frontends/etiquette_flask/backend/decorators.py b/frontends/etiquette_flask/backend/decorators.py index 6dcf4b2..4257ec6 100644 --- a/frontends/etiquette_flask/backend/decorators.py +++ b/frontends/etiquette_flask/backend/decorators.py @@ -24,25 +24,3 @@ def catch_etiquette_exception(function): response = flasktools.json_response(response, status=status) flask.abort(response) return wrapped - -def give_theme_cookie(function): - @functools.wraps(function) - def wrapped(*args, **kwargs): - old_theme = request.cookies.get('etiquette_theme', None) - new_theme = request.args.get('theme', None) - theme = new_theme or old_theme or 'slate' - - request.cookies = werkzeug.datastructures.MultiDict(request.cookies) - request.cookies['etiquette_theme'] = theme - - response = function(*args, **kwargs) - - if new_theme is None: - pass - elif new_theme == '': - response.set_cookie('etiquette_theme', value='', expires=0) - elif new_theme != old_theme: - response.set_cookie('etiquette_theme', value=new_theme, expires=2147483647) - - return response - return wrapped