You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
from django.db.models import Min
|
|
from django.contrib.auth import get_user_model
|
|
from django.views.generic import TemplateView
|
|
|
|
from apps.course.models import Course
|
|
from apps.school.models import SchoolSchedule
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class IndexView(TemplateView):
|
|
template_name = 'templates/lilcity/main.html'
|
|
|
|
def get_context_data(self):
|
|
context = super().get_context_data()
|
|
context.update({
|
|
'course_items': Course.objects.filter(status=Course.PUBLISHED)[:3],
|
|
'school_schedules': SchoolSchedule.objects.all(),
|
|
'min_school_price': SchoolSchedule.objects.all().aggregate(Min('month_price'))['month_price__min'],
|
|
'authors': User.objects.filter(role=User.AUTHOR_ROLE, show_in_mainpage=True),
|
|
})
|
|
return context
|
|
|
|
|
|
class SchoolSchedulesView(TemplateView):
|
|
template_name = 'templates/lilcity/school_schedules.html'
|
|
|
|
def get_context_data(self):
|
|
context = super().get_context_data()
|
|
context['school_schedules'] = SchoolSchedule.objects.all()
|
|
return context
|
|
|