Skip to content
Snippets Groups Projects
Commit 68faf9f2 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Display host creation date and user

Add new jinja2 filter to format datetime
parent a89deccd
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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 %}
......
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment