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


Python Dao.get_all_pending_tournaments方法代码示例

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


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

示例1: get

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_pending_tournaments [as 别名]
    def get(self, region):
        dao = Dao(region, mongo_client=mongo_client)
        if not dao:
            return 'Dao not found', 404
        include_pending_tournaments = False
        args = tournament_list_get_parser.parse_args()
        if args['includePending'] and args['includePending'] == 'true':
            user = get_user_from_request(request, dao)
            include_pending_tournaments = user and is_user_admin_for_region(
                user, region)

        tournaments = dao.get_all_tournaments(regions=[region])
        only_properties = ('id',
                           'name',
                           'date',
                           'regions')

        # temporary fix
        all_tournament_jsons = []
        for t in tournaments:
            try:
                all_tournament_jsons.append(t.dump(context='web',
                                                   only=only_properties))
            except:
                print 'error inserting tournament', t

        if include_pending_tournaments:
            # add a pending field for all existing tournaments
            for t in all_tournament_jsons:
                t['pending'] = False

            pending_tournaments = dao.get_all_pending_tournaments(regions=[
                                                                  region])
            if pending_tournaments:
                for p in pending_tournaments:
                    try:
                        p = p.dump(context='web',
                                   only=only_properties)
                        p['pending'] = True
                        all_tournament_jsons.append(p)
                    except:
                        print 'error inserting pending tournament', p

        return_dict = {}
        return_dict['tournaments'] = all_tournament_jsons

        return return_dict
开发者ID:garsh0p,项目名称:garpr,代码行数:49,代码来源:server.py

示例2: get

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_pending_tournaments [as 别名]
    def get(self, region):
        dao = Dao(region, mongo_client=mongo_client)

        include_pending_tournaments = False
        args = tournament_list_get_parser.parse_args()
        if args['includePending'] and args['includePending'] == 'true':
            user = get_user_from_request(request, dao)
            include_pending_tournaments = user and is_user_admin_for_region(user, region)

        tournaments = dao.get_all_tournaments(regions=[region])
        all_tournament_jsons = [t.get_json_dict() for t in tournaments]

        if include_pending_tournaments:
            # add a pending field for all existing tournaments
            for t in all_tournament_jsons:
                t['pending'] = False

            pending_tournaments = dao.get_all_pending_tournaments(regions=[region])
            for p in pending_tournaments:
                p = p.get_json_dict()
                p['pending'] = True
                del p['alias_to_id_map']
                all_tournament_jsons.append(p)

        return_dict = {}
        return_dict['tournaments'] = all_tournament_jsons
        convert_object_id_list(return_dict['tournaments'])

        for t in return_dict['tournaments']:
            t['date'] = t['date'].strftime("%x")

            # remove extra fields
            del t['raw']
            del t['matches']
            del t['players']
            del t['type']

        return return_dict
开发者ID:acoulon99,项目名称:garpr,代码行数:40,代码来源:server.py

示例3: TestDAO

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_pending_tournaments [as 别名]

#.........这里部分代码省略.........
        self.assertEquals(pending_tournament_1.type, self.pending_tournament_type_1)
        self.assertEquals(pending_tournament_1.raw, self.pending_tournament_raw_1)
        self.assertEquals(pending_tournament_1.date, self.pending_tournament_date_1)
        self.assertEquals(pending_tournament_1.name, self.pending_tournament_name_1)
        self.assertEquals(pending_tournament_1.matches, self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament_1.players, self.pending_tournament_players_1)
        self.assertEquals(pending_tournament_1.regions, self.pending_tournament_regions_1)

        pending_tournament_1_raw_new = 'asdfasdf'
        pending_tournament_1_name_new = 'new pending tournament name'

        pending_tournament_1.raw = pending_tournament_1_raw_new
        pending_tournament_1.name = pending_tournament_1_name_new

        self.norcal_dao.update_pending_tournament(pending_tournament_1)

        pending_tournament_1 = self.norcal_dao.get_pending_tournament_by_id(self.pending_tournament_id_1)
        self.assertEquals(pending_tournament_1.id, self.pending_tournament_id_1)
        self.assertEquals(pending_tournament_1.type, self.pending_tournament_type_1)
        self.assertEquals(pending_tournament_1.raw, pending_tournament_1_raw_new)
        self.assertEquals(pending_tournament_1.date, self.pending_tournament_date_1)
        self.assertEquals(pending_tournament_1.name, pending_tournament_1_name_new)
        self.assertEquals(pending_tournament_1.matches, self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament_1.players, self.pending_tournament_players_1)
        self.assertEquals(pending_tournament_1.regions, self.pending_tournament_regions_1)

    def test_update_pending_tournament_empty_raw(self):
        pending_tournament = self.norcal_dao.get_pending_tournament_by_id(self.pending_tournament_id_1)
        pending_tournament.raw = ''

        with self.assertRaises(UpdateTournamentException):
            self.norcal_dao.update_tournament(pending_tournament)

    def test_get_all_pending_tournaments(self):
        pending_tournaments = self.norcal_dao.get_all_pending_tournaments()

        self.assertEquals(len(pending_tournaments), 1)

        pending_tournament = pending_tournaments[0]
        self.assertEquals(pending_tournament.id, self.pending_tournament_id_1)
        self.assertEquals(pending_tournament.type, self.pending_tournament_type_1)
        self.assertEquals(pending_tournament.raw, '')
        self.assertEquals(pending_tournament.date, self.pending_tournament_date_1)
        self.assertEquals(pending_tournament.name, self.pending_tournament_name_1)
        self.assertEquals(pending_tournament.matches, self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament.players, self.pending_tournament_players_1)
        self.assertEquals(pending_tournament.regions, self.pending_tournament_regions_1)

    def test_get_all_pending_tournaments_for_region(self):
        pending_tournaments = self.norcal_dao.get_all_pending_tournaments(regions=['norcal'])

        self.assertEquals(len(pending_tournaments), 1)

        pending_tournament = pending_tournaments[0]
        self.assertEquals(pending_tournament.id, self.pending_tournament_id_1)
        self.assertEquals(pending_tournament.type, self.pending_tournament_type_1)
        self.assertEquals(pending_tournament.raw, '')
        self.assertEquals(pending_tournament.date, self.pending_tournament_date_1)
        self.assertEquals(pending_tournament.name, self.pending_tournament_name_1)
        self.assertEquals(pending_tournament.matches, self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament.players, self.pending_tournament_players_1)
        self.assertEquals(pending_tournament.regions, self.pending_tournament_regions_1)

    def test_get_pending_tournament_by_id(self):
        pending_tournament = self.norcal_dao.get_pending_tournament_by_id(self.pending_tournament_id_1)
        self.assertEquals(pending_tournament.id, self.pending_tournament_id_1)
开发者ID:MrMonacle,项目名称:garpr,代码行数:70,代码来源:test_dao.py

示例4: TestDAO

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_pending_tournaments [as 别名]

#.........这里部分代码省略.........
                          self.pending_tournament_date_1)
        self.assertEquals(pending_tournament_1.name,
                          self.pending_tournament_name_1)
        self.assertEquals(pending_tournament_1.matches,
                          self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament_1.players,
                          self.pending_tournament_players_1)
        self.assertEquals(pending_tournament_1.regions,
                          self.pending_tournament_regions_1)

        pending_tournament_1_name_new = 'new pending tournament name'

        pending_tournament_1.name = pending_tournament_1_name_new

        self.norcal_dao.update_pending_tournament(pending_tournament_1)

        pending_tournament_1 = self.norcal_dao.get_pending_tournament_by_id(
            self.pending_tournament_id_1)
        self.assertEquals(pending_tournament_1.id,
                          self.pending_tournament_id_1)
        self.assertEquals(pending_tournament_1.type,
                          self.pending_tournament_type_1)
        self.assertEquals(pending_tournament_1.date,
                          self.pending_tournament_date_1)
        self.assertEquals(pending_tournament_1.name,
                          pending_tournament_1_name_new)
        self.assertEquals(pending_tournament_1.matches,
                          self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament_1.players,
                          self.pending_tournament_players_1)
        self.assertEquals(pending_tournament_1.regions,
                          self.pending_tournament_regions_1)

    def test_get_all_pending_tournaments(self):
        pending_tournaments = self.norcal_dao.get_all_pending_tournaments()

        self.assertEquals(len(pending_tournaments), 1)

        pending_tournament = pending_tournaments[0]
        self.assertEquals(pending_tournament.id, self.pending_tournament_id_1)
        self.assertEquals(pending_tournament.type,
                          self.pending_tournament_type_1)
        self.assertEquals(pending_tournament.date,
                          self.pending_tournament_date_1)
        self.assertEquals(pending_tournament.name,
                          self.pending_tournament_name_1)
        self.assertEquals(pending_tournament.matches,
                          self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament.players,
                          self.pending_tournament_players_1)
        self.assertEquals(pending_tournament.regions,
                          self.pending_tournament_regions_1)

    def test_get_all_pending_tournaments_for_region(self):
        pending_tournaments = self.norcal_dao.get_all_pending_tournaments(regions=[
                                                                          'norcal'])

        self.assertEquals(len(pending_tournaments), 1)

        pending_tournament = pending_tournaments[0]
        self.assertEquals(pending_tournament.id, self.pending_tournament_id_1)
        self.assertEquals(pending_tournament.type,
                          self.pending_tournament_type_1)
        self.assertEquals(pending_tournament.date,
                          self.pending_tournament_date_1)
        self.assertEquals(pending_tournament.name,
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:70,代码来源:test_dao.py


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