from django.shortcuts import render
from django.views import generic
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from teams.models import Team

User = get_user_model()

class Dashboard(LoginRequiredMixin, generic.TemplateView):
    def get_template_names(self):
        if self.request.user.is_superuser:
            return ['dashboard/dashboard_superuser.html']
        elif self.request.user.is_support_manager:
            return ['dashboard/dashboard_support_manager.html']

        return ['dashboard/dashboard.html']

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        if self.request.user.is_superuser:
            if not User.objects.has_support_manager():
                context['setup_msg'] = 'SUPPORT_MANAGER'
        elif self.request.user.is_support_manager:
            if Team.objects.count() < 1:
                context['setup_msg'] = 'TEAM'

        return context

#class NotSetUp(LoginRequiredMixin, generic.TemplateView):
#    def get_template_names(self):
#        if Team.objects.count() < 1:
#            print("here")
#            return ['dashboard/not_set_up_teams.html']
#        else:
#            print('there')
#            return ['dashboard/not_set_up.html']

from django.shortcuts import render
from django.views import generic
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from teams.models import Team

User = get_user_model()

class Dashboard(LoginRequiredMixin, generic.TemplateView):
    def get_template_names(self):
        if self.request.user.is_superuser:
            return ['dashboard/dashboard_superuser.html']
        elif self.request.user.is_support_manager:
            return ['dashboard/dashboard_support_manager.html']

        return ['dashboard/dashboard.html']

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        if self.request.user.is_superuser:
            if not User.objects.has_support_manager():
                context['setup_msg'] = 'SUPPORT_MANAGER'
        elif self.request.user.is_support_manager:
            if Team.objects.count() < 1:
                context['setup_msg'] = 'TEAM'

        return context

#class NotSetUp(LoginRequiredMixin, generic.TemplateView):
#    def get_template_names(self):
#        if Team.objects.count() < 1:
#            print("here")
#            return ['dashboard/not_set_up_teams.html']
#        else:
#            print('there')
#            return ['dashboard/not_set_up.html']

#class NotSetUp(LoginRequiredMixin, generic.TemplateView): #    def get_template_names(self): #        if Team.objects.count() < 1: #            print("here") #            return ['dashboard/not_set_up_teams.html'] #        else: #            print('there') #            return ['dashboard/not_set_up.html']