musician websitedetail

This commit is contained in:
Jorge Pastor 2024-05-13 20:23:25 +02:00
parent 898dde9330
commit f3e3d45d60
5 changed files with 182 additions and 8 deletions

View File

@ -0,0 +1,97 @@
{% extends "musician/base.html" %}
{% load i18n %}
{% block content %}
<a class="btn-arrow-left" href="{% url 'musician:website-list' %}">{% trans "Go back" %}</a>
<h1 class="service-name">{% trans "WebSite Options for" %} {{ object.name }}</h1>
<hr>
<table class="table service-list">
<tbody>
<tr>
<th scope="row">Server:</th>
<td>{{ object.target_server }}</td>
</tr>
<tr>
<th scope="row">Domains:</th>
<td>
{% for domain in object.domains.all %}
{{ domain }} <br>
{% endfor %}
</td>
</tr>
<tr>
<th scope="row">active:</th>
<td class="text-{{website.is_active|yesno:'success,danger'}}">
<i class="fa fa-{{ website.is_active|yesno:'check,times' }}"></i>
<span class="sr-only">{{ website.is_active|yesno }}</span>
</td>
</tr>
<tr>
<th scope="row">Protocol:</th>
<td>{{ object.protocol }}</td>
</tr>
</tbody>
</table>
<!-- Contents -->
<h3 class="service-name">{% trans "Contents" %}</h3>
<hr>
<p>{% trans "Webapps assigned to this website" %}</p>
<table class="table service-list">
<thead class="thead-dark">
<tr>
<th scope="col">{% trans "Webapp" %}</th>
<th scope="col">{% trans "Type " %}</th>
<th scope="col">{% trans "Path" %}</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for option in content %}
<tr>
<td>{{ option.webapp }}</td>
<td>{{ option.webapp.get_type_display }}</td>
<td>{{ option.path }}</td>
<td class="text-right">
<a href="{% url 'musician:website-delete-content' object.pk option.pk %}">
<i class="ml-3 text-danger fas fa-trash"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- <a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:webapp-add-option' object.pk %}">{% trans "Add new option" %}</a></td> -->
<!-- Directives -->
<h3 class="service-name">{% trans "Directives" %}</h3>
<hr>
<p>{% trans "Options assigned to this Website" %} </p>
<table class="table service-list">
<thead class="thead-dark">
<tr>
<th scope="col">{% trans "Name" %}</th>
<th scope="col">{% trans "Value" %}</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% for option in directives %}
<tr>
<td>{{ option.name }}</td>
<td>{{ option.value }}</td>
<td class="text-right">
<a href="{% url 'musician:website-delete-directive' object.pk option.pk %}">
<i class="ml-3 text-danger fas fa-trash"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- <a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:webapp-add-option' object.pk %}">{% trans "Add new option" %}</a></td> -->
{% endblock %}

View File

@ -38,11 +38,11 @@
<span class="sr-only">{{ website.is_active|yesno }}</span>
</td>
<td>
<!-- <a class="btn btn-outline-warning" href="#">
<i class="fas fa-tools"></i></a> -->
<button type="button" class="btn btn-outline-warning" data-toggle="modal" data-target="#exampleModal">
<!-- <button type="button" class="btn btn-outline-warning" data-toggle="modal" data-target="#websiteModal">
<i class="fas fa-tools"></i>
</button>
</button> -->
<a class="btn btn-outline-warning" href="{% url 'musician:website-detail' website.id %}">
<i class="fas fa-tools"></i></a>
</td>
</tr>
<!-- Fila oculta de webapp -->
@ -108,11 +108,11 @@
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<!-- <div class="modal fade" id="websiteModal" tabindex="-1" role="dialog" aria-labelledby="websiteModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Sorry!</h5>
<h5 class="modal-title" id="websiteModalLabel">Sorry!</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
@ -123,6 +123,6 @@
</div>
</div>
</div>
</div> -->
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "musician/base.html" %}
{% load i18n %}
{% block content %}
<form method="post">
{% csrf_token %}
<p>{% blocktrans %}Are you sure that you want remove the following option"?{% endblocktrans %}</p>
{% if object.name %}
<pre>{{ object.name }} {{ object.value }}</pre>
{% else %}
<pre>Webapp {{ object.webapp }} assigned in website {{ object.website }}</pre>
{% endif %}
<p class="alert alert-warning"><strong>{% trans 'WARNING: This action cannot be undone.' %}</strong></p>
<input class="btn btn-danger" type="submit" value="{% trans 'Delete' %}">
<a class="btn btn-secondary" href="{% url 'musician:website-detail' view.kwargs.pk %}">{% trans 'Cancel' %}</a>
</form>
{% endblock %}

View File

@ -44,7 +44,11 @@ urlpatterns = [
path('webappuser/<int:pk>/change-password/', views.WebappUserChangePasswordView.as_view(), name='webappuser-password'),
path('systemusers/', views.SystemUserListView.as_view(), name='systemuser-list'),
path('systemuser/<int:pk>/change-password/', views.SystemUserChangePasswordView.as_view(), name='systemuser-password'),
path('websites/', views.WebsiteListView.as_view(), name='website-list'),
path('websites/<int:pk>/', views.WebsiteDetailView.as_view(), name='website-detail'),
path('websites/<int:pk>/content/<int:content_pk>/delete/', views.WebsiteDeleteContentView.as_view(), name='website-delete-content'),
path('websites/<int:pk>/directive/<int:directive_pk>/delete/', views.WebsiteDeleteDirectiveView.as_view(), name='website-delete-directive'),
path('webapps/', views.WebappListView.as_view(), name='webapp-list'),
path('webapps/<int:pk>/', views.WebappDetailView.as_view(), name='webapp-detail'),

View File

@ -33,7 +33,7 @@ from orchestra.contrib.mailboxes.models import Address, Mailbox
from orchestra.contrib.resources.models import Resource, ResourceData
from orchestra.contrib.saas.models import SaaS
from orchestra.contrib.systemusers.models import WebappUsers, SystemUser
from orchestra.contrib.websites.models import Website
from orchestra.contrib.websites.models import Website, Content, WebsiteDirective
from orchestra.contrib.webapps.models import WebApp, WebAppOption
from orchestra.utils.html import html_to_pdf
@ -671,6 +671,62 @@ class WebsiteListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
})
return context
class WebsiteDetailView(CustomContextMixin, UserTokenRequiredMixin, DetailView):
template_name = "musician/website_detail.html"
extra_context = {
# Translators: This message appears on the page title
'title': _('website details'),
}
def get_queryset(self):
return Website.objects.filter(account=self.request.user)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['content'] = Content.objects.filter(website=self.object)
context['directives'] = WebsiteDirective.objects.filter(website=self.object)
return context
class WebsiteDeleteContentView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
model = Content
template_name = "musician/websiteoption_check_delete.html"
pk_url_kwarg = "content_pk"
def get_queryset(self):
qs = Content.objects.filter(website__account=self.request.user, website=self.kwargs["pk"])
return qs
def get_success_url(self):
return reverse_lazy("musician:website-detail", kwargs={"pk": self.kwargs["pk"]})
def delete(self, request, *args, **kwargs):
object = self.get_object()
response = super().delete(request, *args, **kwargs)
object.website.save()
return response
class WebsiteDeleteDirectiveView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
model = WebsiteDirective
template_name = "musician/websiteoption_check_delete.html"
pk_url_kwarg = "directive_pk"
def get_queryset(self):
qs = WebsiteDirective.objects.filter(website__account=self.request.user, website=self.kwargs["pk"])
return qs
def get_success_url(self):
return reverse_lazy("musician:website-detail", kwargs={"pk": self.kwargs["pk"]})
def delete(self, request, *args, **kwargs):
object = self.get_object()
response = super().delete(request, *args, **kwargs)
object.website.save()
return response
class WebappListView(CustomContextMixin, UserTokenRequiredMixin, ListView):
model = WebApp
template_name = "musician/webapp_list.html"