]> WPIA git - motion.git/commitdiff
Merge branch 'fix_typo' into 'master'
authorFelix Dörre <felix@dogcraft.de>
Mon, 5 Oct 2020 12:24:39 +0000 (14:24 +0200)
committerFelix Dörre <felix@dogcraft.de>
Mon, 5 Oct 2020 12:24:39 +0000 (14:24 +0200)
fix: add missing colon in text

See merge request felixdoerre/motion!20

README.md
config.py.example
jenkins_job.py [new file with mode: 0644]
motion.py
requirements.txt
templates/base.html
tests/test_motion.py

index fa02a3b55dff59ab9d35c2f35a0b54a5f831f4fd..e06c09e865173400a41156b66c1d2ea491c9761c 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
 
@@ -103,3 +103,79 @@ fastcgi_param USER_ROLES $motion_user_role;
 fastcgi_pass unix:/motion-socket/motion.fcgi;
 }
 ```
+
+# Configuration for a Jenkins Freestyle Project
+
+## Preconditions for Jenkins system
+
+* Python 3 installed with:
+
+  python3 virtualenv python3-pip
+
+* PostgreSQL server installed with motion database and database user
+
+
+## Add freestyle project
+
+### Source-Code-Management
+
+Adjust Git settings
+
+### Build Environment
+
+Add Bindings
+
+Add Username and password (separated)
+
+Enter username (DB_USER) and password (DB_PW) according to database credentials
+
+### Build
+
+Add build step shell
+
+Add the command
+
+```
+rm -rf env
+virtualenv -p python3 env
+. env/bin/activate
+pip3 install -r requirements.txt
+
+
+cat > config.py << EOF
+DATABASE="pq://IP-ADDRESS/motion"
+USER="${DB_USER}"
+PASSWORD="${DB_PW}"
+EOF
+
+python3 jenkins_job.py
+```
+
+If an IPv6 address is used the following needs to be added to the script to fix a bug of the IPv6 literal translation:
+(https://github.com/python-postgres/fe/issues/104)
+
+```
+patch env/lib/python3*/site-packages/postgresql/versionstring.py <<EOF
+diff --git a/postgresql/versionstring.py b/postgresql/versionstring.py
+index ccb3953..2503013 100644
+--- a/postgresql/versionstring.py
++++ b/postgresql/versionstring.py
+@@ -15,7 +15,7 @@ def split(vstr : str) -> (
+    Split a PostgreSQL version string into a tuple
+    (major,minor,patch,...,state_class,state_level)
+    """
+-   v = vstr.strip().split('.')
++   v = vstr.strip().split(' ')[0].split('.')
+    # Get rid of the numbers around the state_class (beta,a,dev,alpha, etc)
+    state_class = v[-1].strip('0123456789')
+EOF
+```
+
+### Post build actions
+
+Add Publish JUnit test result report - test report XMLs
+
+```
+python_tests_xml/*
+```
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
diff --git a/jenkins_job.py b/jenkins_job.py
new file mode 100644 (file)
index 0000000..56dc831
--- /dev/null
@@ -0,0 +1,13 @@
+import unittest
+import xmlrunner
+
+def runner(output='python_tests_xml'):
+    return xmlrunner.XMLTestRunner(
+        output=output
+    )
+
+def find_tests():
+    return unittest.TestLoader().discover('tests', 'test_motion.py')
+
+if __name__ == "__main__":
+    runner().run(find_tests())
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 7bfcb1f7c2fe01cbdc7b0bce1d3887dd00b4d3a6..0713e61650a17e769757df9b9d33dad7e936d675 100644 (file)
@@ -6,3 +6,4 @@ MarkupSafe==1.0
 py-postgresql==1.2.1
 Werkzeug==0.12.2
 Flask-Markdown==0.3
+xmlrunner>=1.7.7
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):