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


Python Message.content方法代码示例

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


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

示例1: detail_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import content [as 别名]
def detail_message(request, conv_id):
    """
    view untuk menampilkan detail pesan
    beserta percakapan
    """
    conv = get_object_or_404(Conversation, id=conv_id, users=request.user, membership__deleted=False)
    list_messages = Message.objects.filter(conversation=conv)
    msg = list_messages[0]
    if request.POST:
        form = SendConversationForm(request.POST)
        if form.is_valid():
            msg = Message()
            msg.conversation = conv
            msg.user = request.user
            msg.content = form.cleaned_data['content']
            msg.save()
            to2 = list(conv.users.all())
            to2.remove(request.user)
            notification.send(to2, 'new_message', {'user': request.user, 'message': conv})
            messages.info(request, _('Message sent'))
            return HttpResponseRedirect(conv.get_absolute_url())
    else:
        form = SendConversationForm()
    return render_to_response('message/detail_message.html',
            {"conv": conv,
                'form': form,
                'msg': msg,
                'list_messages': list_messages},
            context_instance=RequestContext(request))
开发者ID:sakti,项目名称:ittelkomnewsmap,代码行数:31,代码来源:views.py

示例2: save_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import content [as 别名]
def save_message(user_id, message):
	type_name = message.get('type_name')
	args = message.get('args')
	file = message.get('file', '')
	conversation_id = message.get('conversation_id')
	
	mt = MessageType.select().where(MessageType.name == type_name).first()
	u = User.select().where(User.id == user_id).first()
	cps = ConversationParty.select().where(ConversationParty.conversation == conversation_id)
	number_of_conversationees = cps.count()

	if not mt or not u or not cps or not number_of_conversationees:
		raise InvalidMessageDataException('Couldn\'t save message: invalid message data')

	m = Message()

	with database.transaction():	

		m.conversation = conversation_id
		m.message_type = mt
		m.sender_id = user_id
		m.ts = datetime.now()
		m.file = file
		m.content, m.display_content = __save_content(args, mt, user_id, cps)
		m.save()

		update_conversation(conversation_id=conversation_id,
							last_message=m)

		mark_message_as_read(user_id=user_id,
							 message=m,
							 conversation_id=conversation_id)
	message_object = get_message_json(message=m)
	message_object['recipient_ids'] = [cp.user.id for cp in cps]
	return json.dumps(message_object)
开发者ID:FelipePiacsek,项目名称:chat_angular,代码行数:37,代码来源:messages.py

示例3: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import content [as 别名]
	def post(self):
		# Set up the message instance
		message = Message()
		
		message.author = users.get_current_user()
		
		if self.request.get('content') != '':
			message.content = self.request.get('content')
			message.put()
	  
		self.redirect('/')
开发者ID:engleek,项目名称:pintme,代码行数:13,代码来源:main.py

示例4: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import content [as 别名]
    def post(self):
        message = Message()
        
        user = users.get_current_user()
        if user:
            message.author = user

        #Added the content to the message: 
       	message.content = cgi.escape(self.request.get('content'))
        #Assigned the id to the message:
        message.postID = Message.max_id() + 1
	
        message.put()
开发者ID:benjamin99,项目名称:3dAR,代码行数:15,代码来源:main.py

示例5: post

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

示例6: create_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import content [as 别名]
def create_message(request, username=None):
    """
    view untuk menampilkan pembuatan pesan
    """
    to = []
    if username:
        to.append(username)
    if request.POST:
        to = request.POST.getlist('to')
        form = CreateMessageForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            message = form.cleaned_data['content']
            location = form.cleaned_data['location']
            conv = Conversation()
            conv.title = title
            conv.origin = request.user
            conv.location = location
            conv.save()
            Membership.objects.create(user=request.user,
                    conversation=conv)
            to2 = []
            for person in to:
                to_person = User.objects.get(username=person)
                to2.append(to_person)
                Membership.objects.create(user=to_person,
                        conversation=conv)
            msg = Message()
            msg.conversation = conv
            msg.content = message
            msg.user = request.user
            msg.save()

            notification.send(to2, 'new_message',
                {'user': request.user, 'message': conv})
            messages.info(request, _('Message sent'))
            return HttpResponseRedirect(reverse('message_list'))
    else:
        form = CreateMessageForm()
    return render_to_response('message/create_message.html',
            {'form': form,
                'to': to},
            context_instance=(RequestContext(request)))
开发者ID:sakti,项目名称:ittelkomnewsmap,代码行数:45,代码来源:views.py

示例7: thread

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

示例8: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import content [as 别名]
 def post(self):
     entry = Message()
     entry.name = self.request.get("name")
     entry.content = self.request.get("content")
     entry.put()
     self.redirect("/")
开发者ID:wyattdanger,项目名称:crudify,代码行数:8,代码来源:main.py


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