diff --git a/openslides/core/migrations/0009_customslide_attachments.py b/openslides/core/migrations/0002_customslide_attachments.py similarity index 72% rename from openslides/core/migrations/0009_customslide_attachments.py rename to openslides/core/migrations/0002_customslide_attachments.py index 5bc673e1a..4baadffbd 100644 --- a/openslides/core/migrations/0009_customslide_attachments.py +++ b/openslides/core/migrations/0002_customslide_attachments.py @@ -7,14 +7,14 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ - ('mediafiles', '0004_auto_20151210_0016'), - ('core', '0008_auto_20151210_0016'), + ('mediafiles', '0002_auto_20160110_0103'), + ('core', '0001_initial'), ] operations = [ migrations.AddField( model_name='customslide', name='attachments', - field=models.ManyToManyField(to='mediafiles.Mediafile', verbose_name='Attachments', blank=True), + field=models.ManyToManyField(to='mediafiles.Mediafile', blank=True), ), ] diff --git a/openslides/core/models.py b/openslides/core/models.py index d51803f61..7ebb84df6 100644 --- a/openslides/core/models.py +++ b/openslides/core/models.py @@ -130,7 +130,6 @@ class CustomSlide(RESTModelMixin, models.Model): default=0) attachments = models.ManyToManyField( Mediafile, - verbose_name=ugettext_lazy('Attachments'), blank=True) class Meta: diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 2f78980dc..fa0bc172b 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -186,6 +186,12 @@ angular.module('OpenSlidesApp.core', [ localKey: 'agenda_item_id', localField: 'agenda_item', } + }, + hasMany: { + 'mediafiles/mediafile': { + localField: 'attachments', + localKeys: 'attachments_id', + } } } }); diff --git a/openslides/core/static/js/core/site.js b/openslides/core/static/js/core/site.js index 0afcce9ef..642ce1044 100644 --- a/openslides/core/static/js/core/site.js +++ b/openslides/core/static/js/core/site.js @@ -459,7 +459,8 @@ angular.module('OpenSlidesApp.core.site', [ .factory('CustomslideFormFieldFactory', [ 'gettextCatalog', 'CKEditorOptions', - function (gettextCatalog, CKEditorOptions) { + 'Mediafile', + function (gettextCatalog, CKEditorOptions, Mediafile) { return { getFormFields: function () { return [ @@ -478,7 +479,21 @@ angular.module('OpenSlidesApp.core.site', [ label: gettextCatalog.getString('Text') }, ngModelElAttrs: {'ckeditor': 'CKEditorOptions'} - }]; + }, + { + key: 'attachments_id', + type: 'ui-select-multiple', + templateOptions: { + label: gettextCatalog.getString('Attachment'), + optionsAttr: 'bs-options', + options: Mediafile.getAll(), + ngOptions: 'option[to.valueProp] as option in to.options | filter: $select.search', + valueProp: 'id', + labelProp: 'title_or_filename', + placeholder: gettextCatalog.getString('Select or search an attachment ...') + } + }, + ]; } } } diff --git a/openslides/core/static/templates/core/customslide-detail.html b/openslides/core/static/templates/core/customslide-detail.html index 1e7a5efc4..383ea335a 100644 --- a/openslides/core/static/templates/core/customslide-detail.html +++ b/openslides/core/static/templates/core/customslide-detail.html @@ -25,4 +25,11 @@