From: Felix Dörre Date: Fri, 17 Nov 2017 10:13:01 +0000 (+0100) Subject: chg: crop time at second precision X-Git-Url: https://code.wpia.club/?p=motion.git;a=commitdiff_plain;h=fab51f8d9723fb7095b5f3c4f1af59ad93049fb1 chg: crop time at second precision --- diff --git a/filters.py b/filters.py new file mode 100755 index 0000000..8d76ab9 --- /dev/null +++ b/filters.py @@ -0,0 +1,9 @@ +import flask, jinja2 + +blueprint = flask.Blueprint('filters', __name__) + +# using the decorator +@jinja2.contextfilter +@blueprint.app_template_filter() +def timestamp(context, value): + return value.strftime("%Y-%m-%d %H:%M:%S") diff --git a/motion.py b/motion.py index 9011d37..b74438d 100644 --- a/motion.py +++ b/motion.py @@ -4,6 +4,7 @@ from flask import render_template, redirect from flask import request import postgresql import config +import filters times=[3,5,14] @@ -15,6 +16,9 @@ def get_db(): return db app = Flask(__name__) +app.register_blueprint(filters.blueprint) + + @app.teardown_appcontext def close_connection(exception): @@ -85,4 +89,3 @@ def vote(motion): # TODO cancel running motion (with comment) # TODO authentication/user management -# TODO crop time at second precision diff --git a/templates/motion.html b/templates/motion.html index 687d2a3..6609d20 100644 --- a/templates/motion.html +++ b/templates/motion.html @@ -2,7 +2,9 @@
# {{motion.name}} ({{ 'Running' if motion.running else 'Finished' }}) -
Posed: {{motion.posed}}
Votes until: {{motion.deadline}}
+
+
Posed: {{motion.posed|timestamp}}
+
Votes until: {{motion.deadline|timestamp}}

{{motion.content}}