From dbdec551f234c6dfdb992184b715e9af8462433c Mon Sep 17 00:00:00 2001 From: Weitian LI Date: Tue, 3 Jun 2014 11:28:12 +0800 Subject: Show latest import notice at index page. * added 'page.views.IndexView' for 'django_skaschool.urls * updated 'index.html' to display notice at bottom * added '.smallcaps' in 'index.css' for English title --- page/views.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'page') 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 -- cgit v1.2.2