musician mailinlist edit
This commit is contained in:
parent
9dc719abcb
commit
54c6c59237
|
@ -0,0 +1,18 @@
|
||||||
|
from django import forms
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from orchestra.contrib.lists.models import List
|
||||||
|
from orchestra.contrib.domains.models import Domain
|
||||||
|
|
||||||
|
class MailingUpdateForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = List
|
||||||
|
fields = ("is_active", "name", "address_name", "address_domain")
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.user = kwargs.pop('user')
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
qs = Domain.objects.filter(account=self.user)
|
||||||
|
self.fields['address_domain'].queryset = qs
|
||||||
|
self.fields['address_name'].help_text = _("Additional address besides the default <name>@grups.pangea.org")
|
||||||
|
self.fields['name'].widget.attrs['readonly'] = True
|
|
@ -0,0 +1,61 @@
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from django.urls import reverse_lazy
|
||||||
|
|
||||||
|
from django.views.generic.list import ListView
|
||||||
|
from orchestra.contrib.musician.mixins import (CustomContextMixin, ExtendedPaginationMixin,
|
||||||
|
UserTokenRequiredMixin)
|
||||||
|
from django.views.generic.edit import (CreateView, DeleteView, FormView,
|
||||||
|
UpdateView)
|
||||||
|
|
||||||
|
from orchestra.contrib.lists.models import List
|
||||||
|
from orchestra.contrib.domains.models import Domain, Record
|
||||||
|
from orchestra.contrib.lists.settings import LISTS_DEFAULT_DOMAIN
|
||||||
|
|
||||||
|
from .forms import MailingUpdateForm
|
||||||
|
|
||||||
|
class MailingListsView(CustomContextMixin, UserTokenRequiredMixin, ListView):
|
||||||
|
model = List
|
||||||
|
template_name = "musician/mailinglist_list.html"
|
||||||
|
extra_context = {
|
||||||
|
# Translators: This message appears on the page title
|
||||||
|
'title': _('Mailing lists'),
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return self.model.objects.filter(account=self.request.user)
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
domain_id = self.request.GET.get('domain')
|
||||||
|
if domain_id:
|
||||||
|
qs = Domain.objects.filter(account=self.request.user)
|
||||||
|
context.update({
|
||||||
|
'active_domain': get_object_or_404(qs, pk=domain_id),
|
||||||
|
})
|
||||||
|
context.update({'default_domain': LISTS_DEFAULT_DOMAIN})
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get_queryfilter(self):
|
||||||
|
"""Retrieve query params (if any) to filter queryset"""
|
||||||
|
domain_id = self.request.GET.get('domain')
|
||||||
|
if domain_id:
|
||||||
|
return {"address_domain_id": domain_id}
|
||||||
|
return {}
|
||||||
|
|
||||||
|
class MailingUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
||||||
|
model = List
|
||||||
|
form_class = MailingUpdateForm
|
||||||
|
template_name = "musician/mailinglist_form.html"
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
qs = List.objects.filter(account=self.request.user)
|
||||||
|
return qs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy("musician:mailing-lists")
|
||||||
|
|
||||||
|
def get_form_kwargs(self):
|
||||||
|
kwargs = super().get_form_kwargs()
|
||||||
|
kwargs["user"] = self.request.user
|
||||||
|
return kwargs
|
|
@ -0,0 +1,31 @@
|
||||||
|
{% extends "musician/base.html" %}
|
||||||
|
{% load bootstrap4 i18n %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.form-check{
|
||||||
|
background-color: #fff;
|
||||||
|
padding: .375rem 2.0rem;
|
||||||
|
border: 1px solid #ced4da;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<a class="btn-arrow-left" href="{% url 'musician:mailing-lists' %}">{% trans "Go back" %}</a>
|
||||||
|
|
||||||
|
<h1 class="service-name">
|
||||||
|
{% trans "Update Option of list" %} <span class="font-weight-light">{{ list.name }}</span>
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% bootstrap_form form %}
|
||||||
|
{% buttons %}
|
||||||
|
<a class="btn btn-light mr-2" href="{% url 'musician:mailing-lists' %}">{% trans "Cancel" %}</a>
|
||||||
|
<button type="submit" class="btn btn-secondary">{% trans "Save" %}</button>
|
||||||
|
{% endbuttons %}
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
||||||
|
|
|
@ -13,9 +13,10 @@
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col span="1" style="width: 13%;">
|
<col span="1" style="width: 13%;">
|
||||||
<col span="1" style="width: 12%;">
|
<col span="1" style="width: 12%;">
|
||||||
<col span="1" style="width: 50%;">
|
<col span="1" style="width: 40%;">
|
||||||
<col span="1" style="width: 15%;">
|
<col span="1" style="width: 15%;">
|
||||||
<col span="1" style="width: 10%;">
|
<col span="1" style="width: 10%;">
|
||||||
|
<col span="1" style="width: 10%;">
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
<th scope="col">Address</th>
|
<th scope="col">Address</th>
|
||||||
<th scope="col">Admin email</th>
|
<th scope="col">Admin email</th>
|
||||||
<th scope="col">Configure</th>
|
<th scope="col">Configure</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -35,12 +37,21 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<td class="text-danger font-weight-bold">{% trans "Inactive" %}</td>
|
<td class="text-danger font-weight-bold">{% trans "Inactive" %}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>{{ resource.address_name}}</td>
|
<td>
|
||||||
|
{% if resource.address %}
|
||||||
|
{{ resource.address }}
|
||||||
|
{% else %}
|
||||||
|
{{ resource.name }}@{{ default_domain }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>{{ resource.admin_email }}</td>
|
<td>{{ resource.admin_email }}</td>
|
||||||
<td><a href="{{ resource.get_absolute_url }}" target="_blank" rel="noopener noreferrer">Mailman <i class="fas fa-external-link-alt"></i></a></td>
|
<td><a href="{{ resource.get_absolute_url }}" target="_blank" rel="noopener noreferrer">Mailman <i class="fas fa-external-link-alt"></i></a></td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-outline-warning" href="{% url 'musician:mailing-update' resource.id %}">
|
||||||
|
<i class="fas fa-tools"></i></a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
{% include "musician/components/table_paginator.html" %}
|
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -41,6 +41,7 @@ urlpatterns = [
|
||||||
path('mailboxes/<int:pk>/change-password/', views.MailboxChangePasswordView.as_view(), name='mailbox-password'),
|
path('mailboxes/<int:pk>/change-password/', views.MailboxChangePasswordView.as_view(), name='mailbox-password'),
|
||||||
|
|
||||||
path('mailing-lists/', views.MailingListsView.as_view(), name='mailing-lists'),
|
path('mailing-lists/', views.MailingListsView.as_view(), name='mailing-lists'),
|
||||||
|
path('mailing-lists/<int:pk>/', views.MailingUpdateView.as_view(), name='mailing-update'),
|
||||||
|
|
||||||
path('databases/', views.DatabaseListView.as_view(), name='database-list'),
|
path('databases/', views.DatabaseListView.as_view(), name='database-list'),
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ from .utils import get_bootstraped_percent
|
||||||
|
|
||||||
from .webapps.views import *
|
from .webapps.views import *
|
||||||
from .websites.views import *
|
from .websites.views import *
|
||||||
|
from .lists.views import *
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -315,37 +316,6 @@ class AddressDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
|
||||||
return self.model.objects.filter(account=self.request.user)
|
return self.model.objects.filter(account=self.request.user)
|
||||||
|
|
||||||
|
|
||||||
class MailingListsView(ServiceListView):
|
|
||||||
service_class = MailinglistService
|
|
||||||
model = List
|
|
||||||
template_name = "musician/mailinglist_list.html"
|
|
||||||
extra_context = {
|
|
||||||
# Translators: This message appears on the page title
|
|
||||||
'title': _('Mailing lists'),
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_queryset(self):
|
|
||||||
return self.model.objects.filter(account=self.request.user).order_by("name")
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
|
||||||
context = super().get_context_data(**kwargs)
|
|
||||||
domain_id = self.request.GET.get('domain')
|
|
||||||
if domain_id:
|
|
||||||
qs = Domain.objects.filter(account=self.request.user)
|
|
||||||
context.update({
|
|
||||||
'active_domain': get_object_or_404(qs, pk=domain_id)
|
|
||||||
})
|
|
||||||
return context
|
|
||||||
|
|
||||||
def get_queryfilter(self):
|
|
||||||
"""Retrieve query params (if any) to filter queryset"""
|
|
||||||
domain_id = self.request.GET.get('domain')
|
|
||||||
if domain_id:
|
|
||||||
return {"address_domain_id": domain_id}
|
|
||||||
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
class MailboxListView(ServiceListView):
|
class MailboxListView(ServiceListView):
|
||||||
service_class = MailboxService
|
service_class = MailboxService
|
||||||
model = Mailbox
|
model = Mailbox
|
||||||
|
|
Loading…
Reference in New Issue