aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--django_skaschool/urls.py5
-rw-r--r--page/views.py19
-rw-r--r--static/css/index.css5
-rw-r--r--templates/index.html17
4 files changed, 42 insertions, 4 deletions
diff --git a/django_skaschool/urls.py b/django_skaschool/urls.py
index 7830463..60a298a 100644
--- a/django_skaschool/urls.py
+++ b/django_skaschool/urls.py
@@ -10,13 +10,14 @@ from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.generic.base import TemplateView
+from page.views import IndexView
+
urlpatterns = patterns('',
# admin
url(r'^admin/', include(admin.site.urls)),
# index page
- url(r'^$', TemplateView.as_view(template_name='index.html'),
- name='index'),
+ url(r'^$', IndexView.as_view(), name='index'),
# app 'page'
url(r'^page/', include('page.urls')),
# app 'notice'
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
diff --git a/static/css/index.css b/static/css/index.css
index 6a2d573..1858ee6 100644
--- a/static/css/index.css
+++ b/static/css/index.css
@@ -95,7 +95,12 @@
border-color: #E5E5E5;
}
+.smallcaps {
+ font-variant: small-caps;
+}
+
footer {
color: #CCCCCC;
}
+
diff --git a/templates/index.html b/templates/index.html
index 661dbae..16244d4 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -11,10 +11,12 @@
{% endblock %}
{% block content %}
+
+ {# title and main info #}
<div class="container">
<h1>第二届 中国SKA暑期学校</h1>
<h1>暨 中国-新西兰联合SKA暑期学校</h1>
- <h2>China-New Zealand Joint SKA Summer School</h2>
+ <h2 class="smallcaps">China-New Zealand Joint SKA Summer School</h2>
<br>
<p class="lead">
@@ -33,7 +35,20 @@
{% endblock %} {# content #}
{% block footer %}
+ {# display latest important notice #}
+ {% if important_notice %}
+ <div class="container">
+ <div class="alert alert-info alert-dismissable">
+ <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
+ <strong><a href="{% url 'list_notice' %}" class="alert-link">[通知]</a></strong>
+ {# notice contents #}
+ {{ important_notice.contents }}
+ </div>
+ </div>
+ {% endif %}
+
<footer class="container" role="contentinfo">
+ {# links #}
<ul class="masthead-links sponsors">
<li>Sponsors:</li>
<li><a href="http://www.most.gov.cn/" target="_blank">科学技术部</a></li>