from django.shortcuts import render
from django.views.generic import TemplateView
from .models import TournamentPage

# Create your views here.


class HomeView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(id=id, published=True)
        return {'t': t, 'content': t.homepage, 'content_buttons': t.homepage_buttons, 'homepage': True}


class ScheduleAndResultsView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(
            id=id, published=True, schedule_and_results_enabled=True)
        return {'t': t, 'content': t.schedule_and_results, 'content_buttons': t.schedule_and_results_buttons, 'schedule_and_results': True}


class RegistrationView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(
            id=id, published=True, registration_enabled=True)
        return {'t': t, 'content': t.registration, 'content_buttons': t.registration_buttons, 'registration': True}


class RulesView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(
            id=id, published=True, rules_enabled=True)
        return {'t': t, 'content': t.rules, 'content_buttons': t.rules_buttons, 'rules': True}


class FeeAndPrizesView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(
            id=id, published=True, fee_and_prizes_enabled=True)
        return {'t': t, 'content': t.fee_and_prizes, 'content_buttons': t.fee_and_prizes_buttons, 'fee_and_prizes': True}


class AccomodationView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(
            id=id, published=True, accomodation_enabled=True)
        return {'t': t, 'content': t.accomodation, 'content_buttons': t.accomodation_buttons, 'accomodation': True}


class ContactView(TemplateView):
    template_name = "tournament.html"

    def get_context_data(self, id, **kwargs):
        t = TournamentPage.objects.get(
            id=id, published=True, contact_enabled=True)
        return {'t': t, 'content': t.contact, 'content_buttons': t.contact_buttons, 'contact': True}
