当前位置: 首页>>代码示例>>Python>>正文


Python Message.parent_msg方法代码示例

本文整理汇总了Python中django_messages.models.Message.parent_msg方法的典型用法代码示例。如果您正苦于以下问题:Python Message.parent_msg方法的具体用法?Python Message.parent_msg怎么用?Python Message.parent_msg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django_messages.models.Message的用法示例。


在下文中一共展示了Message.parent_msg方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, sender, parent_msg=None):
     recipients = self.cleaned_data['recipient']
     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 = datetime.datetime.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
开发者ID:kanimozhimurugan,项目名称:Nxt4,代码行数:28,代码来源:forms.py

示例2: send_reply

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
def send_reply(request,msg_body,msg_subject,msg_receiver,parent_id):
  '''
        JSON-RPC view : meow.sendMsgReply
        
        Returns True, if the currently authenticated user is successful in sending the reply message.
	
	Inbound parameters: test string 'msg_body' & 'msg_subject'. text string 'msg_receiver' shld
        be username of MEOW user, 'parent_id' shld be the msg id of an existing mesage.

	Requires authentication to call this function.
  '''
 
  try:
	   logging.debug('start meow.sendMsgReply with %s %s %s %d ' %  (msg_body,msg_subject,msg_receiver, parent_id))
	   msg_receiver_user = User.objects.all().filter(username=msg_receiver)
	   if len(msg_receiver_user) != 1:
		return False
	   msg_receiver_user = msg_receiver_user[0]
	   logging.debug(" MSG %s %s %s %s  %d" % (request.user, msg_receiver_user, msg_subject, msg_body,parent_id))
	   msg = Message(
				sender = request.user,
				recipient = msg_receiver_user,
				subject = msg_subject,
				body = msg_body,
			    )
	   parent_msg_obj = Message.objects.filter(id=parent_id)
	   if (len(parent_msg_obj)!=1):
		return False
	   msg.parent_msg=parent_msg_obj[0]
	   msg.save()
	   return True
  except:
	logging.error('meow.sendMsgReply got exception')
	return False
开发者ID:Harinder,项目名称:MEOW,代码行数:36,代码来源:views.py

示例3: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, sender, parent_msg=None):
     recipients = self.cleaned_data['recipient']
     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)
         UserOnBoardNotification.objects.create(user=r, title="Nachricht", notify_typ="info",
                                                notify_message="Hallo, " + str(
                                                    sender) + " hat Ihnen eine Nachricht zugesendet!")
         UserOnBoardNotification.objects.create(user=sender, title="Nachricht", notify_typ="info",
                                                notify_message="Ihr Nachricht wurde erfolgreich versendet!")
         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
开发者ID:tobiasgoecke,项目名称:django-messages,代码行数:33,代码来源:forms.py

示例4: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, sender, parent_msg=None):
     if sender is None:
         raise ValidationError(self.error_messages['empty_sender'], code='empty_sender')
     recipients = self.cleaned_data['recipient']
     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
开发者ID:dsalaj,项目名称:django-messages,代码行数:30,代码来源:forms.py

示例5: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, parent_msg=None):
     # recipients = self.cleaned_data['recipient']
     recipient = self.cleaned_data['recipient']
     subject = self.cleaned_data['subject']
     body = self.cleaned_data['body']
     # for r in recipients:
     r = recipient
     if True:
         msg = Message(
             sender = self.sender,
             recipient = r,
             subject = subject,
             body = body,
         )
         if parent_msg is not None:
             msg.parent_msg = parent_msg
             parent_msg.replied_at = datetime.datetime.now()
             parent_msg.save()
             msg.conversation = parent_msg.conversation
         msg.save()
         # FIXME: workaround to make sure msg.conversation is saved
         #        even when creating a new conversation
         if not msg.conversation:
             msg.conversation = msg
             msg.save()
     return msg
开发者ID:liberation,项目名称:django-messages,代码行数:28,代码来源:forms.py

示例6: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, sender, parent_msg=None):
     recipients = self.cleaned_data['recipient']
     subject = self.cleaned_data['subject']
     body = self.cleaned_data['body']
     message_list = []
     final_recipients = set()
     for r in recipients:
         if isinstance(r, User):
             final_recipients.add(r)
         elif isinstance(r, Group):
             [final_recipients.add(u) for u in r.user_set.all()]
         else:
             raise NotImplementedError
     for r in final_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 = datetime.datetime.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
开发者ID:rogerso,项目名称:django-messages,代码行数:36,代码来源:forms.py

示例7: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, sender, parent_msg=None):
     recipients = self.cleaned_data['recipient']
     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 = datetime.datetime.now()
             parent_msg.save()
         msg.save()
         message_list.append(msg)
     return message_list
开发者ID:Fandekasp,项目名称:django-messages,代码行数:21,代码来源:forms.py

示例8: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def save(self, sender, parent_msg=None):
     recipients = self.cleaned_data["recipient"]
     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 = datetime.datetime.now()
             parent_msg.save()
         msg.save()
         message_list.append(msg)
         # some notification message should not send here,such as
         # 'messages_replied' and 'messages_sent'
         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
开发者ID:jresins,项目名称:django-messages,代码行数:25,代码来源:forms.py

示例9: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
    def save(self, sender, parent_msg=None):
        groupname = self.cleaned_data['recipient']
        subject = self.cleaned_data['subject']
        body = self.cleaned_data['body']
        message_list = []

        # Added by SFH - Process group messages if present
        # Group identifiers are in the form "group-offering-12345" or "group-world-3434"
        if groupname.startswith("group-"):
            grouptype = groupname.split('-')[1]
            groupid = groupname.split('-')[2]

            if grouptype == "offering":
                offering = Offering.objects.get(course_sec_id=groupid)
                recipients = [profile.user for profile in offering.students.all()]

        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
开发者ID:cca,项目名称:django-messages,代码行数:39,代码来源:forms.py

示例10: send_reply

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
 def send_reply(self, parent_msg, body):
     message_list = []
     recipient = parent_msg.sender
     sender = parent_msg.recipient
     subject = "re: %s" % re.sub(r"^(re:\s*)+","",parent_msg.subject)
     msg = Message(
         sender = sender,
         recipient = recipient,
         subject = subject,
         body = body,
     )
     msg.parent_msg = parent_msg
     parent_msg.replied_at = datetime.datetime.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([recipient], "messages_reply_received", {'message': msg,}, from_address=settings.MESSAGES_HANDLER_ADDRESS)
         else:
             notification.send([sender], "messages_sent", {'message': msg,})
             notification.send([recipient], "messages_received", {'message': msg,}, from_address=settings.MESSAGES_HANDLER_ADDRESS)
     return message_list
开发者ID:JordanReiter,项目名称:django-messages,代码行数:26,代码来源:process_message.py

示例11: save

# 需要导入模块: from django_messages.models import Message [as 别名]
# 或者: from django_messages.models.Message import parent_msg [as 别名]
    def save(self, sender, parent_msg=None):
        recipients = self.cleaned_data['recipient']
        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()
                signals.message_repled.send(sender=ComposeForm, message=msg, user=sender)
            else:
                msg.save()
                signals.message_sent.send(sender=ComposeForm, message=msg, user=sender)

            message_list.append(msg)
        return message_list
开发者ID:arsham,项目名称:django-messages,代码行数:26,代码来源:forms.py


注:本文中的django_messages.models.Message.parent_msg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。