Merge branch 'pretty' of github.com:fnp/wolnelektury into pretty
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 12:08:29 +0000 (13:08 +0100)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 12:09:36 +0000 (13:09 +0100)
Conflicts:
apps/catalogue/urls.py
apps/catalogue/views.py

1  2 
apps/catalogue/urls.py
apps/catalogue/views.py
lib/librarian

@@@ -6,8 -6,10 +6,11 @@@ from django.conf.urls.defaults import 
  from catalogue.feeds import AudiobookFeed
  from catalogue.models import Book
  from picture.models import Picture
 +from catalogue.views import CustomPDFFormView
  
+ SLUG = r'[a-z0-9-]*'
  urlpatterns = patterns('picture.views',
                         # pictures - currently pictures are coupled with catalogue, hence the url is here
          url(r'^obraz/?$', 'picture_list'),
@@@ -47,6 -49,6 +50,7 @@@
  
      url(r'^audiobooki/(?P<type>mp3|ogg|daisy|all).xml$', AudiobookFeed(), name='audiobook_feed'),
  
-     url(r'^custompdf/(?P<book_fileid>%s).pdf' % Book.FILEID_RE, 'download_custom_pdf'),
-     url(r'^custompdf$', CustomPDFFormView(), name='custom_pdf_form')
++    url(r'^custompdf$', CustomPDFFormView(), name='custom_pdf_form'),
+     url(r'^custompdf/(?P<slug>%s).pdf' % SLUG, 'download_custom_pdf'),
  ) 
@@@ -200,15 -196,12 +197,12 @@@ def book_fragments(request, slug, theme
          context_instance=RequestContext(request))
  
  
- def book_detail(request, book):
-     kwargs = models.Book.split_urlid(book)
-     if kwargs is None:
-         raise Http404
+ def book_detail(request, slug):
      try:
-         book = models.Book.objects.get(**kwargs)
+         book = models.Book.objects.get(slug=slug)
      except models.Book.DoesNotExist:
          return pdcounter_views.book_stub_detail(request, kwargs['slug'])
 -    
 +
      book_tag = book.book_tag()
      tags = list(book.tags.filter(~Q(category='set')))
      categories = split_tags(tags)
@@@ -726,14 -704,11 +705,11 @@@ def download_zip(request, format, slug=
      return HttpResponseRedirect(urlquote_plus(settings.MEDIA_URL + url, safe='/?='))
  
  
- def download_custom_pdf(request, book_fileid, method='GET'):
-     kwargs = models.Book.split_fileid(book_fileid)
-     if kwargs is None:
-         raise Http404
-     book = get_object_or_404(models.Book, **kwargs)
 -def download_custom_pdf(request, slug):
++def download_custom_pdf(request, slug, method='GET'):
+     book = get_object_or_404(models.Book, slug=slug)
  
 -    if request.method == 'GET':
 -        form = forms.CustomPDFForm(request.GET)
 +    if request.method == method:
 +        form = forms.CustomPDFForm(method == 'GET' and request.GET or request.POST)
          if form.is_valid():
              cust = form.customizations
              pdf_file = models.get_customized_pdf_path(book, cust)
diff --cc lib/librarian
@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 5fed78856949474a36bc5e268517775a9a802e27
 -Subproject commit a34b95aa7ba5fd4838541d1cdcd28358fb808062
++Subproject commit cbabbdaa7ab6c6be8cd22b77860331444ddf6119