implement managemails.Views.AddMailAddress
- implement managemails.forms.multiple_email_validator - implement managemails.forms.AddMailAddressForm - implement managemails.views.AddMailAddress - add URL pattern 'add_mailaddress' to managemails.urls - add template managemails/mailaddress_create.html - add changelog entry
This commit is contained in:
parent
3271690841
commit
1d69bb22dc
5 changed files with 225 additions and 6 deletions
|
@ -17,12 +17,16 @@ from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin
|
|||
|
||||
from hostingpackages.models import CustomerHostingPackage
|
||||
|
||||
from domains.models import MailDomain
|
||||
from .forms import (
|
||||
CreateMailboxForm,
|
||||
AddMailAddressForm,
|
||||
ChangeMailboxPasswordForm,
|
||||
CreateMailboxForm,
|
||||
)
|
||||
from .models import (
|
||||
MailAddress,
|
||||
Mailbox,
|
||||
)
|
||||
from .models import Mailbox
|
||||
|
||||
|
||||
|
||||
class HostingPackageAndCustomerMixin(object):
|
||||
|
@ -119,3 +123,36 @@ class ChangeMailboxPassword(
|
|||
)
|
||||
)
|
||||
return redirect(self.get_hosting_package())
|
||||
|
||||
|
||||
class AddMailAddress(
|
||||
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, CreateView
|
||||
):
|
||||
"""
|
||||
This view is used to add a new mail address to a domain.
|
||||
|
||||
"""
|
||||
context_object_name = 'mailaddress'
|
||||
form_class = AddMailAddressForm
|
||||
model = MailAddress
|
||||
template_name_suffix = '_create'
|
||||
|
||||
def get_maildomain(self):
|
||||
return get_object_or_404(MailDomain, domain=self.kwargs['domain'])
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(AddMailAddress, self).get_form_kwargs()
|
||||
kwargs.update({
|
||||
'hostingpackage': self.get_hosting_package(),
|
||||
'maildomain': self.get_maildomain(),
|
||||
})
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form):
|
||||
address = form.save()
|
||||
messages.success(
|
||||
self.request,
|
||||
_('Successfully added mail address {mailaddress}').format(
|
||||
mailaddress=address)
|
||||
)
|
||||
return redirect(self.get_hosting_package())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue