diff --git a/musician/models.py b/musician/models.py index 2f43e28..683d7aa 100644 --- a/musician/models.py +++ b/musician/models.py @@ -107,6 +107,7 @@ class UserAccount(OrchestraModel): @classmethod def new_from_json(cls, data, **kwargs): billing = None + last_login = None if 'billcontact' in data: billing = BillingContact.new_from_json(data['billcontact']) diff --git a/musician/templates/musician/dashboard.html b/musician/templates/musician/dashboard.html index 375fbe3..90c8811 100644 --- a/musician/templates/musician/dashboard.html +++ b/musician/templates/musician/dashboard.html @@ -4,7 +4,11 @@ {% block content %}

{% trans "Welcome back" %} {{ profile.username }}

+{% if profile.last_login %}

{% blocktrans with last_login=profile.last_login|date:"SHORT_DATE_FORMAT" %}Last time you logged in was: {{ last_login }}{% endblocktrans %}

+{% else %} +

{% trans "It's the first time you log into the system, welcome on board!" %}

+{% endif %}
{% for resource, usage in resource_usage.items %} diff --git a/musician/tests.py b/musician/tests.py index b25e23a..805ff05 100644 --- a/musician/tests.py +++ b/musician/tests.py @@ -1,5 +1,7 @@ from django.test import TestCase +from .models import UserAccount + class DomainsTestCase(TestCase): def test_domain_not_found(self): @@ -12,3 +14,26 @@ class DomainsTestCase(TestCase): response = self.client.get('/domains/3/') self.assertEqual(404, response.status_code) + + +class UserAccountTest(TestCase): + def test_user_never_logged(self): + data = { + 'billcontact': {'address': 'foo', + 'city': 'Barcelona', + 'country': 'ES', + 'name': '', + 'vat': '12345678Z', + 'zipcode': '08080'}, + 'date_joined': '2020-01-14T12:38:31.684495Z', + 'full_name': 'Pep', + 'id': 2, + 'is_active': True, + 'language': 'EN', + 'short_name': '', + 'type': 'INDIVIDUAL', + 'url': 'http://example.org/api/accounts/2/', + 'username': 'pepe' + } + account = UserAccount.new_from_json(data) + self.assertIsNone(account.last_login)