move HostingPackageAndCustomerMixin to gvawebcore.views
This commit is contained in:
parent
7bc26b261c
commit
638a6f6712
4 changed files with 37 additions and 21 deletions
26
gnuviechadmin/gvawebcore/views.py
Normal file
26
gnuviechadmin/gvawebcore/views.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
This module defines common view code to be used by multiple gnuviechadmin apps.
|
||||
|
||||
"""
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
from hostingpackages.models import CustomerHostingPackage
|
||||
|
||||
|
||||
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
|
Loading…
Add table
Add a link
Reference in a new issue