Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions django_messages/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
else:
notification = None

from django_messages.models import Message
from django_messages.models import Message, Attachment
from django_messages.fields import CommaSeparatedUserField

class ComposeForm(forms.Form):
Expand All @@ -19,6 +19,11 @@ class ComposeForm(forms.Form):
subject = forms.CharField(label=_(u"Subject"), max_length=140)
body = forms.CharField(label=_(u"Body"),
widget=forms.Textarea(attrs={'rows': '12', 'cols':'55'}))
attachments = forms.FileField(
label=_('Attachments'),
widget=forms.ClearableFileInput(attrs={'multiple': True}),
required=False
)


def __init__(self, *args, **kwargs):
Expand All @@ -28,7 +33,7 @@ def __init__(self, *args, **kwargs):
self.fields['recipient']._recipient_filter = recipient_filter


def save(self, sender, parent_msg=None):
def save(self, sender, parent_msg=None, files=[]):
recipients = self.cleaned_data['recipient']
subject = self.cleaned_data['subject']
body = self.cleaned_data['body']
Expand All @@ -45,6 +50,9 @@ def save(self, sender, parent_msg=None):
parent_msg.replied_at = timezone.now()
parent_msg.save()
msg.save()
for f in files:
attachment = Attachment(file=f, message=msg)
attachment.save()
message_list.append(msg)
if notification:
if parent_msg is not None:
Expand Down
Binary file modified django_messages/locale/ar/LC_MESSAGES/django.mo
Binary file not shown.
Loading