From f023cb21c7de8f87a4a8c4da3d4f04a48af72a6d Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Wed, 22 Jan 2020 12:53:12 +0100 Subject: [PATCH 1/7] Add managers URLs as musician settings. --- musician/settings.py | 47 +++++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/musician/settings.py b/musician/settings.py index 5581061..abc538a 100644 --- a/musician/settings.py +++ b/musician/settings.py @@ -1,14 +1,37 @@ -# allowed resources limit hardcoded because cannot be retrieved from the API. -ALLOWED_RESOURCES = { - 'INDIVIDUAL': - { - # 'disk': 1024, - # 'traffic': 2048, - 'mailbox': 2, +from django.conf import settings + + +def getsetting(name): + return getattr(settings, name, DEFAULTS.get(name)) + + +DEFAULTS = { + # 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, + } }, - 'ASSOCIATION': { - # 'disk': 5 * 1024, - # 'traffic': 20 * 1024, - 'mailbox': 10, - } + "URL_DB_PHPMYADMIN": "https://www.phpmyadmin.net/", + "URL_MAILTRAIN": "https://mailtrain.org/", + "URL_SAAS_WORDPRESS": "https://wordpress.org/", + "URL_SAAS_GITLAB": "https://gitlab.org/", } + +ALLOWED_RESOURCES = getsetting("ALLOWED_RESOURCES") + +URL_DB_PHPMYADMIN = getsetting("URL_DB_PHPMYADMIN") + +URL_MAILTRAIN = getsetting("URL_MAILTRAIN") + +URL_SAAS_WORDPRESS = getsetting("URL_SAAS_WORDPRESS") + +URL_SAAS_GITLAB = getsetting("URL_SAAS_GITLAB") From 09c16ab2ae04d9407fec353e033cb446773399ed Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Wed, 22 Jan 2020 13:03:23 +0100 Subject: [PATCH 2/7] Set mailtrain URL. --- musician/models.py | 7 ++++--- musician/templates/musician/mailinglists.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/musician/models.py b/musician/models.py index aa3ebd4..44bc731 100644 --- a/musician/models.py +++ b/musician/models.py @@ -5,6 +5,8 @@ from django.utils.dateparse import parse_datetime from django.utils.html import format_html from django.utils.translation import gettext_lazy as _ +from . import settings as musician_settings + logger = logging.getLogger(__name__) @@ -249,9 +251,8 @@ class MailinglistService(OrchestraModel): return "{}@{}".format(self.data['address_name'], self.data['address_domain']['name']) @property - def configure(self): - # TODO(@slamora): build mailtran absolute URL - return format_html('Mailtrain') + def manager_url(self): + return musician_settings.URL_MAILTRAIN class SaasService(OrchestraModel): diff --git a/musician/templates/musician/mailinglists.html b/musician/templates/musician/mailinglists.html index 22a1b87..d02f4b7 100644 --- a/musician/templates/musician/mailinglists.html +++ b/musician/templates/musician/mailinglists.html @@ -37,7 +37,7 @@ {% endif %} {{ resource.address_name}} {{ resource.admin_email }} - Mailtrain + Mailtrain {% endfor %} From 4da403c4aa6f58223c629b97090829a04e511d30 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 23 Jan 2020 16:12:40 +0100 Subject: [PATCH 3/7] Add OwnCloud manager url. --- musician/settings.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/musician/settings.py b/musician/settings.py index abc538a..ca9b560 100644 --- a/musician/settings.py +++ b/musician/settings.py @@ -22,8 +22,9 @@ DEFAULTS = { }, "URL_DB_PHPMYADMIN": "https://www.phpmyadmin.net/", "URL_MAILTRAIN": "https://mailtrain.org/", - "URL_SAAS_WORDPRESS": "https://wordpress.org/", "URL_SAAS_GITLAB": "https://gitlab.org/", + "URL_SAAS_OWNCLOUD": "https://owncloud.org/", + "URL_SAAS_WORDPRESS": "https://wordpress.org/", } ALLOWED_RESOURCES = getsetting("ALLOWED_RESOURCES") @@ -32,6 +33,8 @@ URL_DB_PHPMYADMIN = getsetting("URL_DB_PHPMYADMIN") URL_MAILTRAIN = getsetting("URL_MAILTRAIN") -URL_SAAS_WORDPRESS = getsetting("URL_SAAS_WORDPRESS") - URL_SAAS_GITLAB = getsetting("URL_SAAS_GITLAB") + +URL_SAAS_OWNCLOUD = getsetting("URL_SAAS_OWNCLOUD") + +URL_SAAS_WORDPRESS = getsetting("URL_SAAS_WORDPRESS") From d05c61defff9105431c5553aa1eed74b6411e09e Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 23 Jan 2020 16:13:23 +0100 Subject: [PATCH 4/7] Include link to SaaS service manager. --- musician/models.py | 11 +++++++++++ musician/templates/musician/saas.html | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/musician/models.py b/musician/models.py index 44bc731..a0c058f 100644 --- a/musician/models.py +++ b/musician/models.py @@ -267,6 +267,17 @@ class SaasService(OrchestraModel): } + @property + def manager_url(self): + URLS = { + 'gitlab': musician_settings.URL_SAAS_GITLAB, + 'owncloud': musician_settings.URL_SAAS_OWNCLOUD, + 'wordpress': musician_settings.URL_SAAS_WORDPRESS, + } + + return URLS.get(self.service, '#none') + + class WebSite(OrchestraModel): api_name = 'website' param_defaults = { diff --git a/musician/templates/musician/saas.html b/musician/templates/musician/saas.html index cff1e83..4da034f 100644 --- a/musician/templates/musician/saas.html +++ b/musician/templates/musician/saas.html @@ -34,7 +34,7 @@ From a71654cc5cedf9e5ed5d546cf1961c9e86c397e7 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 23 Jan 2020 16:14:18 +0100 Subject: [PATCH 5/7] Fix typo on variable name. Regression by 6980522d811e2ff9ff5e0be7e12c54a0863a5ba8 --- musician/templates/musician/dashboard.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/musician/templates/musician/dashboard.html b/musician/templates/musician/dashboard.html index 7988f31..69c9239 100644 --- a/musician/templates/musician/dashboard.html +++ b/musician/templates/musician/dashboard.html @@ -66,9 +66,9 @@

{{ domain.mails|length }} {% trans "mail addresses created" %} - {% if domain.address_left.alert_level %} + {% if domain.addresses_left.alert_level %}
- {{ domain.address_left.count }} mail address left + {{ domain.addresses_left.count }} mail address left {% endif %}

From 9060bc1590f764c34afea48edc779b14b4984877 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 23 Jan 2020 16:16:21 +0100 Subject: [PATCH 6/7] Add external-link icon to Mailtrain anchor. --- musician/templates/musician/mailinglists.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/musician/templates/musician/mailinglists.html b/musician/templates/musician/mailinglists.html index d02f4b7..6ff509e 100644 --- a/musician/templates/musician/mailinglists.html +++ b/musician/templates/musician/mailinglists.html @@ -37,7 +37,7 @@ {% endif %} {{ resource.address_name}} {{ resource.admin_email }} - Mailtrain + Mailtrain {% endfor %} From 672b3298a76afb3807bfd5120a52bf4d1dd371b2 Mon Sep 17 00:00:00 2001 From: Santiago Lamora Date: Thu, 23 Jan 2020 16:32:36 +0100 Subject: [PATCH 7/7] Allow to configure managers URLs on project settings. --- musician/settings.py | 3 ++- userpanel/settings.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/musician/settings.py b/musician/settings.py index ca9b560..7dab46f 100644 --- a/musician/settings.py +++ b/musician/settings.py @@ -2,7 +2,8 @@ from django.conf import settings def getsetting(name): - return getattr(settings, name, DEFAULTS.get(name)) + value = getattr(settings, name, None) + return value or DEFAULTS.get(name) DEFAULTS = { diff --git a/userpanel/settings.py b/userpanel/settings.py index 4d45a17..d14b228 100644 --- a/userpanel/settings.py +++ b/userpanel/settings.py @@ -147,3 +147,15 @@ STATIC_ROOT = config('STATIC_ROOT') # Backend API configuration API_BASE_URL = config('API_BASE_URL') + + +# External services URLs +URL_DB_PHPMYADMIN = config('URL_DB_PHPMYADMIN', None) + +URL_MAILTRAIN = config('URL_MAILTRAIN', None) + +URL_SAAS_GITLAB = config('URL_SAAS_GITLAB', None) + +URL_SAAS_OWNCLOUD = config('URL_SAAS_OWNCLOUD', None) + +URL_SAAS_WORDPRESS = config('URL_SAAS_WORDPRESS', None)