Commit 82841588 authored by Robin Sonnabend's avatar Robin Sonnabend

Remove unnecessary configurability from

parent 4c0c16f0
......@@ -5,16 +5,15 @@
import functools
from flask import session, request, redirect as flask_redirect, url_for
import config
cookie = getattr(config, "REDIRECT_BACK_COOKIE", "back")
default_view = getattr(config, "REDIRECT_BACK_DEFAULT", "index")
COOKIE_NAME = "back"
DEFAULT_VIEW = "index"
def anchor(func, cookie=cookie):
def anchor(func, COOKIE_NAME=COOKIE_NAME):
def result(*args, **kwargs):
session[cookie] = request.url
session[COOKIE_NAME] = request.url
return func(*args, **kwargs)
return result
......@@ -23,12 +22,12 @@ def default_url(default, **url_args):
return url_for(default, **url_args)
def url(default=default_view, cookie=cookie, **url_args):
return session.get(cookie, default_url(default, **url_args))
def url(default=DEFAULT_VIEW, COOKIE_NAME=COOKIE_NAME, **url_args):
return session.get(COOKIE_NAME, default_url(default, **url_args))
def redirect(default=default_view, cookie=cookie, **url_args):
target = url(default, cookie, **url_args)
def redirect(default=DEFAULT_VIEW, COOKIE_NAME=COOKIE_NAME, **url_args):
target = url(default, COOKIE_NAME, **url_args)
if target == request.url:
target = default_url(default, **url_args)
return flask_redirect(target)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment