mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-13 19:18:16 -06:00
Display the relative time on mouse hover
This commit is contained in:
parent
510f1326e6
commit
c580a5399f
@ -35,15 +35,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Last Login" %}</th>
|
||||
<td>
|
||||
{% if request.user.last_login %}
|
||||
<span title="{{ object.last_login|isodatetime:"minutes" }}">
|
||||
{{ request.user.last_login|timesince }} {% trans "ago" %}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ request.user.last_login|isodatetime:"minutes"|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Superuser" %}</th>
|
||||
|
@ -49,16 +49,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Last used" %}</th>
|
||||
<td>
|
||||
{% if object.last_used %}
|
||||
<span title="{{ object.last_used|isodatetime }}">
|
||||
{{ object.last_used|timesince }}
|
||||
</span>
|
||||
{% trans "ago" %}
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ object.last_used|isodatetime|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Allowed IPs" %}</th>
|
||||
|
@ -1,4 +1,3 @@
|
||||
{% load humanize %}
|
||||
{% load helpers %}
|
||||
{% load log_levels %}
|
||||
{% load i18n %}
|
||||
@ -8,7 +7,7 @@
|
||||
{% if job.started %}
|
||||
{% trans "Started" %}: <strong>{{ job.started|isodatetime }}</strong>
|
||||
{% elif job.scheduled %}
|
||||
{% trans "Scheduled for" %}: <strong>{{ job.scheduled|isodatetime }}</strong> ({{ job.scheduled|naturaltime }})
|
||||
{% trans "Scheduled for" %}: <strong>{{ job.scheduled|isodatetime }}</strong>
|
||||
{% else %}
|
||||
{% trans "Created" %}: <strong>{{ job.created|isodatetime }}</strong>
|
||||
{% endif %}
|
||||
|
@ -51,11 +51,7 @@ Context:
|
||||
{% trans "Created" %} {{ object.created|isodatetime:"minutes" }}
|
||||
{% if object.last_updated %}
|
||||
<span class="separator">·</span>
|
||||
{% trans "Updated" %}
|
||||
<span title="{{ object.last_updated|isodatetime:"minutes" }}">
|
||||
{{ object.last_updated|timesince }}
|
||||
</span>
|
||||
{% trans "ago" %}
|
||||
{% trans "Updated" %} {{ object.last_updated|isodatetime:"minutes" }}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock subtitle %}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% extends 'generic/object.html' %}
|
||||
{% load i18n %}
|
||||
{% load helpers %}
|
||||
{% load i18n %}
|
||||
{% load render_table from django_tables2 %}
|
||||
|
||||
{% block title %}{% trans "Token" %} {{ object }}{% endblock %}
|
||||
@ -37,20 +37,11 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Expires" %}</th>
|
||||
<td>{{ object.expires|isodatetime }}</td>
|
||||
<td>{{ object.expires|isodatetime|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Last used" %}</th>
|
||||
<td>
|
||||
{% if object.last_used %}
|
||||
<span title="{{ object.last_used|isodatetime }}">
|
||||
{{ object.last_used|timesince }}
|
||||
</span>
|
||||
{% trans "ago" %}
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ object.last_used|isodatetime|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Allowed IPs" %}</th>
|
||||
|
@ -31,15 +31,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Last Login" %}</th>
|
||||
<td>
|
||||
{% if object.last_login %}
|
||||
<span title="{{ object.last_login|isodatetime:"minutes" }}">
|
||||
{{ object.last_login|timesince }} {% trans "ago" %}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ ''|placeholder }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ object.last_login|isodatetime:"minutes"|placeholder }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">{% trans "Active" %}</th>
|
||||
|
@ -5,6 +5,7 @@ import re
|
||||
import yaml
|
||||
from django import template
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.humanize.templatetags.humanize import naturaltime
|
||||
from django.utils.html import escape
|
||||
from django.utils.safestring import mark_safe
|
||||
from markdown import markdown
|
||||
@ -214,10 +215,12 @@ def render_yaml(value):
|
||||
@register.filter()
|
||||
def isodate(value):
|
||||
if type(value) is datetime.date:
|
||||
return value.isoformat()
|
||||
if type(value) is datetime.datetime:
|
||||
return value.date().isoformat()
|
||||
return ''
|
||||
text = value.isoformat()
|
||||
elif type(value) is datetime.datetime:
|
||||
text = value.date().isoformat()
|
||||
else:
|
||||
return ''
|
||||
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
|
||||
|
||||
|
||||
@register.filter()
|
||||
@ -232,5 +235,7 @@ def isotime(value, spec='seconds'):
|
||||
@register.filter()
|
||||
def isodatetime(value, spec='seconds'):
|
||||
if type(value) is datetime.datetime:
|
||||
return f'{isodate(value)} {isotime(value, spec=spec)}'
|
||||
return ''
|
||||
text = f'{isodate(value)} {isotime(value, spec=spec)}'
|
||||
else:
|
||||
return ''
|
||||
return mark_safe(f'<span title="{naturaltime(value)}">{text}</span>')
|
||||
|
Loading…
Reference in New Issue
Block a user