Compare commits
No commits in common. "8fe15e370b3462de8692a7613d0af062ea02f565" and "ddd80fbf0e76a2b3c531c2816e6d26acce6892ab" have entirely different histories.
8fe15e370b
...
ddd80fbf0e
|
@ -4,9 +4,9 @@
|
|||
{% block content %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<p>{% blocktrans with address_name=object.email %}Are you sure that you want remove the address: "{{ address_name }}"?{% endblocktrans %}</p>
|
||||
<p>{% blocktrans with address_name=object.full_address_name %}Are you sure that you want remove the address: "{{ address_name }}"?{% endblocktrans %}</p>
|
||||
<p class="alert alert-warning"><strong>{% trans 'WARNING: This action cannot be undone.' %}</strong></p>
|
||||
<a class="btn btn-light mr-2" href="{% url 'musician:address-update' object.pk %}">{% trans 'Cancel' %}</a>
|
||||
<input class="btn btn-danger" type="submit" value="{% trans 'Delete' %}">
|
||||
<a class="btn btn-secondary" href="{% url 'musician:address-update' view.kwargs.pk %}">{% trans 'Cancel' %}</a>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<td>
|
||||
{% for addr in mailbox.addresses.all %}
|
||||
<a href="{% url 'musician:address-update' addr.pk %}">
|
||||
{{ addr.email }}
|
||||
{{ addr.full_address_name }}
|
||||
</a><br/>
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
{% endif %}
|
||||
<td>{{ resource.address_name}}</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.manager_url }}" target="_blank" rel="noopener noreferrer">Mailtrain <i class="fas fa-external-link-alt"></i></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -5,15 +5,12 @@ URL routes definition.
|
|||
Describe the paths where the views are accesible.
|
||||
"""
|
||||
from django.urls import path
|
||||
from django.views.generic import RedirectView
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = 'musician'
|
||||
|
||||
urlpatterns = [
|
||||
path('', RedirectView.as_view(pattern_name='musician:dashboard', permanent=False), name='index'),
|
||||
|
||||
path('auth/login/', views.LoginView.as_view(), name='login'),
|
||||
path('auth/logout/', views.LogoutView.as_view(), name='logout'),
|
||||
path('dashboard/', views.DashboardView.as_view(), name='dashboard'),
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from orchestra.contrib.domains.helpers import domain_for_validation
|
||||
from orchestra.contrib.domains.models import Record
|
||||
from orchestra.contrib.domains.validators import validate_zone
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import logging
|
||||
import smtplib
|
||||
from typing import Any
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.mail import mail_managers
|
||||
from django.db.models.query import QuerySet
|
||||
from django.http import (HttpResponse, HttpResponseNotFound,
|
||||
HttpResponseRedirect)
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
@ -292,9 +290,6 @@ class MailUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
|||
success_url = reverse_lazy("musician:address-list")
|
||||
extra_context = {'service': service_class}
|
||||
|
||||
def get_queryset(self) -> QuerySet[Any]:
|
||||
return self.model.objects.filter(account=self.request.user)
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
kwargs["user"] = self.request.user
|
||||
|
@ -303,11 +298,22 @@ class MailUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
|||
|
||||
class AddressDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
|
||||
template_name = "musician/address_check_delete.html"
|
||||
model = Address
|
||||
success_url = reverse_lazy("musician:address-list")
|
||||
|
||||
def get_queryset(self) -> QuerySet[Any]:
|
||||
return self.model.objects.filter(account=self.request.user)
|
||||
def get_object(self, queryset=None):
|
||||
obj = self.orchestra.retrieve_mail_address(self.kwargs['pk'])
|
||||
return obj
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
try:
|
||||
self.orchestra.delete_mail_address(self.object.id)
|
||||
messages.success(self.request, _('Address deleted!'))
|
||||
except HTTPError as e:
|
||||
messages.error(self.request, _('Cannot process your request, please try again later.'))
|
||||
logger.error(e)
|
||||
|
||||
return HttpResponseRedirect(self.success_url)
|
||||
|
||||
|
||||
class MailingListsView(ServiceListView):
|
||||
|
@ -391,21 +397,29 @@ class MailboxUpdateView(CustomContextMixin, UserTokenRequiredMixin, UpdateView):
|
|||
|
||||
|
||||
class MailboxDeleteView(CustomContextMixin, UserTokenRequiredMixin, DeleteView):
|
||||
model = Mailbox
|
||||
template_name = "musician/mailbox_check_delete.html"
|
||||
success_url = reverse_lazy("musician:mailbox-list")
|
||||
|
||||
def get_queryset(self) -> QuerySet[Any]:
|
||||
return self.model.objects.filter(account=self.request.user)
|
||||
def get_object(self, queryset=None):
|
||||
obj = self.orchestra.retrieve_mailbox(self.kwargs['pk'])
|
||||
return obj
|
||||
|
||||
def delete(self, request, *args, **kwargs):
|
||||
response = super().delete(request, *args, **kwargs)
|
||||
self.object = self.get_object()
|
||||
try:
|
||||
self.orchestra.delete_mailbox(self.object.id)
|
||||
messages.success(self.request, _('Mailbox deleted!'))
|
||||
except HTTPError as e:
|
||||
messages.error(self.request, _('Cannot process your request, please try again later.'))
|
||||
logger.error(e)
|
||||
|
||||
self.notify_managers(self.object)
|
||||
return response
|
||||
|
||||
return HttpResponseRedirect(self.success_url)
|
||||
|
||||
def notify_managers(self, mailbox):
|
||||
user = self.request.user
|
||||
subject = f"Mailbox '{mailbox.name}' ({mailbox.id}) deleted | Musician"
|
||||
user = self.get_context_data()['profile']
|
||||
subject = 'Mailbox {} ({}) deleted | Musician'.format(mailbox.id, mailbox.name)
|
||||
content = (
|
||||
"User {} ({}) has deleted its mailbox {} ({}) via musician.\n"
|
||||
"The mailbox has been marked as inactive but has not been removed."
|
||||
|
|
Loading…
Reference in New Issue