move HostingPackageAndCustomerMixin to gvawebcore.views

This commit is contained in:
Jan Dittberner 2015-01-26 10:33:01 +01:00
parent 7bc26b261c
commit 638a6f6712
4 changed files with 37 additions and 21 deletions

View file

@ -15,8 +15,7 @@ from django.views.generic.edit import (
from django.contrib import messages
from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin
from hostingpackages.models import CustomerHostingPackage
from gvawebcore.views import HostingPackageAndCustomerMixin
from domains.models import MailDomain
from .forms import (
@ -33,25 +32,6 @@ from .models import (
)
class HostingPackageAndCustomerMixin(object):
"""
Mixin for views that gets the hosting package instance from the URL
keyword argument 'package'.
"""
hosting_package_kwarg = 'package'
"""Keyword argument used to find the hosting package in the URL."""
def get_hosting_package(self):
return get_object_or_404(
CustomerHostingPackage,
pk=int(self.kwargs[self.hosting_package_kwarg]))
def get_customer_object(self):
return self.get_hosting_package().customer
class CreateMailbox(
HostingPackageAndCustomerMixin, StaffOrSelfLoginRequiredMixin, CreateView
):