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
|
@ -1,6 +1,7 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
* :feature:`-` implement mail address deletion
|
||||
* :feature:`-` implement adding mail address to mail domains
|
||||
* :feature:`-` implement adding options to hosting packages
|
||||
* :bug:`-` fix disk space calculation in
|
||||
|
|
|
@ -11,6 +11,7 @@ from .views import (
|
|||
AddMailAddress,
|
||||
ChangeMailboxPassword,
|
||||
CreateMailbox,
|
||||
DeleteMailAddress,
|
||||
)
|
||||
|
||||
urlpatterns = patterns(
|
||||
|
@ -21,4 +22,7 @@ urlpatterns = patterns(
|
|||
ChangeMailboxPassword.as_view(), name='change_mailbox_password'),
|
||||
url(r'^(?P<package>\d+)/mailaddress/(?P<domain>[\w0-9-.]+)/create$',
|
||||
AddMailAddress.as_view(), name='add_mailaddress'),
|
||||
url(r'^(?P<package>\d+)/mailaddress/(?P<domain>[\w0-9-.]+)/(?P<pk>\d+)'
|
||||
r'/delete$',
|
||||
DeleteMailAddress.as_view(), name='delete_mailaddress'),
|
||||
)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{% extends "managemails/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{{ block.super }} - {% spaceless %}
|
||||
{% if user == customer %}
|
||||
{% blocktrans %}Delete Mail Address {{ mailaddress }}{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans with full_name=customer.get_full_name %}Delete Mail Address {{ mailaddress }} of Customer {{ full_name }}{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endspaceless %}{% endblock title %}
|
||||
|
||||
{% block page_title %}{% spaceless %}
|
||||
{% if user == customer %}
|
||||
{% blocktrans %}Delete Mail Address {{ mailaddress }}{% endblocktrans %}
|
||||
{% else %}
|
||||
{% blocktrans with full_name=customer.get_full_name %}Delete Mail Address {{ mailaddress }} of Customer {{ full_name }}{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endspaceless %}{% endblock page_title %}
|
||||
|
||||
{% block content %}
|
||||
<div class="panel panel-warning">
|
||||
<div class="panel-body">
|
||||
{% blocktrans %}Do you really want to delete the mail address {{ mailaddress }}?{% endblocktrans %}
|
||||
</div>
|
||||
<div class="panel-body form">
|
||||
<form action="{% url 'delete_mailaddress' package=hostingpackage.id domain=maildomain.domain pk=mailaddress.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
<input class="btn btn-warning" type="submit" value="{% trans "Yes, do it!" %}" />
|
||||
<a class="btn btn-default" href="{{ hostingpackage.get_absolute_url }}">{% trans "Cancel" %}</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
Loading…
Reference in a new issue