musician saas nextcloud/WP separate views
This commit is contained in:
parent
228ee30d6e
commit
e5c046c3af
|
@ -14,15 +14,17 @@ class CustomContextMixin(ContextMixin):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
# generate services menu items
|
# generate services menu items
|
||||||
services_menu = [
|
services_menu = [
|
||||||
{'icon': 'home', 'pattern_name': 'musician:dashboard', 'title': _('Dashboard')},
|
{'icon': 'fas fa-home', 'pattern_name': 'musician:dashboard', 'title': _('Dashboard')},
|
||||||
{'icon': 'globe-europe', 'pattern_name': 'musician:domain-list', 'title': _('Domains')},
|
{'icon': 'fas fa-globe', 'pattern_name': 'musician:domain-list', 'title': _('Domains')},
|
||||||
{'icon': 'envelope', 'pattern_name': 'musician:address-list', 'title': _('Mails')},
|
{'icon': 'fas fa-envelope', 'pattern_name': 'musician:address-list', 'title': _('Mails')},
|
||||||
{'icon': 'mail-bulk', 'pattern_name': 'musician:mailing-lists', 'title': _('Mailing lists')},
|
{'icon': 'fas fa-mail-bulk', 'pattern_name': 'musician:mailing-lists', 'title': _('Mailing lists')},
|
||||||
{'icon': 'database', 'pattern_name': 'musician:database-list', 'title': _('Databases')},
|
{'icon': 'fas fa-database', 'pattern_name': 'musician:database-list', 'title': _('Databases')},
|
||||||
{'icon': 'fire', 'pattern_name': 'musician:saas-list', 'title': _('SaaS')},
|
{'icon': 'fas fa-fire', 'pattern_name': 'musician:saas-nextcloud-list', 'title': _('SaaS')},
|
||||||
{'icon': 'globe', 'pattern_name': 'musician:website-list', 'title': _('Websites')},
|
{'icon': 'fas fa-cloud', 'pattern_name': 'musician:saas-nextcloud-list', 'title': _('Nextcloud'), 'indent': True},
|
||||||
{'icon': 'folder', 'pattern_name': 'musician:webapp-list', 'title': _('Webapps'), 'indent': True},
|
{'icon': 'fab fa-wordpress', 'pattern_name': 'musician:saas-wordpress-list', 'title': _('Community WP'), 'indent': True},
|
||||||
{'icon': 'user', 'pattern_name': 'musician:systemuser-list', 'title': _('Users'), 'indent': True},
|
{'icon': 'fas fa-globe', 'pattern_name': 'musician:website-list', 'title': _('Websites')},
|
||||||
|
{'icon': 'fas fa-folder', 'pattern_name': 'musician:webapp-list', 'title': _('Webapps'), 'indent': True},
|
||||||
|
{'icon': 'fas fa-user', 'pattern_name': 'musician:systemuser-list', 'title': _('Users'), 'indent': True},
|
||||||
]
|
]
|
||||||
context.update({
|
context.update({
|
||||||
'services_menu': services_menu,
|
'services_menu': services_menu,
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="nav-link text-light active" href="{% url item.pattern_name %}">
|
<a class="nav-link text-light active" href="{% url item.pattern_name %}">
|
||||||
<i class="fas fa-{{ item.icon }}"></i>
|
<i class="{{ item.icon }}"></i>
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<a class="btn-arrow-left" href="{% url 'musician:saas-list' %}">{% trans "Go back" %}</a>
|
<a class="btn-arrow-left" href="{% url 'musician:saas-nextcloud-list' %}">{% trans "Go back" %}</a>
|
||||||
|
|
||||||
<h1 class="service-name">
|
<h1 class="service-name">
|
||||||
{% if form.instance.pk %}
|
{% if form.instance.pk %}
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% bootstrap_form form %}
|
{% bootstrap_form form %}
|
||||||
{% buttons %}
|
{% buttons %}
|
||||||
<a class="btn btn-light mr-2" href="{% url 'musician:saas-list' %}">{% trans "Cancel" %}</a>
|
<a class="btn btn-light mr-2" href="{% url 'musician:saas-nextcloud-list' %}">{% trans "Cancel" %}</a>
|
||||||
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
||||||
{% if form.instance.pk %}
|
{% if form.instance.pk %}
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
{% extends "musician/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 class="service-name">{{ service.verbose_name }}</h1>
|
||||||
|
<p class="service-description">{{ service.description }}</p>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table service-list">
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">{% trans "Name" %}</th>
|
||||||
|
<th scope="col">{% trans "Status" %}</th>
|
||||||
|
<th scope="col">{% trans "Service" %}</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for saas in object_list %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{{ saas.name }}</strong><br>
|
||||||
|
<span class="text-secondary">{% trans "Installed on" %}: <strong>{{ saas.get_site_domain|default:"-" }}</strong></span>
|
||||||
|
</td>
|
||||||
|
<td class="text-{{saas.is_active|yesno:'success,danger'}}">
|
||||||
|
<i class="fa fa-{{ saas.is_active|yesno:'check,times' }}"></i>
|
||||||
|
<span class="sr-only">{{ saas.is_active|yesno }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-sm btn-link" href="https://{{ saas.get_site_domain|default:'#' }}" target="_blank" rel="noopener noreferrer" title="{% trans 'Open service admin panel' %}">
|
||||||
|
<i class="fab fa-{{ saas.service }}"></i> {{ saas.service|capfirst }}
|
||||||
|
<span class="sr-only">{% trans "Open service admin panel" %}</span> <i class="fas fa-external-link-alt"></i></a>
|
||||||
|
</td>
|
||||||
|
<td class="text-right">
|
||||||
|
<a class="btn btn-outline-warning" role="button" href="{% url 'musician:saas-update' saas.id %}">
|
||||||
|
<i class="fas fa-tools"></i></a>
|
||||||
|
<a class="btn btn-outline-danger" role="button" href="{% url 'musician:saas-delete' saas.id %}">
|
||||||
|
<i class="text-danger fas fa-trash"></i></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">
|
||||||
|
<h5 class="text-dark">
|
||||||
|
<i class="fas fa-fire fa-2x mr-2"></i>
|
||||||
|
{# Translators: saas page when there isn't any saas. #}
|
||||||
|
{% trans "Ooops! Looks like there is nothing here!" %}
|
||||||
|
</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,65 @@
|
||||||
|
{% extends "musician/base.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<h1 class="service-name">{{ service.verbose_name }}</h1>
|
||||||
|
<p class="service-description">{{ service.description }}</p>
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table service-list">
|
||||||
|
<!-- <colgroup>
|
||||||
|
<col span="1" style="width: 35%;">
|
||||||
|
<col span="1" style="width: 10%;">
|
||||||
|
<col span="1" style="width: 25%;">
|
||||||
|
<col span="1" style="width: 30%;">
|
||||||
|
</colgroup> -->
|
||||||
|
<thead class="thead-dark">
|
||||||
|
<tr>
|
||||||
|
<th scope="col">{% trans "Name" %}</th>
|
||||||
|
<th scope="col">{% trans "Status" %}</th>
|
||||||
|
<th scope="col">{% trans "Service" %}</th>
|
||||||
|
<!-- <th scope="col">{% trans "Service info" %}</th> -->
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for saas in object_list %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<strong>{{ saas.name }}</strong><br>
|
||||||
|
<span class="text-secondary">{% trans "Installed on" %}: <strong>{{ saas.get_site_domain|default:"-" }}</strong></span>
|
||||||
|
</td>
|
||||||
|
<td class="text-{{saas.is_active|yesno:'success,danger'}}">
|
||||||
|
<i class="fa fa-{{ saas.is_active|yesno:'check,times' }}"></i>
|
||||||
|
<span class="sr-only">{{ saas.is_active|yesno }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-sm btn-link" href="https://{{ saas.get_site_domain|default:'#' }}" target="_blank" rel="noopener noreferrer" title="{% trans 'Open service admin panel' %}">
|
||||||
|
<i class="fab fa-{{ saas.service }}"></i> {{ saas.service|capfirst }}
|
||||||
|
<span class="sr-only">{% trans "Open service admin panel" %}</span> <i class="fas fa-external-link-alt"></i></a>
|
||||||
|
</td>
|
||||||
|
<td class="text-right">
|
||||||
|
<a class="btn btn-outline-warning" role="button" href="{% url 'musician:saas-update' saas.id %}">
|
||||||
|
<i class="fas fa-tools"></i></a>
|
||||||
|
<!-- <a class="btn btn-outline-danger" role="button" href="{% url 'musician:saas-delete' saas.id %}">
|
||||||
|
<i class="text-danger fas fa-trash"></i></a> -->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">
|
||||||
|
<h5 class="text-dark">
|
||||||
|
<i class="fas fa-fire fa-2x mr-2"></i>
|
||||||
|
{# Translators: saas page when there isn't any saas. #}
|
||||||
|
{% trans "Ooops! Looks like there is nothing here!" %}
|
||||||
|
</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!-- <a class="btn btn-primary mt-4 mb-4" href="#">{% trans "New User Nextcloud" %}</a> -->
|
||||||
|
{% endblock %}
|
|
@ -50,7 +50,9 @@ urlpatterns = [
|
||||||
|
|
||||||
path('databases/', views.DatabaseListView.as_view(), name='database-list'),
|
path('databases/', views.DatabaseListView.as_view(), name='database-list'),
|
||||||
|
|
||||||
path('saas/', views.SaasListView.as_view(), name='saas-list'),
|
# path('saas/', views.SaasListView.as_view(), name='saas-list'),
|
||||||
|
path('saas/nextcloud/', views.SaasNextcloudListView.as_view(), name='saas-nextcloud-list'),
|
||||||
|
path('saas/wordpress/', views.SaasWordpressListView.as_view(), name='saas-wordpress-list'),
|
||||||
path('saas/<int:pk>/', views.SaasUpdateView.as_view(), name='saas-update'),
|
path('saas/<int:pk>/', views.SaasUpdateView.as_view(), name='saas-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'),
|
||||||
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'),
|
||||||
|
|
|
@ -614,15 +614,38 @@ class DatabaseListView(ServiceListView):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class SaasListView(ServiceListView):
|
# class SaasListView(ServiceListView):
|
||||||
service_class = SaasService
|
# service_class = SaasService
|
||||||
|
# model = SaaS
|
||||||
|
# template_name = "musician/saas_list.html"
|
||||||
|
# extra_context = {
|
||||||
|
# # Translators: This message appears on the page title
|
||||||
|
# 'title': _('Software as a Service'),
|
||||||
|
# }
|
||||||
|
|
||||||
|
class SaasNextcloudListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
||||||
model = SaaS
|
model = SaaS
|
||||||
template_name = "musician/saas_list.html"
|
template_name = "musician/saas_nextcloud_list.html"
|
||||||
extra_context = {
|
extra_context = {
|
||||||
# Translators: This message appears on the page title
|
# Translators: This message appears on the page title
|
||||||
'title': _('Software as a Service'),
|
'title': _('Software as a Service'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return self.model.objects.filter(account=self.request.user, service='nextcloud')
|
||||||
|
|
||||||
|
|
||||||
|
class SaasWordpressListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
||||||
|
model = SaaS
|
||||||
|
template_name = "musician/saas_wordpress_list.html"
|
||||||
|
extra_context = {
|
||||||
|
# Translators: This message appears on the page title
|
||||||
|
'title': _('Software as a Service'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return self.model.objects.filter(account=self.request.user, service='wordpress')
|
||||||
|
|
||||||
class SaasUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
class SaasUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
||||||
model = SaaS
|
model = SaaS
|
||||||
form_class = SaasUpdateForm
|
form_class = SaasUpdateForm
|
||||||
|
@ -633,7 +656,7 @@ class SaasUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
return reverse_lazy("musician:saas-list")
|
return reverse_lazy("musician:saas-nextcloud-list")
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
kwargs = super().get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
|
@ -644,7 +667,7 @@ class NextcloudChangePasswordView(CustomContextMixin, UserTokenRequiredMixin, Up
|
||||||
template_name = "musician/nextcloud_change_password.html"
|
template_name = "musician/nextcloud_change_password.html"
|
||||||
model = SaaS
|
model = SaaS
|
||||||
form_class = NextcloudChangePasswordForm
|
form_class = NextcloudChangePasswordForm
|
||||||
success_url = reverse_lazy("musician:saas-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)
|
||||||
|
@ -652,7 +675,7 @@ class NextcloudChangePasswordView(CustomContextMixin, UserTokenRequiredMixin, Up
|
||||||
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-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)
|
||||||
|
|
Loading…
Reference in New Issue