15b4c212169cea33111ffd3c3800934f3a7f9319
[copyspeak.git] / src / words / views.py
1 from django.views.generic import TemplateView, DetailView
2 from .models import Word
3
4 class HomeView(TemplateView):
5     template_name = 'words/home.html'
6
7     def get_context_data(self):
8         all_words = Word.objects.all().order_by('word')
9         words = {}
10         for word in all_words:
11             words.setdefault(word.alignment, []).append(word)
12
13         return {
14             'words': words,
15             #'random': Word.objects.order_by('?')[0],
16         }
17
18 class WordView(DetailView):
19     model = Word
20
21     def get_context_data(self, object):
22         return {
23             'object': object,
24             'words': Word.objects.all(),
25         }