From 66a7e727089249cd3eeea99c2aead5fb6a9550ce Mon Sep 17 00:00:00 2001 From: INOPIAE Date: Fri, 25 Sep 2020 06:44:59 +0200 Subject: [PATCH] add: add footer with copyright and legal requirements check config.py for adjustments Change-Id: I4795b7b4766d70b8081a60e71ef38e96c207e15c --- README.md | 2 +- config.py.example | 7 +++++++ motion.py | 27 ++++++++++++++++++++++++++- templates/base.html | 8 ++++++++ tests/test_motion.py | 2 +- 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6b2618d..3e0daca 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ virtualenv -p python3 . . bin/activate pip install -r requirements.txt ``` -Then edit config.py.example into config.py with your database connection +Then edit config.py.example into config.py with your database connection and web site settings ## Development and debug diff --git a/config.py.example b/config.py.example index 22ee94e..5bbdb4d 100644 --- a/config.py.example +++ b/config.py.example @@ -2,6 +2,13 @@ DATABASE="pg://dbserver/db" USER="..." PASSWORD="..." +# Footer data: remove # at beginning of lines and adjust if needed +#COPYRIGHTSTART="2017" +#COPYRIGHTNAME="WPIA" +#COPYRIGHTLINK="https://wpia.club" +#IMPRINTLINK="https://documents.wpia.club/imprint.html" +#DATAPROTECTIONLINK="https://documents.wpia.club/data_privacy_policy_html_pages_en.html" + DEFAULT_HOST="hostname for migration from db version < 2" GROUP_PREFIX={'hostname': {'group1': 'g1', 'group2': 'g2'}} # motion types and their id-prefixes diff --git a/motion.py b/motion.py index e2f3f15..80ac5a3 100644 --- a/motion.py +++ b/motion.py @@ -26,7 +26,16 @@ class EscapeHtml(Extension): md = Markdown(app, extensions=[EscapeHtml()]) +class default_settings(object): + COPYRIGHTSTART="2017" + COPYRIGHTNAME="WPIA" + COPYRIGHTLINK="https://wpia.club" + IMPRINTLINK="https://documents.wpia.club/imprint.html" + DATAPROTECTIONLINK="https://documents.wpia.club/data_privacy_policy_html_pages_en.html" + + # Load config +app.config.from_object('motion.default_settings') app.config.from_pyfile('config.py') @@ -94,6 +103,23 @@ def lookup_user(): g.roles[a[0]].append(val) return None +@app.context_processor +def init_footer_variables(): + if int(app.config.get("COPYRIGHTSTART")) {%- block body %} {% endblock %} + + diff --git a/tests/test_motion.py b/tests/test_motion.py index 86d69fe..1bc6585 100644 --- a/tests/test_motion.py +++ b/tests/test_motion.py @@ -139,7 +139,7 @@ class GeneralTests(BasicTest): def test_basic_results_data_details(self): motion='g1.20200402.002' result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True) - testtext= '

A second motion

\n \n\nBack\n' + testtext= '

A second motion

\n \n\nBack' self.assertIn(str.encode(testtext), result.data) def test_vote(self): -- 2.39.2