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


Python Message.sender方法代码示例

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


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

示例1: post

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

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import sender [as 别名]
def import_message(gmail_message, account, save_attachments=True):
    # see if the message is already in the db
    if len(Message.objects.filter(message_id=gmail_message.message_id)) > 0:
        # already exists, skip
        # print "Message Id %s already in database, skipping (Subject: %s)" % (gmail_message.message_id, gmail_message.subject)
        # maybe update read status, or inbox status if I can figure out how to do that?
        return None

    new_message = Message(subject=gmail_message.subject,
                          sent_date=gmail_message.sent_at,
                          message_id=gmail_message.message_id,
                          thread_id=gmail_message.thread_id,
                          account=account)
    # new_message.save()
    # add the senders
    new_message.sender = get_or_create_person(gmail_message.fr)
    new_message.save()
    new_message.members.add(new_message.sender.person)
    for person in gmail_message.to + gmail_message.cc:
        p = get_or_create_person(person)
        new_message.recipients.add(p)
        new_message.members.add(p.person)

    new_message.save()
    if gmail_message.body:
        body_text = MessageBody(message=new_message,
                                type='text',
                                content=gmail_message.body)
        body_text.save()

    if gmail_message.html:
        body_html = MessageBody(message=new_message,
                                type='html',
                                content=gmail_message.html)
        body_html.save()

    if not gmail_message.is_read():
        new_message.flags.add(MessageFlag(flag=MessageFlag.UNREAD_FLAG))

    # add the headers
    for k, v in gmail_message.headers.iteritems():
        new_message.headers.add(Header(key=k, value=v))

    # need to handle attachments
    if save_attachments:
        for att, related in gmail_message.attachments:
            handle_attachment(new_message, att, related)

    return new_message
开发者ID:thechild,项目名称:mbox2sql,代码行数:51,代码来源:importing.py

示例3: post

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

        file = request.FILES.get('file')
        content = request.POST.get('message')
        sender = request.user
        message = Message()

        message.file=file


        # print message.file

        message.content=content
        message.receiver = kwargs['receiver']
        message.sender=User.objects.get(username=sender)
        message.sender_full_name = message.sender.userprofile.get_full_name()
        print message.sender_full_name
        message.save()

        # print message
        #
        # print message.file


        # print (request.user)

        messages = Message.objects.filter(Q(sender=request.user, receiver=kwargs['receiver']) | Q(sender=User.objects.get(username=kwargs['receiver']), receiver=request.user))

        messages5 = Message.objects.filter(Q(sender=request.user) | Q(receiver=request.user))[::-1]
        if len(messages5) <=5:
            message5 = messages5
        else :
            message5 = messages5[:5]

        # message5=message5[::-1]

        # print profile

        profile = User.objects.filter(username=kwargs['receiver'])[0]

        auth_form = AuthenticateForm()


        return render(request, 'message.html', {'messages':messages, 'profile':profile ,'auth_form':auth_form, 'message5':message5})
开发者ID:bh00t,项目名称:donateinbd,代码行数:46,代码来源:views.py

示例4: tnx

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import sender [as 别名]
        def tnx():
            
            service = Service.get_by_key_name(u"<%s>" % self.request.get("service_id"))
            if not service:
                error["message"] = _("Service not found")
                return

            service.messages += 1
            memcache.set(u"service-%s" % self.request.get("service_id"), service)
            
            message = Message(key_name = u"<%s>" % self.request.get("message_id"), parent = service)
            message.service   = service
            message.message_id= self.request.get("message_id")
            message.message   = self.request.get("message").strip()
            message.sender    = self.request.get("sender")
            message.country   = self.request.get("country")
            message.price     = int(float(self.request.get("price").strip())*100)
            message.currency  = self.request.get("currency")
            message.keyword   = self.request.get("keyword")
            message.shortcode = self.request.get("shortcode")
            message.operator  = self.request.get("operator")
            message.test      = self.request.get("test") == "true"
            
            db.put([message, service])
开发者ID:andris9,项目名称:VoteSMS,代码行数:26,代码来源:main.py

示例5: Message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import sender [as 别名]
from models import BaseModel, User, Conversation, ConversationParty, Message, MessageType, database
from datetime import datetime

# Messages
m = Message()
m.conversation = Conversation.get(Conversation.id==1)
m.sender = User.get(User.id==1)
m.message_type = MessageType.get(MessageType.name=='directive_quotation_mt')
m.ts = datetime.now()

args = {'currency':'R$',
		'per_day_beneficiary_value':'20.50',
		'number_of_beneficiaries':'5',
		'company_name':'VR',
		'company_picture':''
	   }

with database.transaction():
	m.save()
	m.run_constructor(args)
	m.save()
开发者ID:FelipePiacsek,项目名称:chat_angular,代码行数:23,代码来源:05_messages.py

示例6: post

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

示例7: Http404

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import sender [as 别名]
    host: The hostname of the computer the client is running on
    """
    if request.method != "POST":
        print "Did not post"
        raise Http404("You must post to this URL")

    receiver_account = get_or_create_account(protocol, request.POST["receiver_account"], request.POST["owner_account"])
    sender_account = get_or_create_account(protocol, request.POST["sender_account"], request.POST["owner_account"])  
    if sender_account.full_name == "":
        sender_account.full_name = request.POST["alias"]
        sender_account.save()
    
    try:
        timestamp = datetime.datetime.strptime(request.POST["timestamp"][:-6], "%Y-%m-%dT%H:%M:%S")
    except Exception, e:
        print e.message
        timestamp = datetime.datetime.strptime(request.POST["timestamp"][:-6], "%Y-%m-%d %H:%M:%S")
    messages = Message.objects.filter(sender=sender_account).filter(receiver=receiver_account).filter(timestamp=timestamp)
    if len(messages) > 0:
        return HttpResponse(simplejson.dumps({"result":False,"reason":"Duplicate message"}), mimetype="application/json")
    message = Message()
    message.receiver = receiver_account
    message.sender = sender_account
    message.timestamp = timestamp
    message.text = request.POST["message_text"]
    message.client_type = request.POST["client_type"]
    message.host = request.POST["host"]
    message.save()

    data = simplejson.dumps({"result":True})
    return HttpResponse(data, mimetype="application/json")
开发者ID:tangerilli,项目名称:dool,代码行数:33,代码来源:views.py

示例8: send_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import sender [as 别名]
 def send_message(self, receiver, message):
     msg = Message(receiver=receiver, message=message)
     msg.sender = self.node.hashsum
     self.session.add(msg)
     self.session.commit()
开发者ID:nijotz,项目名称:dht-experiment,代码行数:7,代码来源:node.py


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