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


Python Message.recipient方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import recipient [as 别名]
 def post(self):
   text = cgi.escape(self.request.get('text'))
   sender = cgi.escape(self.request.get('sender'))
   recipient = cgi.escape(self.request.get('recipient'))
   subject = cgi.escape(self.request.get('subject'))
   parent_message = cgi.escape(self.request.get('parent'))
   q = User.query(User.username == recipient)
   user = q.get()
   if(user):
     if len(parent_message) > 0:
       message_key = ndb.Key(urlsafe=parent_message)
       message = Message(parent = message_key)
     else:
       message = Message()
     message.subject = subject
     message.text = text
     message.sender = sender
     message.recipient = recipient
     message.time = datetime.datetime.now() - datetime.timedelta(hours=7) #For PST
     message.put()
     #Increment message count for navbar
     q = User.query(User.username == recipient)
     user = q.get()
     user.message_count += 1
     user.put()
     self.redirect('/messages')
   else:
     self.redirect('/compose')
开发者ID:tungply7,项目名称:Tutoring-Service,代码行数:30,代码来源:Messages.py

示例2: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import recipient [as 别名]
 def post(self):

    recipient = cgi.escape(self.request.get('recipient'))
    text = cgi.escape(self.request.get('text'))
    sender = cgi.escape(self.request.get('sender'))


    #create msg and put

    #is this conversation already existed?
    #Yes
        #attach message
    #No create a new one
        #owner, sender, msg

    #put

    #There's a new coming msg to owner
    mesg = Message()
    mesg.time = datetime.datetime.now() - datetime.timedelta(hours=8)
    mesg.sender = sender
    mesg.recipient = recipient
    mesg.text = text
    mesg.put()
    
    owners_temp = []
    owners_temp.append(sender)
    owners_temp.append(recipient)

    temp1 = " ".join((sender, recipient))
    temp2 = " ".join((recipient, sender))

    recipient_user = User.query(User.username == recipient).get()
    if recipient_user:
        recipient_user.msg_count += 1
    recipient_user.put()



    
    conversation_qry = Conversation.query(ndb.OR(Conversation.owners == temp1, Conversation.owners == temp2)).get()
    
    if conversation_qry:
        logging.info("yes")
        #logging.info(conversation_qry.owners)
        conversation_qry.children.append(mesg.key)
        conversation_qry.msg_count = conversation_qry.msg_count + 1
        conversation_qry.most_recent_msg = mesg.text
        conversation_qry.most_recent_date = str(mesg.time)


        conversation_qry.put()
        
    else:
        logging.info("noooooooooo")
        #logging.info(conversation_qry)
        conv = Conversation()
        conv.sender = sender
        conv.recipient = recipient
        conv.owners = " ".join((sender, recipient))
        conv.children.append(mesg.key)
        conv.msg_count = conv.msg_count + 1
        conv.most_recent_msg = mesg.text
        conv.most_recent_date = str(mesg.time)
        conv.put()
开发者ID:nikko0327,项目名称:Ninja-Tutor,代码行数:67,代码来源:Conversation.py


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