diff --git a/openslides/motion/forms.py b/openslides/motion/forms.py
index 80be63255..21f90cfc2 100644
--- a/openslides/motion/forms.py
+++ b/openslides/motion/forms.py
@@ -14,6 +14,7 @@ from django import forms
from django.utils.translation import ugettext_lazy
from openslides.config.api import config
+from openslides.mediafile.models import Mediafile
from openslides.utils.forms import (CleanHtmlFormMixin, CssClassMixin,
LocalizedModelChoiceField)
from openslides.utils.person import MultiplePersonFormField, PersonFormField
@@ -48,13 +49,22 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
Reason of the motion. will be saved in a MotionVersion object.
"""
+ attachments = forms.ModelMultipleChoiceField(
+ queryset=Mediafile.objects.all(),
+ required=False,
+ label=ugettext_lazy('Attachments'))
+ """
+ Attachments of the motion.
+ """
+
class Meta:
model = Motion
fields = ()
def __init__(self, *args, **kwargs):
"""
- Fill the FormFields releated to the version data with initial data.
+ Fill the FormFields related to the version data with initial data.
+ Fill also the initial data for attachments.
"""
self.motion = kwargs.get('instance', None)
self.initial = kwargs.setdefault('initial', {})
@@ -63,6 +73,7 @@ class BaseMotionForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
self.initial['title'] = last_version.title
self.initial['text'] = last_version.text
self.initial['reason'] = last_version.reason
+ self.initial['attachments'] = self.motion.attachments.all()
else:
self.initial['text'] = config['motion_preamble']
super(BaseMotionForm, self).__init__(*args, **kwargs)
diff --git a/openslides/motion/models.py b/openslides/motion/models.py
index c0d9a01b4..5c281d625 100644
--- a/openslides/motion/models.py
+++ b/openslides/motion/models.py
@@ -21,6 +21,7 @@ from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy, ugettext_noop
from openslides.config.api import config
+from openslides.mediafile.models import Mediafile
from openslides.poll.models import (BaseOption, BasePoll, BaseVote,
CountInvalid, CountVotesCast)
from openslides.projector.models import RelatedModelMixin, SlideMixin
@@ -78,6 +79,11 @@ class Motion(SlideMixin, models.Model):
ForeignKey to one category of motions.
"""
+ attachments = models.ManyToManyField(Mediafile)
+ """
+ Many to many relation to mediafile objects.
+ """
+
# TODO: proposal
#master = models.ForeignKey('self', null=True, blank=True)
diff --git a/openslides/motion/templates/motion/motion_detail.html b/openslides/motion/templates/motion/motion_detail.html
index ad51aac62..680e8663c 100644
--- a/openslides/motion/templates/motion/motion_detail.html
+++ b/openslides/motion/templates/motion/motion_detail.html
@@ -89,6 +89,17 @@
{{ reason|safe|default:'–' }}
+
+ {% with attachments=motion.attachments.all %}
+ {% if attachments %}
+