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


Python Message.time方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import time [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: save

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import time [as 别名]
 def save(self, author, reciever):
     new = Message()
     new.user1 = author
     new.user2 = reciever
     new.time = datetime.now()
     new.title = self.cleaned_data['title']
     new.text = self.cleaned_data['text']
     new.save()
开发者ID:romanvlasiuk,项目名称:MyNetwork,代码行数:10,代码来源:forms.py

示例3: thread

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import time [as 别名]
def thread(request, **args):
    t = loader.get_template("discussion.view")
    thread = None
    if "id" in args:
        thread = Thread.objects.get(id=int(args["id"]))

    message_form = None

    if thread and thread.openForEvent():
        if request.method == "POST":
            # Post dictionary needs to be mutable in order to remove the value from the messagebox
            post_vars = {}
            for key in request.POST:
                post_vars[key] = request.POST[key]

            message_form = MessageForm(post_vars)
            if message_form.is_valid():
                message = Message()
                message.content = message_form.cleaned_data["content"]
                message_form.data["content"] = ""
                message.time = datetime.now()
                message.user = request.user
                message.thread = thread
                message.save()
        else:
            message_form = MessageForm()

    c = {
        "thread": thread,
        "thread_message": thread.getStatusMessage(),
        "thread_status": thread.getStatus(),
        "messages": None,
        "message_form": message_form,
        "is_authenticated": request.user.is_authenticated(),
    }

    if thread:
        messages = Message.objects.filter(thread__id=thread.id)
        c["messages"] = messages

    c.update(csrf(request))
    return HttpResponse(t.render(Context(c)))
开发者ID:jeroen51,项目名称:Game-calendar,代码行数:44,代码来源:discussion.py

示例4: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import time [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.time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。