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:
Jan Dittberner 2015-01-25 19:03:58 +01:00
parent af27400077
commit bebcad8c86
4 changed files with 71 additions and 0 deletions

View file

@ -1,6 +1,7 @@
Changelog Changelog
========= =========
* :feature:`-` implement mail address deletion
* :feature:`-` implement adding mail address to mail domains * :feature:`-` implement adding mail address to mail domains
* :feature:`-` implement adding options to hosting packages * :feature:`-` implement adding options to hosting packages
* :bug:`-` fix disk space calculation in * :bug:`-` fix disk space calculation in

View file

@ -11,6 +11,7 @@ from .views import (
AddMailAddress, AddMailAddress,
ChangeMailboxPassword, ChangeMailboxPassword,
CreateMailbox, CreateMailbox,
DeleteMailAddress,
) )
urlpatterns = patterns( urlpatterns = patterns(
@ -21,4 +22,7 @@ urlpatterns = patterns(
ChangeMailboxPassword.as_view(), name='change_mailbox_password'), ChangeMailboxPassword.as_view(), name='change_mailbox_password'),
url(r'^(?P<package>\d+)/mailaddress/(?P<domain>[\w0-9-.]+)/create$', url(r'^(?P<package>\d+)/mailaddress/(?P<domain>[\w0-9-.]+)/create$',
AddMailAddress.as_view(), name='add_mailaddress'), 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'),
) )

View file

@ -9,6 +9,7 @@ from django.shortcuts import get_object_or_404, redirect
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.generic.edit import ( from django.views.generic.edit import (
CreateView, CreateView,
DeleteView,
UpdateView, UpdateView,
) )
from django.contrib import messages from django.contrib import messages
@ -137,6 +138,11 @@ class AddMailAddress(
model = MailAddress model = MailAddress
template_name_suffix = '_create' 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): def get_maildomain(self):
return get_object_or_404(MailDomain, domain=self.kwargs['domain']) return get_object_or_404(MailDomain, domain=self.kwargs['domain'])
@ -156,3 +162,29 @@ class AddMailAddress(
mailaddress=address) mailaddress=address)
) )
return redirect(self.get_hosting_package()) 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()

View file

@ -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 %}