Compare commits

..

3 Commits

12 changed files with 179 additions and 53 deletions

View File

@ -30,7 +30,7 @@ API_PATHS = {
'mailbox-detail': 'mailboxes/{pk}/', 'mailbox-detail': 'mailboxes/{pk}/',
'mailbox-password': 'mailboxes/{pk}/set_password/', 'mailbox-password': 'mailboxes/{pk}/set_password/',
'mailinglist-list': 'lists/', 'mailinglist-list': 'lists/',
'saas-list': 'saas/', # 'saas-list': 'saas/',
'website-list': 'websites/', 'website-list': 'websites/',
# other # other

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-08 10:19+0000\n" "POT-Creation-Date: 2024-11-18 10:57+0000\n"
"PO-Revision-Date: 2021-11-25 12:53+0100\n" "PO-Revision-Date: 2021-11-25 12:53+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -30,19 +30,19 @@ msgstr "No trobem cap objecte que coincideixi amb la teva consulta"
msgid "No mailbox found matching the query" msgid "No mailbox found matching the query"
msgstr "No trobem cap bústia que coincideixi amb la teva consulta" msgstr "No trobem cap bústia que coincideixi amb la teva consulta"
#: forms.py:42 forms.py:111 #: forms.py:42 forms.py:111 saas/forms.py:100
msgid "The two password fields didnt match." msgid "The two password fields didnt match."
msgstr "Les contrasenyes introduïdes no coincideixen." msgstr "Les contrasenyes introduïdes no coincideixen."
#: forms.py:45 forms.py:115 #: forms.py:45 forms.py:115 saas/forms.py:103
msgid "Password" msgid "Password"
msgstr "Contrasenya" msgstr "Contrasenya"
#: forms.py:50 forms.py:120 #: forms.py:50 forms.py:120 saas/forms.py:108
msgid "Password confirmation" msgid "Password confirmation"
msgstr "Confirma la contrasenya" msgstr "Confirma la contrasenya"
#: forms.py:53 forms.py:123 #: forms.py:53 forms.py:123 saas/forms.py:111
msgid "Enter the same password as before, for verification." msgid "Enter the same password as before, for verification."
msgstr "Introdueix la mateixa contrasenya per verificar-la." msgstr "Introdueix la mateixa contrasenya per verificar-la."
@ -141,57 +141,60 @@ msgstr ""
"Si tens algun servei SaaS (Software as a Service) contractat, aquí trobaràs " "Si tens algun servei SaaS (Software as a Service) contractat, aquí trobaràs "
"els seus detalls de configuració." "els seus detalls de configuració."
#: saas/forms.py:16 #: saas/forms.py:17
msgid "Site URL" msgid "Site URL"
msgstr "" msgstr ""
#: saas/forms.py:50 #: saas/forms.py:51
msgid "" msgid ""
"ID of this blog used by WordPress, the only attribute that doesn't change." "ID of this blog used by WordPress, the only attribute that doesn't change."
msgstr "" msgstr ""
"ID d'aquest blog utilitzat per WordPress, l'únic atribut que no canvia." "ID d'aquest blog utilitzat per WordPress, l'únic atribut que no canvia."
#: saas/forms.py:51 templates/musician/address_list.html:25 #: saas/forms.py:52 templates/musician/address_list.html:25
msgid "Email" msgid "Email"
msgstr "Correu electrònic" msgstr "Correu electrònic"
#: saas/forms.py:52 #: saas/forms.py:53
msgid "" msgid ""
"A new user will be created if the above email address is not in the database." "A new user will be created if the above email address is not in the database."
"<br>The username and password will be mailed to this email address." "<br>The username and password will be mailed to this email address."
msgstr "" msgstr ""
"Es crearà un nou usuari si l'adreça de correu electrònic anterior no és a la base de dades." "Es crearà un nou usuari si l'adreça de correu electrònic anterior no és a la "
"<br>El nom d'usuari i la contrasenya s'enviaran a aquesta adreça de correu electrònic." "base de dades.<br>El nom d'usuari i la contrasenya s'enviaran a aquesta "
"adreça de correu electrònic."
#: saas/forms.py:89 #: saas/forms.py:90 saas/forms.py:124
#, python-format #, python-format
msgid "Suggestion: %s" msgid "Suggestion: %s"
msgstr "Suggerimet: %s" msgstr "Suggerimet: %s"
#. Translators: This message appears on the page title #. Translators: This message appears on the page title
#: saas/views.py:24 saas/views.py:38 templates/musician/domain_list.html:51 #: saas/views.py:26 saas/views.py:40 templates/musician/domain_list.html:51
msgid "Software as a Service" msgid "Software as a Service"
msgstr "Software as a Service" msgstr "Software as a Service"
#: saas/views.py:25 #: saas/views.py:27
msgid "Nextcloud Service" msgid "Nextcloud Service"
msgstr "Servei Nextcloud" msgstr "Servei Nextcloud"
#: saas/views.py:26 #: saas/views.py:28
msgid "Members can manage their Nextcloud users in this section." msgid "Members can manage their Nextcloud users in this section."
msgstr "Els socis/ies poden gestionar els seus usuaris de Nextcloud en aquesta secció." msgstr ""
"Els socis/ies poden gestionar els seus usuaris de Nextcloud en aquesta "
"secció."
#: saas/views.py:39 #: saas/views.py:41
msgid "Community WordPress" msgid "Community WordPress"
msgstr "WordPress comunitari" msgstr "WordPress comunitari"
#: saas/views.py:40 #: saas/views.py:42
msgid "" msgid ""
"Pangea's multisite WordPress service. Members can have their WordPress on " "Pangea's multisite WordPress service. Members can have their WordPress on "
"this community WordPress hosted and maintained by Pangea." "this community WordPress hosted and maintained by Pangea."
msgstr "" msgstr ""
"Servei de Wordpress multisite de Pangea. " "Servei de Wordpress multisite de Pangea. Els socis/ies poden tenir el seu WP "
"Els socis/ies poden tenir el seu WP en aquest WP comunitari alltijat i mantigut per Pangea." "en aquest WP comunitari alltijat i mantigut per Pangea."
#: templates/auth/login.html:59 #: templates/auth/login.html:59
msgid "Log in" msgid "Log in"
@ -241,7 +244,7 @@ msgstr "AVÍS: Aquesta acció es irreversible."
#: templates/musician/record_check_delete.html:11 #: templates/musician/record_check_delete.html:11
#: templates/musician/record_form.html:16 #: templates/musician/record_form.html:16
#: templates/musician/saas_check_delete.html:9 #: templates/musician/saas_check_delete.html:9
#: templates/musician/saas_nextcloud_form.html:30 #: templates/musician/saas_nextcloud_form.html:36
#: templates/musician/saas_wordpress_form.html:31 #: templates/musician/saas_wordpress_form.html:31
#: templates/musician/systemuser_change_password.html:11 #: templates/musician/systemuser_change_password.html:11
#: templates/musician/webapps/webapp_form.html:11 #: templates/musician/webapps/webapp_form.html:11
@ -263,7 +266,7 @@ msgstr "Cancel·lar"
#: templates/musician/record_check_delete.html:10 #: templates/musician/record_check_delete.html:10
#: templates/musician/record_form.html:20 #: templates/musician/record_form.html:20
#: templates/musician/saas_check_delete.html:10 #: templates/musician/saas_check_delete.html:10
#: templates/musician/saas_nextcloud_form.html:35 #: templates/musician/saas_nextcloud_form.html:41
#: templates/musician/saas_wordpress_form.html:35 #: templates/musician/saas_wordpress_form.html:35
#: templates/musician/webapps/webapp_form.html:15 #: templates/musician/webapps/webapp_form.html:15
#: templates/musician/webapps/webappoption_check_delete.html:10 #: templates/musician/webapps/webappoption_check_delete.html:10
@ -277,7 +280,7 @@ msgstr "Esborrar"
#: templates/musician/mailinglist_form.html:31 #: templates/musician/mailinglist_form.html:31
#: templates/musician/nextcloud_change_password.html:12 #: templates/musician/nextcloud_change_password.html:12
#: templates/musician/record_form.html:17 #: templates/musician/record_form.html:17
#: templates/musician/saas_nextcloud_form.html:31 #: templates/musician/saas_nextcloud_form.html:37
#: templates/musician/saas_wordpress_form.html:32 #: templates/musician/saas_wordpress_form.html:32
#: templates/musician/systemuser_change_password.html:12 #: templates/musician/systemuser_change_password.html:12
#: templates/musician/webapps/webapp_form.html:12 #: templates/musician/webapps/webapp_form.html:12
@ -567,7 +570,7 @@ msgstr "Adreces de correu"
#: templates/musician/mailbox_change_password.html:5 #: templates/musician/mailbox_change_password.html:5
#: templates/musician/mailbox_form.html:24 #: templates/musician/mailbox_form.html:24
#: templates/musician/nextcloud_change_password.html:5 #: templates/musician/nextcloud_change_password.html:5
#: templates/musician/saas_nextcloud_form.html:34 #: templates/musician/saas_nextcloud_form.html:40
#: templates/musician/systemuser_change_password.html:5 #: templates/musician/systemuser_change_password.html:5
#: templates/musician/webapps/webappuser_change_password.html:5 #: templates/musician/webapps/webappuser_change_password.html:5
msgid "Change password" msgid "Change password"
@ -585,6 +588,7 @@ msgstr ""
"Tots els missatges <strong>s'esborraran i no es podran recuperar</strong>." "Tots els missatges <strong>s'esborraran i no es podran recuperar</strong>."
#: templates/musician/mailbox_form.html:9 #: templates/musician/mailbox_form.html:9
#: templates/musician/saas_nextcloud_form.html:28
msgid "Warning!" msgid "Warning!"
msgstr "Atenció!" msgstr "Atenció!"
@ -739,10 +743,23 @@ msgstr "Actualitzar SaaS"
#: templates/musician/saas_nextcloud_form.html:22 #: templates/musician/saas_nextcloud_form.html:22
#: templates/musician/saas_wordpress_form.html:22 #: templates/musician/saas_wordpress_form.html:22
msgid "Create SaaS" msgid "Create SaaS"
msgstr "Crear SaaS" msgstr "Crear SaaS"
#: templates/musician/saas_nextcloud_form.html:28
msgid ""
"You have reached the limit of Nextcloud users of your subscription so "
"<strong>extra fees</strong> may apply."
msgstr ""
"Has assolit el límit d'usuaris Nextcloud de la teva subscripció, els nous "
"usuaris poden implicar <strong>costos addicionals</strong>."
#: templates/musician/saas_nextcloud_list.html:57
#, fuzzy
#| msgid "SFTP user"
msgid "New user"
msgstr "Usuari SFTP"
#: templates/musician/systemuser_list.html:6 #: templates/musician/systemuser_list.html:6
msgid "" msgid ""
"The main user is your system's main user on each server. You'll be able to " "The main user is your system's main user on each server. You'll be able to "

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-08 09:37+0000\n" "POT-Creation-Date: 2024-11-18 11:01+0000\n"
"PO-Revision-Date: 2021-11-25 12:53+0100\n" "PO-Revision-Date: 2021-11-25 12:53+0100\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -30,19 +30,19 @@ msgstr "No hay objetos que coincidan con tu búsqueda"
msgid "No mailbox found matching the query" msgid "No mailbox found matching the query"
msgstr "No hay buzones de correo que coincidan con tu búsqueda" msgstr "No hay buzones de correo que coincidan con tu búsqueda"
#: forms.py:42 forms.py:111 #: forms.py:42 forms.py:111 saas/forms.py:100
msgid "The two password fields didnt match." msgid "The two password fields didnt match."
msgstr "Las contraseñas introducidas no coinciden." msgstr "Las contraseñas introducidas no coinciden."
#: forms.py:45 forms.py:115 #: forms.py:45 forms.py:115 saas/forms.py:103
msgid "Password" msgid "Password"
msgstr "Contraseña" msgstr "Contraseña"
#: forms.py:50 forms.py:120 #: forms.py:50 forms.py:120 saas/forms.py:108
msgid "Password confirmation" msgid "Password confirmation"
msgstr "Confirma la contraseña" msgstr "Confirma la contraseña"
#: forms.py:53 forms.py:123 #: forms.py:53 forms.py:123 saas/forms.py:111
msgid "Enter the same password as before, for verification." msgid "Enter the same password as before, for verification."
msgstr "Introduce la misma contraseña para verificarla" msgstr "Introduce la misma contraseña para verificarla"
@ -143,57 +143,59 @@ msgstr ""
"Si tienes algún servicio SaaS (Software as a Service) contratado, aquí " "Si tienes algún servicio SaaS (Software as a Service) contratado, aquí "
"encontrarás sus detalles de configuración." "encontrarás sus detalles de configuración."
#: saas/forms.py:16 #: saas/forms.py:17
msgid "Site URL" msgid "Site URL"
msgstr "" msgstr ""
#: saas/forms.py:50 #: saas/forms.py:51
msgid "" msgid ""
"ID of this blog used by WordPress, the only attribute that doesn't change." "ID of this blog used by WordPress, the only attribute that doesn't change."
msgstr "" msgstr ""
"ID de este blog utilizado por WordPress, el único atributo que no cambia." "ID de este blog utilizado por WordPress, el único atributo que no cambia."
#: saas/forms.py:51 templates/musician/address_list.html:25 #: saas/forms.py:52 templates/musician/address_list.html:25
msgid "Email" msgid "Email"
msgstr "Correo electrónico" msgstr "Correo electrónico"
#: saas/forms.py:52 #: saas/forms.py:53
msgid "" msgid ""
"A new user will be created if the above email address is not in the database." "A new user will be created if the above email address is not in the database."
"<br>The username and password will be mailed to this email address." "<br>The username and password will be mailed to this email address."
msgstr "" msgstr ""
"Se creará un nuevo usuario si la dirección de correo electrónico anterior no está en la base de datos." "Se creará un nuevo usuario si la dirección de correo electrónico anterior no "
"<br>El nombre de usuario y la contraseña se enviarán a esta dirección de correo electrónico." "está en la base de datos.<br>El nombre de usuario y la contraseña se "
"enviarán a esta dirección de correo electrónico."
#: saas/forms.py:89 #: saas/forms.py:90 saas/forms.py:124
#, python-format #, python-format
msgid "Suggestion: %s" msgid "Suggestion: %s"
msgstr "Sugerencia: %s" msgstr "Sugerencia: %s"
#. Translators: This message appears on the page title #. Translators: This message appears on the page title
#: saas/views.py:24 saas/views.py:38 templates/musician/domain_list.html:51 #: saas/views.py:26 saas/views.py:40 templates/musician/domain_list.html:51
msgid "Software as a Service" msgid "Software as a Service"
msgstr "Software as a Service" msgstr "Software as a Service"
#: saas/views.py:25 #: saas/views.py:27
msgid "Nextcloud Service" msgid "Nextcloud Service"
msgstr "Servicio Nextcloud" msgstr "Servicio Nextcloud"
#: saas/views.py:26 #: saas/views.py:28
msgid "Members can manage their Nextcloud users in this section." msgid "Members can manage their Nextcloud users in this section."
msgstr "Los miembros pueden gestionar sus usuarios de Nextcloud en esta sección." msgstr ""
"Los miembros pueden gestionar sus usuarios de Nextcloud en esta sección."
#: saas/views.py:39 #: saas/views.py:41
msgid "Community WordPress" msgid "Community WordPress"
msgstr "WordPress Comunitario" msgstr "WordPress Comunitario"
#: saas/views.py:40 #: saas/views.py:42
msgid "" msgid ""
"Pangea's multisite WordPress service. Members can have their WordPress on " "Pangea's multisite WordPress service. Members can have their WordPress on "
"this community WordPress hosted and maintained by Pangea." "this community WordPress hosted and maintained by Pangea."
msgstr "" msgstr ""
"Servicio de WordPress multisitio de Pangea. " "Servicio de WordPress multisitio de Pangea. Los socios pueden tener su "
"Los socios pueden tener su WordPress en este WordPress comunitario alojado y mantenido por Pangea." "WordPress en este WordPress comunitario alojado y mantenido por Pangea."
#: templates/auth/login.html:59 #: templates/auth/login.html:59
msgid "Log in" msgid "Log in"
@ -244,7 +246,7 @@ msgstr "AVISO: Esta acción es irreversible."
#: templates/musician/record_check_delete.html:11 #: templates/musician/record_check_delete.html:11
#: templates/musician/record_form.html:16 #: templates/musician/record_form.html:16
#: templates/musician/saas_check_delete.html:9 #: templates/musician/saas_check_delete.html:9
#: templates/musician/saas_nextcloud_form.html:30 #: templates/musician/saas_nextcloud_form.html:36
#: templates/musician/saas_wordpress_form.html:31 #: templates/musician/saas_wordpress_form.html:31
#: templates/musician/systemuser_change_password.html:11 #: templates/musician/systemuser_change_password.html:11
#: templates/musician/webapps/webapp_form.html:11 #: templates/musician/webapps/webapp_form.html:11
@ -266,7 +268,7 @@ msgstr "Cancelar"
#: templates/musician/record_check_delete.html:10 #: templates/musician/record_check_delete.html:10
#: templates/musician/record_form.html:20 #: templates/musician/record_form.html:20
#: templates/musician/saas_check_delete.html:10 #: templates/musician/saas_check_delete.html:10
#: templates/musician/saas_nextcloud_form.html:35 #: templates/musician/saas_nextcloud_form.html:41
#: templates/musician/saas_wordpress_form.html:35 #: templates/musician/saas_wordpress_form.html:35
#: templates/musician/webapps/webapp_form.html:15 #: templates/musician/webapps/webapp_form.html:15
#: templates/musician/webapps/webappoption_check_delete.html:10 #: templates/musician/webapps/webappoption_check_delete.html:10
@ -280,7 +282,7 @@ msgstr "Borrar"
#: templates/musician/mailinglist_form.html:31 #: templates/musician/mailinglist_form.html:31
#: templates/musician/nextcloud_change_password.html:12 #: templates/musician/nextcloud_change_password.html:12
#: templates/musician/record_form.html:17 #: templates/musician/record_form.html:17
#: templates/musician/saas_nextcloud_form.html:31 #: templates/musician/saas_nextcloud_form.html:37
#: templates/musician/saas_wordpress_form.html:32 #: templates/musician/saas_wordpress_form.html:32
#: templates/musician/systemuser_change_password.html:12 #: templates/musician/systemuser_change_password.html:12
#: templates/musician/webapps/webapp_form.html:12 #: templates/musician/webapps/webapp_form.html:12
@ -571,7 +573,7 @@ msgstr "Direcciones de correo"
#: templates/musician/mailbox_change_password.html:5 #: templates/musician/mailbox_change_password.html:5
#: templates/musician/mailbox_form.html:24 #: templates/musician/mailbox_form.html:24
#: templates/musician/nextcloud_change_password.html:5 #: templates/musician/nextcloud_change_password.html:5
#: templates/musician/saas_nextcloud_form.html:34 #: templates/musician/saas_nextcloud_form.html:40
#: templates/musician/systemuser_change_password.html:5 #: templates/musician/systemuser_change_password.html:5
#: templates/musician/webapps/webappuser_change_password.html:5 #: templates/musician/webapps/webappuser_change_password.html:5
msgid "Change password" msgid "Change password"
@ -589,6 +591,7 @@ msgstr ""
"Todos los mensajes <strong>se borrarán y no se podrán recuperar</strong>." "Todos los mensajes <strong>se borrarán y no se podrán recuperar</strong>."
#: templates/musician/mailbox_form.html:9 #: templates/musician/mailbox_form.html:9
#: templates/musician/saas_nextcloud_form.html:28
msgid "Warning!" msgid "Warning!"
msgstr "¡Aviso!" msgstr "¡Aviso!"
@ -748,6 +751,20 @@ msgstr "Actualizar SaaS"
msgid "Create SaaS" msgid "Create SaaS"
msgstr "Crear SaaS" msgstr "Crear SaaS"
#: templates/musician/saas_nextcloud_form.html:28
msgid ""
"You have reached the limit of Nextcloud users of your subscription so "
"<strong>extra fees</strong> may apply."
msgstr ""
"Has alcanzado el límite de usuarios Nextcloud de tu suscripción, los nuevos "
"usuarios pueden suponer <strong>costes adicionales</strong>."
#: templates/musician/saas_nextcloud_list.html:57
#, fuzzy
#| msgid "SFTP user"
msgid "New user"
msgstr "Usuario SFTP"
#: templates/musician/systemuser_list.html:6 #: templates/musician/systemuser_list.html:6
msgid "" msgid ""
"The main user is your system's main user on each server. You'll be able to " "The main user is your system's main user on each server. You'll be able to "

View File

@ -6,6 +6,7 @@ from django.views.generic.base import ContextMixin
from orchestra import get_version from orchestra import get_version
from . import api from . import api
from .settings import LANGUAGES
from .auth import SESSION_KEY_TOKEN from .auth import SESSION_KEY_TOKEN
@ -29,7 +30,8 @@ class CustomContextMixin(ContextMixin):
context.update({ context.update({
'services_menu': services_menu, 'services_menu': services_menu,
'version': get_version(), 'version': get_version(),
'languages': settings.LANGUAGES, # 'languages': settings.LANGUAGES,
'languages': LANGUAGES,
}) })
return context return context

View File

@ -4,6 +4,7 @@ from orchestra.forms.widgets import SpanWidget
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from orchestra.utils.python import random_ascii from orchestra.utils.python import random_ascii
from django.core.exceptions import ValidationError
from django.forms.widgets import HiddenInput from django.forms.widgets import HiddenInput
@ -92,3 +93,50 @@ class NextcloudChangePasswordForm(ChangePasswordForm):
password = self.cleaned_data.get("password") password = self.cleaned_data.get("password")
self.fields['password'] = password self.fields['password'] = password
self.instance.set_password(password) self.instance.set_password(password)
class NextcloudCreateForm(forms.ModelForm):
error_messages = {
'password_mismatch': _('The two password fields didnt match.'),
}
password = forms.CharField(
label=_("Password"),
strip=False,
widget=forms.PasswordInput(attrs={'autocomplete': 'new-password'}),
)
password2 = forms.CharField(
label=_("Password confirmation"),
widget=forms.PasswordInput(attrs={'autocomplete': 'new-password'}),
strip=False,
help_text=_("Enter the same password as before, for verification."),
)
class Meta:
fields = ("service", "name", "password", "password2", "account")
model = SaaS
def __init__(self, *args, **kwargs):
user = kwargs.pop('user')
super().__init__(*args, **kwargs)
self.fields['account'].initial = user
self.fields['account'].widget = HiddenInput()
self.fields['service'].choices = [("nextcloud","nextCloud")]
self.fields['password'].help_text = _("Suggestion: %s") % random_ascii(20)
def clean_password2(self):
password = self.cleaned_data.get("password")
password2 = self.cleaned_data.get("password2")
if password and password2 and password != password2:
raise ValidationError(
self.error_messages['password_mismatch'],
code='password_mismatch',
)
return password
def clean_password(self):
password = self.cleaned_data.get("password")
self.fields['password'] = password
self.instance.set_password(password)

View File

@ -12,9 +12,11 @@ from orchestra.contrib.musician.mixins import (CustomContextMixin, ExtendedPagin
UserTokenRequiredMixin) UserTokenRequiredMixin)
from .forms import ( NextcloudChangePasswordForm, SaasNextcloudUpdateForm, from .forms import ( NextcloudChangePasswordForm, SaasNextcloudUpdateForm,
SaasWordpressUpdateForm ) SaasWordpressUpdateForm, NextcloudCreateForm )
from orchestra.contrib.saas.models import SaaS from orchestra.contrib.saas.models import SaaS
from orchestra.contrib.musician.settings import ALLOWED_RESOURCES
class SaasNextcloudListView(CustomContextMixin, UserTokenRequiredMixin, ListView): class SaasNextcloudListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
model = SaaS model = SaaS
@ -88,10 +90,36 @@ class NextcloudChangePasswordView(CustomContextMixin, UserTokenRequiredMixin, Up
def get_queryset(self): def get_queryset(self):
return self.model.objects.filter(account=self.request.user) return self.model.objects.filter(account=self.request.user)
class SaasDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView): class SaasDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
template_name = "musician/saas_check_delete.html" template_name = "musician/saas_check_delete.html"
model = SaaS model = SaaS
success_url = reverse_lazy("musician:saas-nextcloud-list") success_url = reverse_lazy("musician:saas-nextcloud-list")
def get_queryset(self): def get_queryset(self):
return self.model.objects.filter(account=self.request.user) return self.model.objects.filter(account=self.request.user)
class NextcloudCreateView(CustomContextMixin, UserTokenRequiredMixin, CreateView):
model = SaaS
template_name = "musician/saas_nextcloud_form.html"
form_class = NextcloudCreateForm
success_url = reverse_lazy("musician:saas-nextcloud-list")
def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
kwargs['user'] = self.request.user
return kwargs
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update({
'extra_user': self.is_extra_user(context['profile']),
})
return context
def is_extra_user(self, profile):
qs = SaaS.objects.filter(account=profile, service="nextcloud")
number_of_users = len(qs)
allowed_users = ALLOWED_RESOURCES[profile.type]['nextcloud']
return number_of_users >= allowed_users

View File

@ -70,3 +70,9 @@ MUSICIAN_WEBSITES_ENABLE_GROUP_DIRECTIVE = Setting('MUSICIAN_WEBSITES_ENABLE_GRO
), ),
help_text="Valid groups: HTTPD, ModSecurity, SSL, SaaS" help_text="Valid groups: HTTPD, ModSecurity, SSL, SaaS"
) )
LANGUAGES = [
('en', 'English'),
('es', 'Spanish'),
('ca', 'Catalan'),
]

View File

@ -23,6 +23,12 @@
{% endif %} {% endif %}
</h1> </h1>
{% if extra_user %}
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>{% trans "Warning!" %}</strong> {% trans "You have reached the limit of Nextcloud users of your subscription so <strong>extra fees</strong> may apply." %}
</div>
{% endif %}
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
{% bootstrap_form form %} {% bootstrap_form form %}

View File

@ -54,4 +54,5 @@
</table> </table>
</div> </div>
<a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:saas-nextcloud-create' %}">{% trans "New user" %}</a>
{% endblock %} {% endblock %}

View File

@ -53,6 +53,7 @@ urlpatterns = [
path('saas/nextcloud/', views.SaasNextcloudListView.as_view(), name='saas-nextcloud-list'), path('saas/nextcloud/', views.SaasNextcloudListView.as_view(), name='saas-nextcloud-list'),
path('saas/nextcloud/<int:pk>/', views.SaasNextcloudUpdateView.as_view(), name='saas-nextcloud-update'), path('saas/nextcloud/<int:pk>/', views.SaasNextcloudUpdateView.as_view(), name='saas-nextcloud-update'),
path('saas/<int:pk>/nextcloud-change-password/', views.NextcloudChangePasswordView.as_view(), name='nextcloud-password'), path('saas/<int:pk>/nextcloud-change-password/', views.NextcloudChangePasswordView.as_view(), name='nextcloud-password'),
path('saas/nextcloud/new/', views.NextcloudCreateView.as_view(), name='saas-nextcloud-create'),
path('saas/wordpress/', views.SaasWordpressListView.as_view(), name='saas-wordpress-list'), path('saas/wordpress/', views.SaasWordpressListView.as_view(), name='saas-wordpress-list'),
path('saas/wordpress/<int:pk>/', views.SaasWordpressUpdateView.as_view(), name='saas-wordpress-update'), path('saas/wordpress/<int:pk>/', views.SaasWordpressUpdateView.as_view(), name='saas-wordpress-update'),
path('saas/<int:pk>/delete/', views.SaasDeleteView.as_view(), name='saas-delete'), path('saas/<int:pk>/delete/', views.SaasDeleteView.as_view(), name='saas-delete'),