custom pdf download via ajaxable
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 12:43:13 +0000 (13:43 +0100)
committerMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Fri, 30 Dec 2011 12:43:13 +0000 (13:43 +0100)
apps/ajaxable/utils.py
apps/catalogue/views.py
wolnelektury/templates/catalogue/book_wide.html

index a6faafa..d6f7050 100755 (executable)
@@ -52,7 +52,7 @@ class AjaxableFormView(object):
                 redirect = request.GET.get('next')
                 if not ajax and redirect:
                     return HttpResponseRedirect(urlquote_plus(
-                            redirect, safe='/?='))
+                            redirect, safe='/?=&'))
                 response_data = {'success': True, 
                     'message': self.success_message, 'redirect': redirect}
             else:
index b874c4c..34c9c1f 100644 (file)
@@ -730,7 +730,13 @@ class CustomPDFFormView(AjaxableFormView):
     submit = _('Download')
 
     def __call__(self, request):
+        from copy import copy
         if request.method == 'POST':
-            return download_custom_pdf(request, request.GET['book_id'], method='POST')
-        else:
-            return super(CustomPDFFormView, self).__call__(request)
+            request.GET = copy(request.GET)
+            request.GET['next'] = "%s?%s" % (reverse('catalogue.views.download_custom_pdf', args=[request.GET['slug']]),
+                                             request.POST.urlencode())
+        return super(CustomPDFFormView, self).__call__(request)
+        
+
+    def success(self, *args):
+        pass
index 59abe0f..0506c8e 100644 (file)
@@ -38,7 +38,7 @@
        {% endif %}
       </li>
       <li>
-       <a href="{% url custom_pdf_form %}?book_id={{book.fileid}}" id="custom-pdf" class="ajaxable">{% trans "Download a custom PDF" %}</a>
+       <a href="{% url custom_pdf_form %}?slug={{book.slug}}" id="custom-pdf" class="ajaxable">{% trans "Download a custom PDF" %}</a>
       </li>
     </ul>
   </div>