Esempio n. 1
0
 def save(self, sender, parent_msg=None):
     recipients = self.friends_list
     subject = self.cleaned_data['subject']
     body = self.cleaned_data['body']
     message_list = []
     for r in recipients:
         msg = Message(
             sender=sender,
             recipient=r,
             subject=subject,
             body=body,
         )
         if parent_msg is not None:
             msg.parent_msg = parent_msg
             parent_msg.replied_at = timezone.now()
             parent_msg.save()
         msg.save()
         message_list.append(msg)
         if notification:
             if parent_msg is not None:
                 notification.send([sender], "messages_replied",
                                   {'message': msg})
                 notification.send([r], "messages_reply_received",
                                   {'message': msg})
             else:
                 notification.send([sender], "messages_sent",
                                   {'message': msg})
                 notification.send([r], "messages_received",
                                   {'message': msg})
     return message_list