Merge branch 'issue2_orchestra_api_review'

Closes #2
This commit is contained in:
Santiago Lamora 2020-01-14 12:23:51 +01:00
commit 10392c0eb5
4 changed files with 16 additions and 9 deletions

View File

@ -2,7 +2,7 @@
Package metadata definition. Package metadata definition.
""" """
VERSION = (0, 1, 0, 'beta', 1) VERSION = (0, 1, 0, 'beta', 2)
def get_version(): def get_version():

View File

@ -1,6 +1,7 @@
import ast import ast
import logging import logging
from django.utils.dateparse import parse_datetime
from django.utils.html import format_html from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -100,6 +101,7 @@ class UserAccount(OrchestraModel):
'short_name': None, 'short_name': None,
'full_name': None, 'full_name': None,
'billing': {}, 'billing': {},
'last_login': None,
} }
@classmethod @classmethod
@ -108,7 +110,10 @@ class UserAccount(OrchestraModel):
if 'billcontact' in data: if 'billcontact' in data:
billing = BillingContact.new_from_json(data['billcontact']) 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): class DatabaseUser(OrchestraModel):
@ -229,6 +234,7 @@ class MailinglistService(OrchestraModel):
fields = ('name', 'status', 'address_name', 'admin_email', 'configure') fields = ('name', 'status', 'address_name', 'admin_email', 'configure')
param_defaults = { param_defaults = {
'name': None, 'name': None,
'is_active': True,
'admin_email': None, 'admin_email': None,
} }
@ -236,11 +242,6 @@ class MailinglistService(OrchestraModel):
self.data = kwargs self.data = kwargs
super().__init__(**kwargs) super().__init__(**kwargs)
@property
def status(self):
# TODO(@slamora): where retrieve if the list is active?
return 'active'
@property @property
def address_name(self): def address_name(self):
return "{}@{}".format(self.data['address_name'], self.data['address_domain']['name']) return "{}@{}".format(self.data['address_name'], self.data['address_domain']['name'])

View File

@ -4,7 +4,7 @@
{% block content %} {% block content %}
<h2>{% trans "Welcome back" %} <strong>{{ profile.username }}</strong></h2> <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"> <div class="card-deck">
{% for resource, usage in resource_usage.items %} {% for resource, usage in resource_usage.items %}
@ -46,7 +46,9 @@
</button> </button>
</div> </div>
<div class="col-md text-right"> <div class="col-md text-right">
{% comment "@slamora: orchestra doesn't have this information [won't fix] See issue #2" %}
{% trans "Expiration date" %}: <strong>{{ domain.expiration_date|date:"SHORT_DATE_FORMAT" }}</strong> {% trans "Expiration date" %}: <strong>{{ domain.expiration_date|date:"SHORT_DATE_FORMAT" }}</strong>
{% endcomment %}
</div> </div>
</div> </div>
</div><!-- /card-header--> </div><!-- /card-header-->

View File

@ -30,7 +30,11 @@
{% for resource in object_list %} {% for resource in object_list %}
<tr> <tr>
<th scope="row">{{ resource.name }}</th> <th scope="row">{{ resource.name }}</th>
<td class="text-primary font-weight-bold">{{ resource.status|capfirst }}</td> {% if resource.is_active %}
<td class="text-primary font-weight-bold">{% trans "Active" %}</td>
{% else %}
<td class="text-danger font-weight-bold">{% trans "Inactive" %}</td>
{% endif %}
<td>{{ resource.address_name}}</td> <td>{{ resource.address_name}}</td>
<td>{{ resource.admin_email }}</td> <td>{{ resource.admin_email }}</td>
<td><a href="#TODO-{{ resource.manager_url }}" target="_blank" rel="noopener noreferrer">Mailtrain</a></td> <td><a href="#TODO-{{ resource.manager_url }}" target="_blank" rel="noopener noreferrer">Mailtrain</a></td>