aboutsummaryrefslogtreecommitdiffstats
path: root/page
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-06-03 11:28:12 +0800
committerWeitian LI <liweitianux@gmail.com>2014-06-03 11:28:12 +0800
commitdbdec551f234c6dfdb992184b715e9af8462433c (patch)
treead9aef4f55bf143cc549e2e347c000df96e75462 /page
parent2288c7f4dca08aa4519b80ace852be8c0526d992 (diff)
downloaddjango-skaschool-dbdec551f234c6dfdb992184b715e9af8462433c.tar.bz2
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
Diffstat (limited to 'page')
-rw-r--r--page/views.py19
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