Fix tests

This commit is contained in:
Jan Dittberner 2023-04-29 13:10:25 +02:00
parent 866f6c8083
commit d88745f46b
11 changed files with 35 additions and 116 deletions

View file

@ -11,41 +11,17 @@ from gvacommon.viewmixins import StaffOrSelfLoginRequiredMixin
from hostingpackages.models import CustomerHostingPackage
class IndexView(LoginRequiredMixin, TemplateView):
"""
This is the dashboard view.
"""
template_name = "dashboard/index.html"
def dispatch(self, request, *args, **kwargs):
if not request.user.is_anonymous:
return redirect("customer_dashboard", slug=request.user.username)
return super().dispatch(request, *args, **kwargs)
class UserDashboardView(StaffOrSelfLoginRequiredMixin, DetailView):
class UserDashboardView(LoginRequiredMixin, TemplateView):
"""
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
customer=self.request.user
)
return context
def get_customer_object(self):
"""
Returns the customer object.
"""
return self.get_object()