• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python card.Card类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.card.Card的典型用法代码示例。如果您正苦于以下问题:Python Card类的具体用法?Python Card怎么用?Python Card使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Card类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()]
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:7,代码来源:test_card.py


示例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],
    }
开发者ID:Folashade,项目名称:sagefy,代码行数:30,代码来源:card.py


示例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)]
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:7,代码来源:test_card.py


示例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)
开发者ID:oujiaqi,项目名称:suiyue,代码行数:25,代码来源:card.py


示例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')
开发者ID:oujiaqi,项目名称:suiyue,代码行数:29,代码来源:control.py


示例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)
开发者ID:oujiaqi,项目名称:suiyue,代码行数:7,代码来源:card.py


示例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()
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:8,代码来源:test_card.py


示例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
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:8,代码来源:test_card.py


示例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()]
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:14,代码来源:test_list.py


示例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
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:15,代码来源:comment.py


示例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()))
开发者ID:bilby91,项目名称:ganban,代码行数:16,代码来源:api.py


示例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()
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:16,代码来源:test_user.py


示例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)
开发者ID:Folashade,项目名称:sagefy,代码行数:27,代码来源:entity.py


示例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)})
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:16,代码来源:views.py


示例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)]
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:16,代码来源:test_comment.py


示例16: get_version

def get_version(kind, id_):
    if kind == 'card':
        return Card.get(id=id_)
        # TODO-1 This needs to also get the right card kind...
    elif kind == 'unit':
        return Unit.get(id=id_)
    elif kind == 'set':
        return Set.get(id=id_)
开发者ID:Folashade,项目名称:sagefy,代码行数:8,代码来源:entity.py


示例17: get_card_versions_route

def get_card_versions_route(request, card_id):
    """
    Get versions card given an ID. Paginates.
    """

    versions = Card.get_versions(entity_id=card_id, **request['params'])
    return 200, {
        'versions': [version.deliver(access='view') for version in versions]
    }
开发者ID:Folashade,项目名称:sagefy,代码行数:9,代码来源:card.py


示例18: get

 def get(self):
     root = self.get_secure_cookie('root')
     if root=='suiyue':
         current_order = get_order()
         cards = Card.get_all_card()
         stories = Story.get_all_story()
         self.render("control.html", order=current_order, cards=cards, stories=stories)
     else:
         self.redirect('/rootlogin')
开发者ID:oujiaqi,项目名称:suiyue,代码行数:9,代码来源:control.py


示例19: test_add_and_get

 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
开发者ID:GuangzheGao,项目名称:sorbitol,代码行数:10,代码来源:test_comment.py


示例20: get_latest_accepted

def get_latest_accepted(kind, entity_id):
    """
    Given a kind and an entity_id, pull the latest accepted
    version out of the database.
    """

    if kind == 'card':
        return Card.get_latest_accepted(entity_id)
        # TODO-1 This needs to also get the right card kind...
    elif kind == 'unit':
        return Unit.get_latest_accepted(entity_id)
    elif kind == 'set':
        return Set.get_latest_accepted(entity_id)
开发者ID:Folashade,项目名称:sagefy,代码行数:13,代码来源:entity.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python category.Category类代码示例发布时间:2022-05-27
下一篇:
Python board.Board类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap