diff --git a/.gitmodules b/.gitmodules index 87aa32e6b518e6567d76c90a4664d57d5d8997f4..e0dfa93f6de9f3f2fea1dba5723d7fdb7af28019 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "auth"] +[submodule "common"] path = common url = git@git.fsmpi.rwth-aachen.de:protokollsystem/common-web.git diff --git a/back.py b/back.py deleted file mode 100644 index 8afa00be5a19e22d2688e6bc0c908512dac217a8..0000000000000000000000000000000000000000 --- a/back.py +++ /dev/null @@ -1,35 +0,0 @@ -# This snippet is in public domain. -# However, please retain this link in your sources: -# http://flask.pocoo.org/snippets/120/ -# Danya Alexeyevsky - -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") - - -def anchor(func, cookie=cookie): - @functools.wraps(func) - def result(*args, **kwargs): - session[cookie] = request.url - return func(*args, **kwargs) - return result - - -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 redirect(default=default_view, cookie=cookie, **url_args): - print(request.url, request.url_rule, default, session.get(cookie)) - target = url(default, cookie, **url_args) - if target == request.url: - target = default_url(default, **url_args) - return flask_redirect(target) diff --git a/common b/common index f9dbd00f0a1e413e000e42b968de0f6a0a44558f..3dfc2b71eb6a7e0746fe8794854f739c3305587b 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit f9dbd00f0a1e413e000e42b968de0f6a0a44558f +Subproject commit 3dfc2b71eb6a7e0746fe8794854f739c3305587b diff --git a/decorators.py b/decorators.py index 7057c004aeaa05894f4f5f40568b221daa082473..b7e8c503d09b3434e7165e2ff94b2ec39b5b5535 100644 --- a/decorators.py +++ b/decorators.py @@ -6,7 +6,7 @@ from hmac import compare_digest from models.database import ALL_MODELS from shared import current_user from utils import get_csrf_token -import back +from common import back ID_KEY = "id" KEY_NOT_PRESENT_MESSAGE = "Missing {}_id." diff --git a/server.py b/server.py index 0c9f168d5fd7c5437654e54e408a29a304e67a14..78d228bd5fdb6e3e778723e0e0646fe16930c71d 100755 --- a/server.py +++ b/server.py @@ -55,7 +55,7 @@ from views.tables import ( TodosTable, DocumentsTable, DecisionsTable, TodoTable, ErrorTable, TodoMailsTable, DefaultMetasTable, DecisionCategoriesTable) from legacy import import_old_todos, import_old_protocols, import_old_todomails -import back +from common import back app = Flask(__name__) app.config.from_object(config) diff --git a/shared.py b/shared.py index 450aa05bf08e9ec1c270db5aa8226a39f12c7638..e3fbccb301f203c283f642380e192340d7bd7e74 100644 --- a/shared.py +++ b/shared.py @@ -5,7 +5,7 @@ import re from functools import wraps from enum import Enum -import back +from common import back import config