2015-01-17 14:01:22 +01:00
|
|
|
"""
|
|
|
|
This module defines the views for the gnuviechadmin customer dashboard.
|
|
|
|
|
|
|
|
"""
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.views.generic import (
|
|
|
|
DetailView,
|
|
|
|
TemplateView,
|
|
|
|
)
|
2015-01-20 00:47:24 +01:00
|
|
|
from django.contrib.auth import get_user_model
|
2015-01-17 14:01:22 +01:00
|
|
|
|
2015-01-24 16:12:23 +01:00
|
|
|
from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin
|
2015-01-17 14:01:22 +01:00
|
|
|
|
2015-01-18 16:19:28 +01:00
|
|
|
from hostingpackages.models import CustomerHostingPackage
|
|
|
|
|
2015-01-17 14:01:22 +01:00
|
|
|
|
|
|
|
class IndexView(TemplateView):
|
|
|
|
"""
|
|
|
|
This is the dashboard view.
|
|
|
|
|
|
|
|
"""
|
|
|
|
template_name = 'dashboard/index.html'
|
|
|
|
|
|
|
|
|
2015-01-24 16:12:23 +01:00
|
|
|
class UserDashboardView(StaffOrSelfLoginRequiredMixin, DetailView):
|
2015-01-17 14:01:22 +01:00
|
|
|
"""
|
|
|
|
This is the user dashboard view.
|
|
|
|
|
|
|
|
"""
|
|
|
|
model = get_user_model()
|
2015-01-17 15:42:47 +01:00
|
|
|
context_object_name = 'dashboard_user'
|
2015-01-17 14:01:22 +01:00
|
|
|
slug_field = 'username'
|
|
|
|
template_name = 'dashboard/user_dashboard.html'
|
2015-01-17 15:42:47 +01:00
|
|
|
|
2015-01-18 16:19:28 +01:00
|
|
|
def get_context_data(self, **kwargs):
|
|
|
|
context = super(UserDashboardView, self).get_context_data(**kwargs)
|
|
|
|
context['hosting_packages'] = CustomerHostingPackage.objects.filter(
|
|
|
|
customer=self.object
|
|
|
|
)
|
|
|
|
return context
|
2015-01-24 16:12:23 +01:00
|
|
|
|
|
|
|
def get_customer_object(self):
|
|
|
|
"""
|
|
|
|
Returns the customer object.
|
|
|
|
|
|
|
|
"""
|
|
|
|
return self.get_object()
|