tags in editor metadata window
authorJan Szejko <janek37@gmail.com>
Thu, 13 Apr 2017 16:01:15 +0000 (18:01 +0200)
committerJan Szejko <janek37@gmail.com>
Thu, 13 Apr 2017 16:01:15 +0000 (18:01 +0200)
apps/wiki/templates/wiki/bootstrap.html
apps/wiki/views.py
redakcja/static/js/catalogue/catalogue.js

index 1a380b4..1298fa6 100644 (file)
                     core: {
                         templates: {{serialized_templates|safe}},
                         metadata: [
-                            {key: 'audience', values: [
-                                '3-6', '6-9', '9-12', '12-18', '18+', 'Adults'
-                            ]},
+                            {% for category in tag_categories %}
+                                {key: '{{ category.dc_tag }}', values: [
+                                    {% for tag in category.tag_set.all %}
+                                        '{{ tag.dc_value }}'{% if not forloop.last %},{% endif %}
+                                    {% endfor %}
+                                ]},
+                            {% endfor %}
                             {key: 'creator'},
                             {key: 'description'},
                             {key: 'publisher'},
-                            {key: 'language'},
-                            {key: 'rights'},
                             {key: 'relation.coverimage.url', isFile: true}
                         ]
                     }
index 6a5f2ac..e0e2f08 100644 (file)
@@ -20,7 +20,7 @@ from django.utils.translation import ugettext as _
 from django.views.decorators.http import require_POST
 from django.shortcuts import get_object_or_404, render
 
-from catalogue.models import Document, Template
+from catalogue.models import Document, Template, Category
 from dvcs.models import Revision
 import nice_diff
 from wiki import forms
@@ -82,6 +82,7 @@ def editor(request, pk, template_name='wiki/bootstrap.html'):
             "text_revert": forms.DocumentTextRevertForm(prefix="textrevert"),
             "text_publish": forms.DocumentTextPublishForm(prefix="textpublish"),
         },
+        'tag_categories': Category.objects.all(),
         'pk': doc.pk,
     })
 
index a750b77..04fedce 100755 (executable)
             }
         });
 
-        $('.chosen-select').chosen().each(function() {
-            var widget = $(this.nextSibling), $t = $(this);
-            $.each($.merge([], this.attributes), function() {
-                if (this.name.substr(0, 5) === 'data-') {
-                    $t.removeAttr(this.name);
-                    widget.attr(this.name, this.value);
-                }
+        if ($.isFunction($.fn.chosen)) {
+            $('.chosen-select').chosen().each(function () {
+                var widget = $(this.nextSibling), $t = $(this);
+                $.each($.merge([], this.attributes), function () {
+                    if (this.name.substr(0, 5) === 'data-') {
+                        $t.removeAttr(this.name);
+                        widget.attr(this.name, this.value);
+                    }
+                });
             });
-        });
-
+        }
 
 
         // tutorial mode