aboutsummaryrefslogtreecommitdiffstats
path: root/archive/views.py
diff options
context:
space:
mode:
authorWeitian LI <liweitianux@gmail.com>2014-04-28 13:34:41 +0800
committerWeitian LI <liweitianux@gmail.com>2014-04-28 13:34:41 +0800
commit650b6c5f48bccd2f79e2489ecd9df9157bac421a (patch)
treeab7fb7065a721dc1af2029c8dbf8021c1cbc2b27 /archive/views.py
parent5af86ee6cbb4d9561c8f0a32d064f1ccd4e4b1cf (diff)
downloaddjango-skaschool-650b6c5f48bccd2f79e2489ecd9df9157bac421a.tar.bz2
* added app 'archive' to provides downloads
o models: Archive, ArchiveCategory o views: ArchiveView based on TemplateView o template: archive.html o sidebar: sidebar.js, sidebar.css
Diffstat (limited to 'archive/views.py')
-rw-r--r--archive/views.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/archive/views.py b/archive/views.py
new file mode 100644
index 0000000..eec7d36
--- /dev/null
+++ b/archive/views.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+
+from django.shortcuts import render
+from django.views.generic.base import TemplateView
+
+from archive.models import Archive, ArchiveCategory
+
+
+class ArchiveView(TemplateView):
+ """
+ class-based view to show archives
+ """
+ template_name = 'archive/archive.html'
+
+ def get_context_data(self, **kwargs):
+ """
+ add 'user' context
+ """
+ context = super(type(self), self).get_context_data(**kwargs)
+ archive_categories = ArchiveCategory.objects.all()
+ if Archive.objects.all():
+ archive_empty = False
+ else:
+ archive_empty = True
+ context['archive_categories'] = archive_categories
+ context['archive_empty'] = archive_empty
+ return context
+