本文整理汇总了Python中models.card.Card类的典型用法代码示例。如果您正苦于以下问题:Python Card类的具体用法?Python Card怎么用?Python Card使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Card类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_user_ids
def test_get_user_ids(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
card_id = Card.add("card0", lid0, uid0)
card = Card.get(card_id)
assert str(uid0) in [user_id for user_id in card.get_user_ids()]
示例2: get_card_route
def get_card_route(request, card_id):
"""
Get a specific card given an ID. Show all relevant data, but
not used for the learning interface.
"""
card = get_card_by_kind(card_id)
if not card:
return abort(404)
unit = Unit.get_latest_accepted(entity_id=card['unit_id'])
if not unit:
return abort(404)
# TODO-2 SPLITUP create new endpoints for these instead
topics = Topic.list_by_entity_id(entity_id=card_id)
versions = Card.get_versions(entity_id=card_id)
requires = Card.list_requires(entity_id=card_id)
required_by = Card.list_required_by(entity_id=card_id)
params = CardParameters.get(entity_id=card_id)
return 200, {
'card': card.deliver(access='view'),
'card_parameters': params.get_values(),
'unit': unit.deliver(),
'topics': [topic.deliver() for topic in topics],
'versions': [version.deliver() for version in versions],
'requires': [require.deliver() for require in requires],
'required_by': [require.deliver() for require in required_by],
}
示例3: test_get_cards_by_list_id
def test_get_cards_by_list_id(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
card_id = Card.add("card0", lid0, uid0)
card = Card.get(card_id)
assert card_id in [card.id for card in Card.get_cards_by_list_id(lid0)]
示例4: get
def get(self):
uname = self.get_current_user()
user = User.get_user_by_name(uname)
order = get_order()
card = Card.get_by_porder(order)
cid = self.get_argument("cid",None)
if cid is not None:
card=Card.get_by_cid(cid)
article = Article.get_all_Acard(200)
usedCard = Card.get_all_card()
temp = []
for one in usedCard:
if 0 < one.porder and one.porder <= order:
temp.append(one)
usedCard = temp
reArticles = Article.get_all(200)
Rarticle = sorted(reArticles,BaseHandler.rank)
if len(Rarticle) > 6:
Rarticle = Rarticle[:6]
Ruser = User.get_all_user(100)
if len(Ruser)>9:
Ruser = Ruser[:9]
if len(usedCard)>3:
usedCard = usedCard[:3]
self.render("card.html",user=user,Rarticle=Rarticle,Article=article,usedCard=usedCard,Ruser=Ruser,card=card)
示例5: post
def post(self):
cid = self.get_argument('cid')
root = self.get_secure_cookie('root')
if root != 'suiyue':
return self.redirect('/rootlogin')
cards = Card.get_by_cid(cid)
ext_allowed = ['gif', 'jpg', 'jpeg', 'png']
cpic = cards[0].pic
max_size = 2621440
save_dir = os.path.join(os.path.dirname(__file__), "../public/pic/card/")
if len(cards)>0:
file_name = str(cards[0].cid)
error = ""
if 'image' in self.request.files:
pic = self.request.files['image'][0]
ext = pic['filename'].split('.').pop()
if ext not in ext_allowed:
error="图片格式不支持"
self.redirect('/control')
if len(pic['body'])>max_size:
error="图片太大"
self.redirect('/control')
cpic = file_name+"."+ext
with open(save_dir+cpic,'wb') as up:
up.write(pic['body'])
Card.change_pic(cid, cpic)
self.redirect("/control")
else:
self.redirect('/control')
示例6: post
def post(self):
uname = self.get_current_user()
user = User.get_user_by_name(uname)
main = self.get_argument("main")
pic = "default.jpg"
Card.add_one_card(pic,user[0].uid,main)
self.render("wcard.html", msg="投稿成功,谢谢你的idea",user=user)
示例7: test_get_and_test_description
def test_get_and_test_description(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
card_id = Card.add("card0", lid0, uid0)
card = Card.get(card_id)
card.set_description('desc')
assert 'desc' in card.get_description()
示例8: test_set_and_get_card
def test_set_and_get_card(self):
uid0 = User.add("test1", "password", "[email protected]")
bid0 = Board.add("board1", "A")
lid0 = List.add("To Do", bid0)
card_id = Card.add("card0", lid0, uid0)
card = Card.get(card_id)
assert card.title == 'card0'
assert card.list_id == lid0
示例9: test_get_cards
def test_get_cards(self):
bid0 = Board.add("board1", "A")
lid0 = List.add("List0", bid0)
list0 = List.get(lid0)
lid1 = List.add("List1", bid0)
list1 = List.get(lid1)
uid0 = User.add("test1", "password", "[email protected]")
caid0 = Card.add("card1", lid0, uid0)
caid1 = Card.add("card2", lid1, uid0)
assert caid0 in [card.id for card in list0.get_cards()]
assert caid1 not in [card.id for card in list0.get_cards()]
示例10: add
def add(cls, card_id, user_id, content):
comment = cls(card_id = card_id, user_id = user_id, content = content)
from models.card import Card
Card.incr_comment(card_id)
try:
mysql_session.add(comment)
mysql_session.commit()
except Exception as e:
mysql_session.rollback()
print "error in mysql commit:", e
raise
finally:
mysql_session.close()
return comment.id
示例11: post
def post(self):
''' Create new card '''
board = self.get_board(self.request.get('board_id'))
card = Card(board_key=board.key,
content=self.request.get('content'),
author_key=self.current_ganban_user().key)
card.put()
if settings.SEND_EMAILS:
self.send_new_card_email(card)
logging.info("Card with id: %s created.", card.key.id())
self.send_channel_message('create', card)
self.response.out.write(json.dumps(card.to_dict()))
示例12: test_add_and_get_cards
def test_add_and_get_cards(self):
uid0 = User.add("test_user1", "password", "[email protected]")
user0 = User.get(uid0)
uid1 = User.add("test_user2", "password", "[email protected]")
user1 = User.get(uid1)
bid0 = Board.add("board1", "A")
lid0 = List.add("List0", bid0)
caid0 = Card.add("card1", lid0, uid0)
caid1 = Card.add("card2", lid0, uid1)
card0 = Card.get(caid0)
print caid0, user0.get_card_ids()
assert str(caid0) in user0.get_card_ids()
assert str(caid1) not in user0.get_card_ids()
示例13: get_card_by_kind
def get_card_by_kind(card_id):
"""
Given a card data, return a new card model to replace it by kind.
"""
card = Card.get_latest_accepted(card_id)
if not card:
return
data, kind = card.data, card.data.get('kind')
map = {
'audio': AudioCard,
'choice': ChoiceCard,
'embed': EmbedCard,
'formula': FormulaCard,
'match': MatchCard,
'number': NumberCard,
'page': PageCard,
'slideshow': SlideshowCard,
'upload': UploadCard,
'video': VideoCard,
'writing': WritingCard,
}
if kind in map:
return map[kind](data)
示例14: api_card
def api_card(list_id = None):
if request.method == 'GET':
list_id = request.args.get('list_id')
if list_id != None:
cards = Card.get_cards_by_list_id(list_id)
return jsonify(json_list=[card.serialize() for card in cards])
else:
return jsonify({'code': 404, 'message': 'Card ID not valid.'})
else:
try:
list_id = long(request.form['list_id'])
title = request.form['title']
except KeyError:
return jsonify({'code': 400, 'message': 'Bad Request'})
return jsonify({"card_id": Card.add(title, list_id, current_user.id)})
示例15: test_get_comments_by_card_id
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)]