from django.shortcuts import render
from django.views.generic import TemplateView
import importlib
import pkgutil

from db.main.models import *
from db.administration.models import *
from db.league.models import *
from db.calendar.models import *
from db.gpb.models import *
from db.tournaments.models import *
from db.membership.models import *
from db.atu.models import *

# Create your views here.


class HomeView(TemplateView):
    template_name = 'home.html'

    def get_context_data(self, **kwargs):
        return {
            **super().get_context_data(**kwargs),
            'home': 'active',
            'gpw': GrandPrixW.load(),
            'posts': Post.objects.all(),
        }


class AdministrationView(TemplateView):
    template_name = 'administration.html'

    def get_context_data(self, **kwargs):
        return {
            **super().get_context_data(**kwargs),
            'czlonkowie': Member.objects.all(),
            'statut': Statute.objects.first(),
        }


class AdministrationAnnouncementsView(TemplateView):
    template_name = 'administration/announcements.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['ogloszenia'] = Announcement.objects.all()

        return context


class AdministrationProtocolsView(TemplateView):
    template_name = 'administration/protocols.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['protokoly'] = Protocol.objects.all()

        return context


class AdministrationRegulationsView(TemplateView):
    template_name = 'administration/regulations.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['regulaminy'] = Regulation.objects.all()

        return context


class AdministrationRODOView(TemplateView):
    template_name = 'administration/rodos.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['rodos'] = RODO.objects.all()

        return context


class LeagueView(TemplateView):
    template_name = 'league.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['leagues'] = League.objects.all()

        return context


class CalendarView(TemplateView):
    template_name = 'calendar.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['calendars'] = Calendar.objects.all()

        return context


class GrandPrixView(TemplateView):
    template_name = 'grandprix.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['gp'] = GrandPrixB.load()

        return context


class TournamentView(TemplateView):
    template_name = "tournaments.html"

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['tournaments'] = Tournament.objects.all()

        return context


class MembershipView(TemplateView):
    template_name = 'membership.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['memberships'] = Membership.objects.all()

        return context


class AtuView(TemplateView):
    template_name = 'atu.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['atu'] = Atu.load()

        return context
