implement mail address deletion
- implement managemails.views.DeleteMailAddress - add get_context_data to AddMailAddress to add customer to template context - add URL pattern 'delete_mailaddress' to managemails.urls - add template hostingpackages/customerhostingpackage_detail.html - add entry to changelog
This commit is contained in:
parent
af27400077
commit
bebcad8c86
4 changed files with 71 additions and 0 deletions
|
@ -9,6 +9,7 @@ from django.shortcuts import get_object_or_404, redirect
|
|||
from django.utils.translation import ugettext as _
|
||||
from django.views.generic.edit import (
|
||||
CreateView,
|
||||
DeleteView,
|
||||
UpdateView,
|
||||
)
|
||||
from django.contrib import messages
|
||||
|
@ -137,6 +138,11 @@ class AddMailAddress(
|
|||
model = MailAddress
|
||||
template_name_suffix = '_create'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(AddMailAddress, self).get_context_data(**kwargs)
|
||||
context['customer'] = self.get_customer_object()
|
||||
return context
|
||||
|
||||
def get_maildomain(self):
|
||||
return get_object_or_404(MailDomain, domain=self.kwargs['domain'])
|
||||
|
||||
|
@ -156,3 +162,29 @@ class AddMailAddress(
|
|||
mailaddress=address)
|
||||
)
|
||||
return redirect(self.get_hosting_package())
|
||||
|
||||
|
||||
class DeleteMailAddress(
|
||||
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, DeleteView
|
||||
):
|
||||
"""
|
||||
This view is used to delete a mail address.
|
||||
|
||||
"""
|
||||
context_object_name = 'mailaddress'
|
||||
model = MailAddress
|
||||
|
||||
def get_maildomain(self):
|
||||
return get_object_or_404(MailDomain, domain=self.kwargs['domain'])
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DeleteMailAddress, self).get_context_data(**kwargs)
|
||||
context.update({
|
||||
'customer': self.get_customer_object(),
|
||||
'hostingpackage': self.get_hosting_package(),
|
||||
'maildomain': self.get_maildomain(),
|
||||
})
|
||||
return context
|
||||
|
||||
def get_success_url(self):
|
||||
return self.get_hosting_package().get_absolute_url()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue