gva/gnuviechadmin/dashboard/views.py
Jan Dittberner 3a9110dc30 refactor dashboard.views.UserDashboardView
- use gvacommon.viewmixins.StaffOrSelfLoginRequiredMixin instead of custom
  implementation
2015-01-24 16:12:23 +01:00

48 lines
1.1 KiB
Python

"""
This module defines the views for the gnuviechadmin customer dashboard.
"""
from __future__ import unicode_literals
from django.views.generic import (
DetailView,
TemplateView,
)
from django.contrib.auth import get_user_model
from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin
from hostingpackages.models import CustomerHostingPackage
class IndexView(TemplateView):
"""
This is the dashboard view.
"""
template_name = 'dashboard/index.html'
class UserDashboardView(StaffOrSelfLoginRequiredMixin, DetailView):
"""
This is the user dashboard view.
"""
model = get_user_model()
context_object_name = 'dashboard_user'
slug_field = 'username'
template_name = 'dashboard/user_dashboard.html'
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
def get_customer_object(self):
"""
Returns the customer object.
"""
return self.get_object()