1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from dictionary.models import Note
6 from django.views.generic.list import ListView
9 class NotesView(ListView):
10 def get_queryset(self):
11 self.letters = ["0-9"] + [chr(a) for a in range(ord('a'), ord('z')+1)]
12 self.letter = self.kwargs.get('letter')
14 objects = Note.objects.all()
15 if self.letter == "0-9":
16 objects = objects.filter(sort_key__regex=r"^[0-9]")
18 objects = objects.filter(sort_key__startswith=self.letter)
21 def get_context_data(self, **kwargs):
22 context = super(NotesView, self).get_context_data(**kwargs)
23 context['letter'] = self.letter
24 context['letters'] = self.letters