本文整理汇总了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')
示例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()