Show user.last_login on dashboard

This commit is contained in:
Santiago Lamora 2020-01-14 11:40:42 +01:00
parent 4cc3707ad5
commit 669600f4da
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import ast
import logging
from django.utils.dateparse import parse_datetime
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
@ -100,6 +101,7 @@ class UserAccount(OrchestraModel):
'short_name': None,
'full_name': None,
'billing': {},
'last_login': None,
}
@classmethod
@ -108,7 +110,10 @@ class UserAccount(OrchestraModel):
if 'billcontact' in data:
billing = BillingContact.new_from_json(data['billcontact'])
return super().new_from_json(data=data, billing=billing)
if 'last_login' in data:
last_login = parse_datetime(data['last_login'])
return super().new_from_json(data=data, billing=billing, last_login=last_login)
class DatabaseUser(OrchestraModel):

View File

@ -4,7 +4,7 @@
{% block content %}
<h2>{% trans "Welcome back" %} <strong>{{ profile.username }}</strong></h2>
<p>{% blocktrans with last_login=profile.last_login|default:"N/A" %}Last time you logged in was: {{ last_login }}{% endblocktrans %}</p>
<p>{% blocktrans with last_login=profile.last_login|date:"SHORT_DATE_FORMAT" %}Last time you logged in was: {{ last_login }}{% endblocktrans %}</p>
<div class="card-deck">
{% for resource, usage in resource_usage.items %}