diff options
Diffstat (limited to 'archive/views.py')
-rw-r--r-- | archive/views.py | 28 |
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 + |