aboutsummaryrefslogtreecommitdiffstats
path: root/page/views.py
blob: a777e2f3b75674f3077ea83e72c0b0833ab0b019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-

"""
App 'page' views
"""

from django.shortcuts import render
from django.views.generic.base import TemplateView

from notice.models import Notice


## IndexView for index page (django_skaschool/urls.py)
class IndexView(TemplateView):
    """
    class-based view for index page
    """
    template_name = 'index.html'

    def get_context_data(self, **kwargs):
        context = super(type(self), self).get_context_data(**kwargs)
        # latest important notice (only display single one)
        important_notice_all = Notice.objects.filter(is_important=True).order_by('-pubtime')
        if important_notice_all:
            important_notice = important_notice_all[0]
        else:
            important_notice = None
        context['important_notice'] = important_notice
        return context