Show resource usage based on plan definition.
This commit is contained in:
parent
6520798493
commit
e6dc5cf872
|
@ -0,0 +1,14 @@
|
||||||
|
# allowed resources limit hardcoded because cannot be retrieved from the API.
|
||||||
|
ALLOWED_RESOURCES = {
|
||||||
|
'INDIVIDUAL':
|
||||||
|
{
|
||||||
|
# 'disk': 1024,
|
||||||
|
# 'traffic': 2048,
|
||||||
|
'mailbox': 2,
|
||||||
|
},
|
||||||
|
'ASSOCIATION': {
|
||||||
|
# 'disk': 5 * 1024,
|
||||||
|
# 'traffic': 20 * 1024,
|
||||||
|
'mailbox': 10,
|
||||||
|
}
|
||||||
|
}
|
|
@ -54,8 +54,11 @@
|
||||||
<h4>{% trans "Mail" %}</h4>
|
<h4>{% trans "Mail" %}</h4>
|
||||||
<p class="card-text"><i class="fas fa-envelope fa-3x"></i></p>
|
<p class="card-text"><i class="fas fa-envelope fa-3x"></i></p>
|
||||||
<p class="card-text text-dark">
|
<p class="card-text text-dark">
|
||||||
{{ domain.mails|length }} {% trans "mail addresses created" %}<br/>
|
{{ domain.mails|length }} {% trans "mail addresses created" %}
|
||||||
<span class="text-warning">1 mail address left</span>
|
{% if domain.address_left.alert %}
|
||||||
|
<br/>
|
||||||
|
<span class="text-{{ domain.address_left.alert }}">{{ domain.address_left.count }} mail address left</span>
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
<a class="stretched-link" href="{% url 'musician:mails' %}?domain={{ domain.id }}"></a>
|
<a class="stretched-link" href="{% url 'musician:mails' %}?domain={{ domain.id }}"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,6 +20,7 @@ from .mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
||||||
UserTokenRequiredMixin)
|
UserTokenRequiredMixin)
|
||||||
from .models import (DatabaseService, MailinglistService, MailService,
|
from .models import (DatabaseService, MailinglistService, MailService,
|
||||||
PaymentSource, SaasService, UserAccount)
|
PaymentSource, SaasService, UserAccount)
|
||||||
|
from .settings import ALLOWED_RESOURCES
|
||||||
|
|
||||||
|
|
||||||
class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
|
@ -57,6 +58,22 @@ class DashboardView(CustomContextMixin, UserTokenRequiredMixin, TemplateView):
|
||||||
# TODO(@slamora) update when backend supports notifications
|
# TODO(@slamora) update when backend supports notifications
|
||||||
notifications = []
|
notifications = []
|
||||||
|
|
||||||
|
# show resource usage based on plan definition
|
||||||
|
# TODO(@slamora): validate concept of limits with Pangea
|
||||||
|
profile_type = context['profile'].type
|
||||||
|
for domain in domains:
|
||||||
|
address_left = ALLOWED_RESOURCES[profile_type]['mailbox'] - len(domain.mails)
|
||||||
|
alert = None
|
||||||
|
if address_left == 1:
|
||||||
|
alert = 'warning'
|
||||||
|
elif address_left < 1:
|
||||||
|
alert = 'danger'
|
||||||
|
|
||||||
|
domain.address_left = {
|
||||||
|
'count': address_left,
|
||||||
|
'alert': alert,
|
||||||
|
}
|
||||||
|
|
||||||
context.update({
|
context.update({
|
||||||
'domains': domains,
|
'domains': domains,
|
||||||
'resource_usage': resource_usage,
|
'resource_usage': resource_usage,
|
||||||
|
|
Loading…
Reference in New Issue