Changes in club payments.
[wolnelektury.git] / src / catalogue / urls.py
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.
4 #
5 from django.conf.urls import url
6 from django.db.models import Max
7 from django.views.generic import ListView, RedirectView
8 from catalogue.feeds import AudiobookFeed
9 from catalogue.models import Book
10 from catalogue import views
11 import picture.views
12
13
14 SLUG = r'[a-z0-9-]*'
15
16 urlpatterns = [
17     url(r'^obraz/strona/$', picture.views.picture_page, name='picture_page'),
18     # pictures - currently pictures are coupled with catalogue, hence the url is here
19     url(r'^obraz/$', picture.views.picture_list_thumb, name='picture_list_thumb'),
20     url(r'^obraz/(?P<slug>%s).html$' % SLUG, picture.views.picture_viewer, name='picture_viewer'),
21     url(r'^obraz/(?P<slug>%s)/$' % SLUG, picture.views.picture_detail, name='picture_detail'),
22
23     url(r'^p/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', picture.views.picture_mini, name='picture_mini'),
24     url(r'^p/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', picture.views.picture_short, name='picture_short'),
25     url(r'^pa/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', picture.views.picturearea_short, name='picture_area_short'),
26
27     # old search page - redirected
28     url(r'^szukaj/$', RedirectView.as_view(
29             url='/szukaj/', query_string=True, permanent=True)),
30
31     url(r'^$', views.catalogue, name='catalogue'),
32
33     url(r'^autor/$', views.tag_catalogue, {'category': 'author'}, name='author_catalogue'),
34     url(r'^epoka/$', views.tag_catalogue, {'category': 'epoch'}, name='epoch_catalogue'),
35     url(r'^gatunek/$', views.tag_catalogue, {'category': 'genre'}, name='genre_catalogue'),
36     url(r'^rodzaj/$', views.tag_catalogue, {'category': 'kind'}, name='kind_catalogue'),
37     url(r'^motyw/$', views.tag_catalogue, {'category': 'theme'}, name='theme_catalogue'),
38
39     url(r'^galeria/$', views.gallery, name='gallery'),
40     url(r'^kolekcje/$', views.collections, name='catalogue_collections'),
41
42     url(r'^lektury/$', views.literature, name='book_list'),
43     url(r'^lektury/(?P<slug>[a-zA-Z0-9-]+)/$', views.collection, name='collection'),
44     url(r'^audiobooki/$', views.audiobooks, name='audiobook_list'),
45     url(r'^daisy/$', views.daisy_list, name='daisy_list'),
46     url(r'^nowe/$', ListView.as_view(
47         queryset=Book.objects.filter(parent=None).order_by('-created_at'),
48         template_name='catalogue/recent_list.html'), name='recent_list'),
49     url(r'^nowe/audiobooki/$', ListView.as_view(
50         queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m'),
51         template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'),
52     url(r'^nowe/daisy/$', ListView.as_view(
53         queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'),
54         template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'),
55
56     url(r'^custompdf/(?P<slug>%s)/$' % SLUG, views.CustomPDFFormView(), name='custom_pdf_form'),
57
58     url(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
59
60     url(r'^pobierz/(?P<slug>%s).(?P<format_>[a-z0-9]*)$' % SLUG, views.embargo_link, name='embargo_link'),
61
62     # zip
63     url(r'^zip/pdf\.zip$', views.download_zip, {'format': 'pdf', 'slug': None}, 'download_zip_pdf'),
64     url(r'^zip/epub\.zip$', views.download_zip, {'format': 'epub', 'slug': None}, 'download_zip_epub'),
65     url(r'^zip/mobi\.zip$', views.download_zip, {'format': 'mobi', 'slug': None}, 'download_zip_mobi'),
66     url(r'^zip/mp3/(?P<slug>%s)\.zip' % SLUG, views.download_zip, {'format': 'mp3'}, 'download_zip_mp3'),
67     url(r'^zip/ogg/(?P<slug>%s)\.zip' % SLUG, views.download_zip, {'format': 'ogg'}, 'download_zip_ogg'),
68
69     # Public interface. Do not change this URLs.
70     url(r'^lektura/(?P<slug>%s)\.html$' % SLUG, views.book_text, name='book_text'),
71     url(r'^lektura/(?P<slug>%s)/audiobook/$' % SLUG, views.player, name='book_player'),
72     url(r'^lektura/(?P<slug>%s)/$' % SLUG, views.book_detail, name='book_detail'),
73     url(r'^lektura/(?P<slug>%s)/motyw/(?P<theme_slug>[a-zA-Z0-9-]+)/$' % SLUG,
74         views.book_fragments, name='book_fragments'),
75
76     url(r'^okladka-ridero/(?P<slug>%s).png$' % SLUG, views.ridero_cover),
77     url(r'^isbn/(?P<book_format>(pdf|epub|mobi|txt|html))/(?P<slug>%s)/' % SLUG, views.get_isbn),
78
79     # Includes.
80     url(r'^b/(?P<pk>\d+)/mini\.(?P<lang>.+)\.html', views.book_mini, name='catalogue_book_mini'),
81     url(r'^b/(?P<pk>\d+)/mini_nolink\.(?P<lang>.+)\.html', views.book_mini, {'with_link': False},
82         name='catalogue_book_mini_nolink'),
83     url(r'^b/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', views.book_short, name='catalogue_book_short'),
84     url(r'^b/(?P<pk>\d+)/wide\.(?P<lang>.+)\.html', views.book_wide, name='catalogue_book_wide'),
85     url(r'^f/(?P<pk>\d+)/promo\.(?P<lang>.+)\.html', views.fragment_promo, name='catalogue_fragment_promo'),
86     url(r'^f/(?P<pk>\d+)/short\.(?P<lang>.+)\.html', views.fragment_short, name='catalogue_fragment_short'),
87     url(r'^t/(?P<pk>\d+)/box\.(?P<lang>.+)\.html', views.tag_box, name='catalogue_tag_box'),
88     url(r'^c/(?P<pk>.+)/box\.(?P<lang>.+)\.html', views.collection_box, name='catalogue_collection_box'),
89
90     # This should be the last pattern.
91     url(r'^galeria/(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'gallery'},
92         name='tagged_object_list_gallery'),
93     url(r'^audiobooki/(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'audiobooks'},
94         name='tagged_object_list_audiobooks'),
95     url(r'^(?P<tags>[a-zA-Z0-9-/]*)/$', views.tagged_object_list, {'list_type': 'books'},
96         name='tagged_object_list'),
97 ]