Fix error handling.
[redakcja.git] / src / wlxml / views.py
index 87780b7..3375b0d 100644 (file)
@@ -6,8 +6,9 @@ from . import models
 from librarian.dcparser import BookInfo
 from librarian.document import WLDocument
 from librarian.builders import StandaloneHtmlBuilder
 from librarian.dcparser import BookInfo
 from librarian.document import WLDocument
 from librarian.builders import StandaloneHtmlBuilder
-from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience
-from depot.legimi import legimi
+from librarian.meta.types.wluri import WLURI
+from librarian.meta.types.text import LegimiCategory, Epoch, Kind, Genre, Audience, ThemaCategory, MainThemaCategory
+from depot.publishers.legimi import Legimi
 
 
 class XslView(TemplateView):
 
 
 class XslView(TemplateView):
@@ -47,7 +48,28 @@ class TagView(DetailView):
 VALUE_TYPES = {
     LegimiCategory: {
         'widget': 'select',
 VALUE_TYPES = {
     LegimiCategory: {
         'widget': 'select',
-        'options': list(legimi.CATEGORIES.keys()),
+        'options': [''] + list(Legimi.CATEGORIES.keys()),
+    },
+    Audience: {
+        'autocomplete': {
+            'source': '/catalogue/terms/audience/',
+        }
+    },
+    ThemaCategory: {
+        'autocomplete': {
+            'source': '/catalogue/terms/thema/',
+        },
+        'chooser': {
+            'source': '/catalogue/chooser/thema/',
+        },
+    },
+    MainThemaCategory: {
+        'autocomplete': {
+            'source': '/catalogue/terms/thema-main/',
+        },
+        'chooser': {
+            'source': '/catalogue/chooser/thema-main/',
+        },
     },
     Epoch: {
         'autocomplete': {
     },
     Epoch: {
         'autocomplete': {
@@ -64,9 +86,63 @@ VALUE_TYPES = {
             'source': '/catalogue/terms/genre/',
         }
     },
             'source': '/catalogue/terms/genre/',
         }
     },
+    WLURI: {
+        "autocomplete": {
+            "source": "/catalogue/terms/wluri/",
+        }
+    },
+    "authors": {
+        "autocomplete": {
+            "source": "/catalogue/terms/author/",
+        }
+    },
+    "translators": {
+        "autocomplete": {
+            "source": "/catalogue/terms/author/",
+        }
+    },
+    "editors": {
+        "autocomplete": {
+            "source": "/catalogue/terms/editor/",
+        }
+    },
+    "technical_editors": {
+        "autocomplete": {
+            "source": "/catalogue/terms/editor/",
+        }
+    },
+    "type": {
+        "autocomplete": {
+            "source": ["text"]
+        }
+    },
+    "title": {
+        "autocomplete": {
+            "source": "/catalogue/terms/book_title/",
+        }
+    },
+
+    "language": {
+        'widget': 'select',
+        'options': [
+            '',
+            'pol',
+            'eng',
+            'fre',
+            'ger',
+            'lit',
+        ],
+    },
+    "publisher": {
+        "autocomplete": {
+            "source": ["Fundacja Wolne Lektury"]
+        }
+    },
+
 }
 
 }
 
-   
+
+
 class MetaTagsView(View):
     def get(self, request):
         fields = []
 class MetaTagsView(View):
     def get(self, request):
         fields = []
@@ -81,7 +157,15 @@ class MetaTagsView(View):
                     'name': f.value_type.__name__,
                 }
             }
                     'name': f.value_type.__name__,
                 }
             }
-            d['value_type'].update(VALUE_TYPES.get(f.value_type, {}))
+            d['value_type'].update(
+                VALUE_TYPES.get(
+                    f.value_type,
+                    VALUE_TYPES.get(
+                        f.name,
+                        {}
+                    )
+                )
+            )
             fields.append(d)
 
         return HttpResponse(
             fields.append(d)
 
         return HttpResponse(