From 7d6fe886cb8f50060e5d5214073ace9ed5218744 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 13 Apr 2017 18:01:15 +0200 Subject: [PATCH] tags in editor metadata window --- apps/wiki/templates/wiki/bootstrap.html | 12 +++++++----- apps/wiki/views.py | 3 ++- redakcja/static/js/catalogue/catalogue.js | 19 ++++++++++--------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apps/wiki/templates/wiki/bootstrap.html b/apps/wiki/templates/wiki/bootstrap.html index 1a380b46..1298fa69 100644 --- a/apps/wiki/templates/wiki/bootstrap.html +++ b/apps/wiki/templates/wiki/bootstrap.html @@ -81,14 +81,16 @@ 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} ] } diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 6a5f2ac5..e0e2f085 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -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, }) diff --git a/redakcja/static/js/catalogue/catalogue.js b/redakcja/static/js/catalogue/catalogue.js index a750b77b..04fedce7 100755 --- a/redakcja/static/js/catalogue/catalogue.js +++ b/redakcja/static/js/catalogue/catalogue.js @@ -51,16 +51,17 @@ } }); - $('.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 -- 2.20.1