From fab51f8d9723fb7095b5f3c4f1af59ad93049fb1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Fri, 17 Nov 2017 11:13:01 +0100 Subject: [PATCH] chg: crop time at second precision --- filters.py | 9 +++++++++ motion.py | 5 ++++- templates/motion.html | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 filters.py 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}}

-- 2.39.2