diff options
Diffstat (limited to 'page/views.py')
| -rw-r--r-- | page/views.py | 19 | 
1 files changed, 18 insertions, 1 deletions
| diff --git a/page/views.py b/page/views.py index 3af87bb..a777e2f 100644 --- a/page/views.py +++ b/page/views.py @@ -7,8 +7,25 @@ App 'page' views  from django.shortcuts import render  from django.views.generic.base import TemplateView +from notice.models import Notice -###### class-based views ###### +## 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 | 
