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


Python Message.send_message方法代码示例

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


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

示例1: new

# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import send_message [as 别名]
def new(request):
    if request.method == 'POST':
        from_user = request.user
        to_user_username = request.POST.get('to')
        try:
            to_user = User.objects.get(username=to_user_username)
        except Exception as e:
            try:
                to_user_username = to_user_username[to_user_username.rfind('(')+1:len(to_user_username)-1]
                to_user = User.objects.get(username=to_user_username)
            except Exception as e:
                return redirect('/messages/new/')
        message = request.POST.get('message')
        if len(message.strip()) == 0:
            return redirect('/messages/new/')
        if from_user != to_user:
            Message.send_message(from_user, to_user, message)
        return redirect(u'/messages/{0}/'.format(to_user_username))
    else:
        conversations = Message.get_conversations(user=request.user)
        return render(request, 'messages/new.html', {'conversations': conversations})
开发者ID:cangfengzhe,项目名称:xiaobaifinder,代码行数:23,代码来源:views.py

示例2: send

# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import send_message [as 别名]
def send(request):
    if request.method == 'POST':
        from_user = request.user
        to_user_username = request.POST.get('to')
        to_user = User.objects.get(username=to_user_username)
        message = request.POST.get('message')
        if len(message.strip()) == 0:
            return HttpResponse()
        if from_user != to_user:
            msg = Message.send_message(from_user, to_user, message)
            return render(request, 'messages/includes/partial_message.html', {'message': msg})
        return HttpResponse()
    else:
        return HttpResponseBadRequest()
开发者ID:cangfengzhe,项目名称:xiaobaifinder,代码行数:16,代码来源:views.py

示例3: redirect

# 需要导入模块: from messages.models import Message [as 别名]
# 或者: from messages.models.Message import send_message [as 别名]
    if request.method == 'POST':
        from_user = request.user
        to_user_username = request.POST.get('to')
        try:
            to_user = User.objects.get(username=to_user_username)
        except Exception, e:
            try:
                to_user_username = to_user_username[to_user_username.rfind('(')+1:len(to_user_username)-1]
                to_user = User.objects.get(username=to_user_username)
            except Exception, e:
                return redirect('/messages/new/')
        message = request.POST.get('message')
        if len(message.strip()) == 0:
            return redirect('/messages/new/')
        if from_user != to_user:
            Message.send_message(from_user, to_user, message)
        return redirect(u'/messages/{0}/'.format(to_user_username))
    else:
        conversations = Message.get_conversations(user=request.user)
        return render(request, 'messages/new.html', {'conversations': conversations})

@login_required
@ajax_required
def delete(request):
    return HttpResponse()

@login_required
@ajax_required
def send(request):
    if request.method == 'POST':
        from_user = request.user
开发者ID:kngeno,项目名称:gis_kenya,代码行数:33,代码来源:views.py


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