2015-01-17 14:01:22 +01:00
|
|
|
"""
|
|
|
|
This module defines the views for the gnuviechadmin customer dashboard.
|
|
|
|
|
|
|
|
"""
|
2015-01-20 00:47:24 +01:00
|
|
|
from django.contrib.auth import get_user_model
|
2023-04-14 19:33:44 +02:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
2023-02-18 22:46:48 +01:00
|
|
|
from django.views.generic import DetailView, TemplateView
|
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
|
|
|
|
2023-04-14 19:33:44 +02:00
|
|
|
class IndexView(LoginRequiredMixin, TemplateView):
|
2015-01-17 14:01:22 +01:00
|
|
|
"""
|
|
|
|
This is the dashboard view.
|
|
|
|
|
|
|
|
"""
|
2023-02-18 22:46:48 +01:00
|
|
|
|
|
|
|
template_name = "dashboard/index.html"
|
2015-01-17 14:01:22 +01:00
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
"""
|
2023-02-18 22:46:48 +01:00
|
|
|
|
2015-01-17 14:01:22 +01:00
|
|
|
model = get_user_model()
|
2023-02-18 22:46:48 +01:00
|
|
|
context_object_name = "dashboard_user"
|
|
|
|
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)
|
2023-02-18 22:46:48 +01:00
|
|
|
context["hosting_packages"] = CustomerHostingPackage.objects.filter(
|
2015-01-18 16:19:28 +01:00
|
|
|
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()
|