本文整理汇总了Python中models.comment.Comment.add方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.add方法的具体用法?Python Comment.add怎么用?Python Comment.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.comment.Comment
的用法示例。
在下文中一共展示了Comment.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_comments_by_card_id
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
def test_get_comments_by_card_id(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
caid0 = Card.add("card1", lid0, uid0)
caid1 = Card.add("card2", lid0, uid0)
coid0 = Comment.add(caid0, uid0, "comment1")
coid1 = Comment.add(caid1, uid0, "comment2")
comment0 = Comment.get(coid0)
comment1 = Comment.get(coid1)
assert coid0 in [comment.id for comment in Comment.get_comments_by_card_id(caid0)]
assert coid1 not in [comment.id for comment in Comment.get_comments_by_card_id(caid0)]
示例2: add_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
def add_comment(post_id, comment_body, user, parent_id=None):
post = Post.get_by_id(post_id)
if parent_id is not None:
parent = Comment.get_by_id(parent_id).key
comment = Comment()
comment.add(
text=comment_body,
author=user,
post=post.key,
parent=None if parent_id is None else parent)
if post.num_comments is None:
post.num_comments = 0
post.num_comments += 1
post.put()
示例3: add
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
def add():
target_type = request.values.get('target_type')
target_id = request.values.get('target_id')
url = request.values.get('url')
msg = request.values.get('msg')
msg_channel = request.values.get('msg_channel')
comment = Comment.add(target_type, target_id, msg, g.user, msg_channel=msg_channel)
add_comment_signal.send(current_app._get_current_object(), comment=comment, msg_channel=msg_channel, url=url)
return jsonify({'msg': "msg add success"})
示例4: test_add_and_get
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
def test_add_and_get(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
caid0 = Card.add("card1", lid0, uid0)
coid0 = Comment.add(caid0, uid0, "comment1")
comment0 = Comment.get(coid0)
assert caid0 == comment0.card_id
assert uid0 == comment0.user_id
assert "comment1" == comment0.content
示例5: api_add_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
def api_add_comment(card_id=None):
if card_id == None:
return jsonify({'code': 400, 'message': 'Bad Request'})
else:
card = Card.get(long(card_id))
if card == None:
return jsonify({'code': 404, 'message': 'Page Not Found'})
try:
content = request.form['comment']
except:
return jsonify({'code': 400, 'message': 'Bad Request'})
comment = Comment.add(long(card_id), current_user.id, content)
return jsonify({'card_id': card_id})
示例6: add_comment
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
def add_comment(self, user, msg, msg_channel=0):
Comment.add(self.target_type, self.target_id, msg, user, datetime.datetime.now(), msg_channel)
示例7:
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import add [as 别名]
user0.set_avatar('http://127.0.0.1:5000/_uploads/images/avatar_1.png')
user1.set_avatar('http://127.0.0.1:5000/_uploads/images/avatar_2.png')
lid0 = List.add("To Do", bid0)
lid1 = List.add("Doing", bid0)
lid2 = List.add("Done", bid0)
caid0 = Card.add("card1", lid0, uid0)
caid1 = Card.add("card2", lid0, uid0)
caid2 = Card.add("card3", lid1, uid0)
card0 = Card.get(caid0)
card0.add_user(user1)
card0.add_user(user2)
coid0 = Comment.add(caid0, uid0, "comment1")
coid1 = Comment.add(caid0, uid1, "comment2")
coid2 = Comment.add(caid0, uid2, "comment3")
'''
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from models.user import User
from models.board import Board
from models.list import List
from models.card import Card
from models.comment import Comment
from models.group import Group
from utils.db import mysql_engine, r_server