musician website edit basic
This commit is contained in:
parent
f3e3d45d60
commit
4f258a9fe0
|
@ -14,6 +14,7 @@ from orchestra.contrib.musician.validators import ValidateZoneMixin
|
|||
from orchestra.contrib.webapps.models import WebApp, WebAppOption
|
||||
from orchestra.contrib.webapps.options import AppOption
|
||||
from orchestra.contrib.webapps.types import AppType
|
||||
from orchestra.contrib.websites.models import Website
|
||||
|
||||
from . import api
|
||||
from .settings import MUSICIAN_EDIT_ENABLE_PHP_OPTIONS
|
||||
|
@ -265,6 +266,25 @@ class WebappOptionUpdateForm(WebappOptionForm):
|
|||
self.fields['name'].widget.choices = [(self.initial['name'], self.initial['name'])]
|
||||
|
||||
|
||||
class WebsiteUpdateForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Website
|
||||
fields = ("is_active", "protocol", "domains")
|
||||
help_texts = {
|
||||
'domains': _('Hold down "Control", or "Command" on a Mac, to select more than one.')
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.user = kwargs.pop('user')
|
||||
super().__init__(*args, **kwargs)
|
||||
# Excluir dominios de otros websites
|
||||
qs = Website.objects.filter(account=self.user).exclude(id=self.instance.id)
|
||||
used_domains = []
|
||||
for website in qs:
|
||||
dominios = website.domains.all()
|
||||
for dominio in dominios:
|
||||
used_domains.append(dominio)
|
||||
self.fields['domains'].queryset = Domain.objects.filter(account=self.user).exclude(name__in=used_domains)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a class="btn btn-primary mt-4 mb-4" href="{% url 'musician:website-update' object.pk %}">{% trans "Edit options" %}</a></td>
|
||||
|
||||
<!-- Contents -->
|
||||
<h3 class="service-name">{% trans "Contents" %}</h3>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
{% extends "musician/base.html" %}
|
||||
{% load bootstrap4 i18n %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<a class="btn-arrow-left" href="{% url 'musician:website-detail' view.kwargs.pk %}">{% trans "Go back" %}</a>
|
||||
|
||||
<h1 class="service-name">
|
||||
{% if form.instance.pk %}{% trans "Update Option of Website" %}{% else %}{% trans "Add Option to" %}{% endif %}
|
||||
<span class="font-weight-light">{{ website.name }}</span>
|
||||
</h1>
|
||||
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
{% buttons %}
|
||||
<a class="btn btn-light mr-2" href="{% url 'musician:website-detail' view.kwargs.pk %}">{% trans "Cancel" %}</a>
|
||||
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
||||
{% endbuttons %}
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
@ -47,6 +47,7 @@ urlpatterns = [
|
|||
|
||||
path('websites/', views.WebsiteListView.as_view(), name='website-list'),
|
||||
path('websites/<int:pk>/', views.WebsiteDetailView.as_view(), name='website-detail'),
|
||||
path('websites/<int:pk>/edit/', views.WebsiteUpdateView.as_view(), name='website-update'),
|
||||
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'),
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ from .auth import logout as auth_logout
|
|||
from .forms import (LoginForm, MailboxChangePasswordForm, MailboxCreateForm,
|
||||
MailboxSearchForm, MailboxUpdateForm, MailForm,
|
||||
RecordCreateForm, RecordUpdateForm, WebappUsersChangePasswordForm,
|
||||
SystemUsersChangePasswordForm, WebappOptionCreateForm, WebappOptionUpdateForm)
|
||||
SystemUsersChangePasswordForm, WebappOptionCreateForm, WebappOptionUpdateForm,
|
||||
WebsiteUpdateForm)
|
||||
from .mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
||||
UserTokenRequiredMixin)
|
||||
from .models import Address as AddressService
|
||||
|
@ -689,6 +690,24 @@ class WebsiteDetailView(CustomContextMixin, UserTokenRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
class WebsiteUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
||||
model = Website
|
||||
form_class = WebsiteUpdateForm
|
||||
template_name = "musician/website_form.html"
|
||||
|
||||
def get_queryset(self):
|
||||
qs = Website.objects.filter(account=self.request.user)
|
||||
return qs
|
||||
|
||||
def get_success_url(self):
|
||||
return reverse_lazy("musician:website-detail", kwargs={"pk": self.kwargs["pk"]})
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["user"] = self.request.user
|
||||
return kwargs
|
||||
|
||||
|
||||
class WebsiteDeleteContentView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
|
||||
model = Content
|
||||
template_name = "musician/websiteoption_check_delete.html"
|
||||
|
@ -764,6 +783,7 @@ class WebappDetailView(CustomContextMixin, UserTokenRequiredMixin, DetailView):
|
|||
})
|
||||
return context
|
||||
|
||||
|
||||
class WebappAddOptionView(CustomContextMixin, UserTokenRequiredMixin, CreateView):
|
||||
model = WebAppOption
|
||||
form_class = WebappOptionCreateForm
|
||||
|
|
Loading…
Reference in New Issue