pdlzbs/core/views.py

96 lines
2.4 KiB
Python

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 *
# Create your views here.
class HomeView(TemplateView):
template_name = 'home.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['home'] = 'active'
context['gpw'] = GrandPrixW.load()
context['posts'] = Post.objects.all()
return context
class AdministrationView(TemplateView):
template_name = 'administration.html'
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context = {
**context,
'czlonkowie': AdministrationMember.objects.all(),
'statut': AdministrationStatute.objects.first(),
'ogloszenia': AdministrationAnnouncement.objects.all(),
'protokoly': AdministrationProtocol.objects.all(),
'regulaminy': AdministrationRegulation.objects.all(),
}
return context
class RODOView(TemplateView):
template_name = 'rodo.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.objects.first()
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