# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from django.views.decorators.csrf import csrf_exempt
+from django.views.generic import TemplateView
from piston.authentication import OAuthAuthentication, oauth_access_token
from piston.resource import Resource
url(r'^oauth/access_token/$', csrf_exempt(oauth_access_token)),
) + patterns('',
- url(r'^$', 'django.views.generic.simple.direct_to_template',
- {'template': 'api/main.html'}, name='api'),
+ url(r'^$', TemplateView.as_view(template_name='api/main.html'), name='api'),
# changes handlers
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
from django.conf.urls.defaults import *
-
+from dictionary.views import NotesView
urlpatterns = patterns('dictionary.views',
- url(r'^$', 'letter_notes', name='dictionary_notes'),
- url(r'(?P<letter>[a-z]|0-9)/$', 'letter_notes', name='dictionary_notes'),
+ url(r'^$', NotesView.as_view(), name='dictionary_notes'),
+ url(r'(?P<letter>[a-z]|0-9)/$', NotesView.as_view(), name='dictionary_notes'),
)
# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
-from django.views.generic.list_detail import object_list
from dictionary.models import Note
+from django.views.generic.list import ListView
-def letter_notes(request, letter=None):
- letters = ["0-9"] + [chr(a) for a in range(ord('a'), ord('z')+1)]
- objects = Note.objects.all()
- if letter == "0-9":
- objects = objects.filter(sort_key__regex=r"^[0-9]")
- elif letter:
- objects = objects.filter(sort_key__startswith=letter)
- return object_list(request, queryset=objects, extra_context=locals())
+class NotesView(ListView):
+ def get_queryset(self):
+ self.letters = ["0-9"] + [chr(a) for a in range(ord('a'), ord('z')+1)]
+ self.letter = self.kwargs.get('letter')
+
+ objects = Note.objects.all()
+ if self.letter == "0-9":
+ objects = objects.filter(sort_key__regex=r"^[0-9]")
+ elif self.letter:
+ objects = objects.filter(sort_key__startswith=self.letter)
+ return ListView.get_queryset(self)
+
+ def get_context_data(self, **kwargs):
+ context = super(NotesView, self).get_context_data(**kwargs)
+ context['letter'] = self.letter
+ context['letters'] = self.letters
+ return context
from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
+from django.views.generic import RedirectView
import wolnelektury_core.views
url(r'^i18n/', include('django.conf.urls.i18n')),
)
-urlpatterns += patterns('django.views.generic.simple',
+urlpatterns += patterns('',
# old static pages - redirected
- url(r'^1procent/$', 'redirect_to',
- {'url': 'http://nowoczesnapolska.org.pl/wesprzyj_nas/'}),
- url(r'^epub/$', 'redirect_to',
- {'url': '/katalog/lektury/'}),
- url(r'^mozesz-nam-pomoc/$', 'redirect_to',
- {'url': '/info/mozesz-nam-pomoc'}),
- url(r'^o-projekcie/$', 'redirect_to',
- {'url': '/info/o-projekcie'}),
- url(r'^widget/$', 'redirect_to',
- {'url': '/info/widget'}),
- url(r'^wolontariat/$', 'redirect_to',
- {'url': '/info/mozesz-nam-pomoc/'}),
+ url(r'^1procent/$', RedirectView.as_view(
+ url='http://nowoczesnapolska.org.pl/wesprzyj_nas/')),
+ url(r'^epub/$', RedirectView.as_view(
+ url='/katalog/lektury/')),
+ url(r'^mozesz-nam-pomoc/$', RedirectView.as_view(
+ url='/info/mozesz-nam-pomoc')),
+ url(r'^o-projekcie/$', RedirectView.as_view(
+ url='/info/o-projekcie')),
+ url(r'^widget/$', RedirectView.as_view(
+ url='/info/widget')),
+ url(r'^wolontariat/$', RedirectView.as_view(
+ url='/info/mozesz-nam-pomoc/')),
)