Added attachments for customslide views. (Fixes #1681)

This commit is contained in:
Emanuel Schuetze 2016-01-09 17:06:15 +01:00
parent 8a6ca904dc
commit f2375008d8
5 changed files with 33 additions and 6 deletions

View File

@ -7,14 +7,14 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
('mediafiles', '0004_auto_20151210_0016'), ('mediafiles', '0002_auto_20160110_0103'),
('core', '0008_auto_20151210_0016'), ('core', '0001_initial'),
] ]
operations = [ operations = [
migrations.AddField( migrations.AddField(
model_name='customslide', model_name='customslide',
name='attachments', name='attachments',
field=models.ManyToManyField(to='mediafiles.Mediafile', verbose_name='Attachments', blank=True), field=models.ManyToManyField(to='mediafiles.Mediafile', blank=True),
), ),
] ]

View File

@ -130,7 +130,6 @@ class CustomSlide(RESTModelMixin, models.Model):
default=0) default=0)
attachments = models.ManyToManyField( attachments = models.ManyToManyField(
Mediafile, Mediafile,
verbose_name=ugettext_lazy('Attachments'),
blank=True) blank=True)
class Meta: class Meta:

View File

@ -186,6 +186,12 @@ angular.module('OpenSlidesApp.core', [
localKey: 'agenda_item_id', localKey: 'agenda_item_id',
localField: 'agenda_item', localField: 'agenda_item',
} }
},
hasMany: {
'mediafiles/mediafile': {
localField: 'attachments',
localKeys: 'attachments_id',
}
} }
} }
}); });

View File

@ -459,7 +459,8 @@ angular.module('OpenSlidesApp.core.site', [
.factory('CustomslideFormFieldFactory', [ .factory('CustomslideFormFieldFactory', [
'gettextCatalog', 'gettextCatalog',
'CKEditorOptions', 'CKEditorOptions',
function (gettextCatalog, CKEditorOptions) { 'Mediafile',
function (gettextCatalog, CKEditorOptions, Mediafile) {
return { return {
getFormFields: function () { getFormFields: function () {
return [ return [
@ -478,7 +479,21 @@ angular.module('OpenSlidesApp.core.site', [
label: gettextCatalog.getString('Text') label: gettextCatalog.getString('Text')
}, },
ngModelElAttrs: {'ckeditor': 'CKEditorOptions'} 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 ...')
}
},
];
} }
} }
} }

View File

@ -25,4 +25,11 @@
<div class="details"> <div class="details">
<div ng-bind-html="customslide.text"></div> <div ng-bind-html="customslide.text"></div>
<h3 ng-if="customslide.attachments.length > 0" translate>Attachments</h3>
<ul>
<li ng-repeat="attachment in customslide.attachments">
<a href="{{ attachment.mediafileUrl }}" target="_blank">
{{ attachment.title_or_filename }}
</a>
</ul>
</div> </div>