]> WPIA git - motion.git/commitdiff
add: add footer with copyright and legal requirements
authorINOPIAE <m.maengel@inopiae.de>
Fri, 25 Sep 2020 04:44:59 +0000 (06:44 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Tue, 29 Sep 2020 18:51:43 +0000 (20:51 +0200)
check config.py for adjustments

Change-Id: I4795b7b4766d70b8081a60e71ef38e96c207e15c

README.md
config.py.example
motion.py
templates/base.html
tests/test_motion.py

index 6b2618dc7480bbc682954e1c82c4a7d996dd9fff..3e0daca09b6ed1d2dca2b29ab58853b2647402be 100644 (file)
--- 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
 
index 22ee94e57f0b5aee682e29903bd2c8e0e44d9f1e..5bbdb4d9c77b133ac9a4975b156e4e9ee3746194 100644 (file)
@@ -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
index e2f3f15ab28854e27e927f7260615ed3e696b0d7..80ac5a36029eb728e0bf7031fb0404caf0397c8e 100644 (file)
--- 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"))<datetime.now().year:
+        version_year = "%s - %s" % (app.config.get("COPYRIGHTSTART"), datetime.now().year)
+    else:
+        version_year = datetime.now().year
+
+    return dict(
+        footer = dict( version_year=version_year, 
+            copyright_link=app.config.get("COPYRIGHTLINK"),
+            copyright_name=app.config.get("COPYRIGHTNAME"),
+            imprint_link=app.config.get("DATAPROTECTIONLINK"),
+            dataprotection_link=app.config.get("DATAPROTECTIONLINK")
+        )
+    )
+
+
 def get_allowed_cats(action):
     return g.roles.get(action, []);
 
@@ -149,7 +175,6 @@ def init_db():
                 db.prepare("ALTER TABLE \"motion\" ALTER COLUMN \"host\" SET NOT NULL")()
                 db.prepare("UPDATE \"schema_version\" SET \"version\"=3")()
 
-
 init_db()
 
 @app.route("/")
index bd8c265fdb972951257de7ff80e0117c79e35dd3..9d66ff4a749a06a5546c8844f5813e62603fab41 100644 (file)
@@ -56,5 +56,13 @@ form {
 <body>
 {%- block body %}
 {% endblock %}
+<!-- Footer -->
+  <footer class="page-footer">
+    <div class="footer-copyright text-center py-3">
+      <p>© {{footer.version_year}} Copyright: <a href="{{footer.copyright_link}}">{{footer.copyright_name}}</a> 
+      | <a href="{{footer.imprint_link}}">Imprint</a> 
+      | <a href="{{footer.dataprotection_link}}">Data protection</a></p>
+    </div>
+  </footer>
 </body>
 </html>
index 86d69feffb85225be2f60882af14034efd9da82d..1bc65858461318e377cf8660479502895cf80cff 100644 (file)
@@ -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= '<p>A second motion</p></p>\n  </div>\n</div>\n<a href=\"/?start=2#motion-2\" class=\"btn btn-primary\">Back</a>\n</body>'
+        testtext= '<p>A second motion</p></p>\n  </div>\n</div>\n<a href=\"/?start=2#motion-2\" class=\"btn btn-primary\">Back</a>'
         self.assertIn(str.encode(testtext), result.data)
 
     def test_vote(self):