diff --git a/app/factory.py b/app/factory.py index 566091da294e7289707d61a5de5d3dca18733b39..d1f7ae5f5ebe9cfcdcad9ee23d6925105579f768 100644 --- a/app/factory.py +++ b/app/factory.py @@ -27,6 +27,7 @@ from .api.user import bp as user_api from .api.inventory import bp as inventory_api from .api.network import bp as network_api from .commands import register_cli +from . import utils def create_app(config=None): @@ -37,6 +38,8 @@ def create_app(config=None): app.config.from_envvar('LOCAL_SETTINGS', silent=True) app.config.update(config or {}) + app.jinja_env.filters['datetimeformat'] = utils.format_datetime + if not app.debug: import logging # Send ERROR via mail diff --git a/app/templates/network/view_host.html b/app/templates/network/view_host.html index 648932839984d78529575153cad073850197b845..72e97a928eea85de9fe72e0e9d3871d8d6425f3d 100644 --- a/app/templates/network/view_host.html +++ b/app/templates/network/view_host.html @@ -34,6 +34,10 @@ {% endif %} <dt class="col-sm-3">Description</dt> <dd class="col-sm-9">{{ host.description }}</dd> + <dt class="col-sm-3">Created by</dt> + <dd class="col-sm-9">{{ host.user }}</dd> + <dt class="col-sm-3">Created at</dt> + <dd class="col-sm-9">{{ host.created_at | datetimeformat }}</dd> </dl> </div> {% if host.device_type.name.startswith('Virtual') and current_user.is_admin %} diff --git a/app/utils.py b/app/utils.py index 86d9806bc7ec1339978d86babe4e32edcfff106e..bcff931844f7193deda5b73e1d82436066ca7708 100644 --- a/app/utils.py +++ b/app/utils.py @@ -210,3 +210,11 @@ def pluralize(singular): return singular + 's' else: return singular + 'es' + + +def format_datetime(value, format='%Y-%m-%d %H:%M'): + """Format a datetime to string + + Function used as a jinja2 filter + """ + return value.strftime(format)