Updating metadata configuration for editor
[redakcja.git] / apps / catalogue / views.py
index ebc3575..981206c 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 from datetime import datetime, date, timedelta
 import logging
 import os
 from datetime import datetime, date, timedelta
 import logging
 import os
@@ -26,7 +27,7 @@ from catalogue import forms
 from catalogue import helpers
 from catalogue.helpers import active_tab
 from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord, Project
 from catalogue import helpers
 from catalogue.helpers import active_tab
 from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord, Project
-from fileupload.views import UploadView
+from fileupload.views import UploadView, PackageView
 
 #
 # Quick hack around caching problems, TODO: use ETags
 
 #
 # Quick hack around caching problems, TODO: use ETags
@@ -114,12 +115,11 @@ def create_missing(request, slug=None):
                 gallery=form.cleaned_data['gallery'],
             )
 
                 gallery=form.cleaned_data['gallery'],
             )
 
-            return http.HttpResponseRedirect(reverse("catalogue_book", args=[book.slug]))
+            return http.HttpResponseRedirect(reverse("wiki_editor", args=[book.slug]))
     else:
         form = forms.DocumentCreateForm(initial={
                 "slug": slug,
                 "title": slug.replace('-', ' ').title(),
     else:
         form = forms.DocumentCreateForm(initial={
                 "slug": slug,
                 "title": slug.replace('-', ' ').title(),
-                "gallery": slug,
         })
 
     return render(request, "catalogue/document_create_missing.html", {
         })
 
     return render(request, "catalogue/document_create_missing.html", {
@@ -488,19 +488,26 @@ def publish(request, slug):
         return http.HttpResponseRedirect(book.get_absolute_url())
 
 
         return http.HttpResponseRedirect(book.get_absolute_url())
 
 
-class GalleryView(UploadView):
+class GalleryMixin(object):
+    def get_directory(self):
+        return "%s%s/" % (settings.IMAGE_DIR, self.object.gallery)
     def get_object(self, request, slug):
         book = get_object_or_404(Book, slug=slug)
         if not book.gallery:
             raise Http404
         return book
 
     def get_object(self, request, slug):
         book = get_object_or_404(Book, slug=slug)
         if not book.gallery:
             raise Http404
         return book
 
+class GalleryView(GalleryMixin, UploadView):
+
     def breadcrumbs(self):
         return [
     def breadcrumbs(self):
         return [
-            (_('books'), reverse('catalogue_document_list')),
+            (u'moduły', reverse('catalogue_document_list')),
             (self.object.title, self.object.get_absolute_url()),
             (self.object.title, self.object.get_absolute_url()),
-            (_('scan gallery'),),
+            (u'materiały',),
         ]
 
         ]
 
-    def get_directory(self):
-        return "%s%s/" % (settings.IMAGE_DIR, self.object.gallery)
+
+class GalleryPackageView(GalleryMixin, PackageView):
+
+    def get_redirect_url(self, slug):
+        return reverse('catalogue_book_gallery', kwargs = dict(slug=slug))