From 4cc3707ad5461910f5e074d050d48e6659140abc Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 14 Jan 2020 11:28:57 +0100 Subject: [PATCH 1/3] Show if a list is active or not. --- musician/models.py | 6 +----- musician/templates/musician/mailinglists.html | 6 +++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/musician/models.py b/musician/models.py index db3367b..e02844e 100644 --- a/musician/models.py +++ b/musician/models.py @@ -229,6 +229,7 @@ class MailinglistService(OrchestraModel): fields = ('name', 'status', 'address_name', 'admin_email', 'configure') param_defaults = { 'name': None, + 'is_active': True, 'admin_email': None, } @@ -236,11 +237,6 @@ class MailinglistService(OrchestraModel): self.data = kwargs super().__init__(**kwargs) - @property - def status(self): - # TODO(@slamora): where retrieve if the list is active? - return 'active' - @property def address_name(self): return "{}@{}".format(self.data['address_name'], self.data['address_domain']['name']) diff --git a/musician/templates/musician/mailinglists.html b/musician/templates/musician/mailinglists.html index a5f0824..22a1b87 100644 --- a/musician/templates/musician/mailinglists.html +++ b/musician/templates/musician/mailinglists.html @@ -30,7 +30,11 @@ {% for resource in object_list %} {{ resource.name }} - {{ resource.status|capfirst }} + {% if resource.is_active %} + {% trans "Active" %} + {% else %} + {% trans "Inactive" %} + {% endif %} {{ resource.address_name}} {{ resource.admin_email }} Mailtrain From 669600f4da2b46645064a0a5cb50aa93680096b6 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 14 Jan 2020 11:40:42 +0100 Subject: [PATCH 2/3] Show user.last_login on dashboard --- musician/models.py | 7 ++++++- musician/templates/musician/dashboard.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/musician/models.py b/musician/models.py index e02844e..2f43e28 100644 --- a/musician/models.py +++ b/musician/models.py @@ -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): diff --git a/musician/templates/musician/dashboard.html b/musician/templates/musician/dashboard.html index d621e1c..e57fc2d 100644 --- a/musician/templates/musician/dashboard.html +++ b/musician/templates/musician/dashboard.html @@ -4,7 +4,7 @@ {% block content %}

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

-

{% blocktrans with last_login=profile.last_login|default:"N/A" %}Last time you logged in was: {{ last_login }}{% endblocktrans %}

+

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

{% for resource, usage in resource_usage.items %} From a9f23f6ea49f7a08fe62a3a37da9acca5cfebd41 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Tue, 14 Jan 2020 11:45:54 +0100 Subject: [PATCH 3/3] Hide domain.expiration_date (not provided by orchestra) --- musician/templates/musician/dashboard.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/musician/templates/musician/dashboard.html b/musician/templates/musician/dashboard.html index e57fc2d..375fbe3 100644 --- a/musician/templates/musician/dashboard.html +++ b/musician/templates/musician/dashboard.html @@ -46,7 +46,9 @@
+ {% comment "@slamora: orchestra doesn't have this information [won't fix] See issue #2" %} {% trans "Expiration date" %}: {{ domain.expiration_date|date:"SHORT_DATE_FORMAT" }} + {% endcomment %}