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


Python Message.message方法代码示例

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


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

示例1: message_out

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import message [as 别名]
def message_out():
#    login.logout_user()
    org_form = SelectOrgForm(Orgs=build_orgs())
    print build_orgs().choices[0]
    message_form = MessageForm(Choices=build_users(build_orgs().choices[0][1]))
    save_org = build_orgs().choices[0][1]
    if request.method == 'POST':
        if request.form['btn']=="select":
            print "select"
            d_choices = dict(build_orgs().choices)
            print d_choices[org_form.org.data]
            save_org = d_choices[org_form.org.data]
            message_form = MessageForm(Choices=build_users(d_choices[org_form.org.data]))
        else:
            print "send"
            print save_org
            if save_org is None:
                print "None"
            else:
                d2_choices = dict(build_users(save_org).choices)
                print d2_choices[message_form.name_to.data]
            message = Message()
            message.addr = d2_choices[message_form.name_to.data]
            message.subject = str(message_form.subject.data)
            message.message = str(message_form.content.data)
            message.save()
            flash("Message Sent", category='success')
#    message_form = MessageForm()
    return render_template('forum/org_list.html' ,form=org_form, message_form=message_form)
开发者ID:sheng01,项目名称:DuluthKids.Net,代码行数:31,代码来源:views.py

示例2: send

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import message [as 别名]
def send(request):
    if request.method == 'POST':
        if len(request.POST[u'message_to_random_user']):
            message = Message()
            message.from_user = request.user
            message.to_user = get_random_user(request.user)
            message.message = request.POST[u'message_to_random_user']
            message.date = datetime.now()
            message.save()
    return render(request, 'send.html', {'rand_user': get_random_user(request.user)})
开发者ID:kosiovekilski,项目名称:chatter,代码行数:12,代码来源:views.py

示例3: send_broadcast

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import message [as 别名]
def send_broadcast(request, event_id=None):

    me = request.user
    to = request.DATA.get("to")
    title = request.DATA.get("title")
    msg = request.DATA.get("message")

    event = Event.objects.filter(id=event_id).first()
    if not event:
        return Response({
            "status": HTTP_404_NOT_FOUND,
            "message": "Event not found"
        }, status=HTTP_404_NOT_FOUND)

    event_organization = event.owner
    user_organization = OrganizationMember.user_organization(me)
    if event_organization != user_organization:
        return Response({
            "status": HTTP_401_UNAUTHORIZED,
            "message": "You are not an authorized member of the event's organization"
        }, status=HTTP_401_UNAUTHORIZED)

    if not OrganizationMember.user_is_admin(user_organization, me):
        return Response({
            "status": HTTP_401_UNAUTHORIZED,
            "message": "You must be an administrator to broadcast messages"
        }, status=HTTP_401_UNAUTHORIZED)

    if to == "ALL":
        recipients = User.objects.all()
    elif to == "CASTING":
        recipients = User.objects.filter(my_user__type='C')
    else:
        recipients = User.objects.filter(my_user__type='T')

    for recipient in recipients:
        message = Message()
        message.from_user = me
        message.to_user = recipient
        message.title = title
        message.message = msg
        message.save()
        create_notification("MSG", message.id, me, recipient, message=msg)

    serializer = PlainMessageSerializer({
        "status": HTTP_200_OK,
        "message": "Broadcast sent."
    })
    return Response(serializer.data)
开发者ID:aftabaig,项目名称:py_castm,代码行数:51,代码来源:views.py

示例4: send_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import message [as 别名]
def send_message(request):
    """
    Sends a message to a linked user.
    Allowed HTTP methods are:\n
        1. POST to send\n
            Accepts following hash:\n
            . {\n
                "to": [user_id],\n
                "title": [message_title],\n
                "message": [the_message]\n
            }\n
            Returns:\n
            . Newly created message
    Status:\n
        1. 200 on success
        2. 400 if some error occurs
        3. 401 if un-authorized
        4. 404 if user not found
    Notes:\n
        1. Require user's token to be sent in the header as:\n
            Authorization: Token [token]\n
    """
    me = request.user
    to_id = request.DATA.get("to")
    title = request.DATA.get("title")
    msg = request.DATA.get("message")
    to = User.objects.filter(id=to_id).first()

    if to:
        if Link.is_already_link(me, to):
            message = Message()
            message.from_user = me
            message.to_user = to
            message.title = title
            message.message = msg
            message.save()
            create_notification("MSG", message.id, me, to, message=msg)
            serializer = PlainMessageSerializer(message.plain())
            return Response(serializer.data)
        return Response({
            "status": HTTP_400_BAD_REQUEST,
            "message": "Cannot send message to a non-link"
        }, status=HTTP_400_BAD_REQUEST)
    return Response({
        "status": HTTP_404_NOT_FOUND,
        "message": "User not found"
    }, status=HTTP_404_NOT_FOUND)
开发者ID:aftabaig,项目名称:py_castm,代码行数:49,代码来源:views.py

示例5: newnode

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import message [as 别名]
def newnode(request):
	if request.method == 'POST':
		node=Nodeall()
		node.naccid=int(request.POST['naccid'])
		node.nmessage=request.POST['nmessage']
		node.nj=float(request.POST['nj'])
		node.nd=float(request.POST['nd'])
		node.ntemp='T'
		node.put()
		if  'saveme' in request.POST:
			m=Message()
			m.message=request.POST['nmessage']
			m.put()
			#return HttpResponse(request.POST['saveme'])
			return HttpResponseRedirect('/')
		else:
			return HttpResponseRedirect('/')
开发者ID:g1z2yong,项目名称:accone,代码行数:19,代码来源:views.py

示例6: tnx

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


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