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


Python prototypes.ClanPrototype类代码示例

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


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

示例1: get_contributors

def get_contributors(entity_id, author_id, type):
    contributors_ids = list(prototypes.ContributionPrototype._db_filter(type=type,
                                                                        entity_id=entity_id).order_by('created_at').values_list('account_id', flat=True))

    if author_id is not None and author_id not in contributors_ids:
        contributors_ids.append(author_id)

    contributors = AccountPrototype.from_query(AccountPrototype._db_filter(id__in=contributors_ids))
    clans = {clan.id: clan for clan in ClanPrototype.from_query(ClanPrototype._db_filter(id__in=[account.clan_id for account in contributors if account.clan_id is not None]))}

    contributors.sort(key=lambda c: contributors_ids.index(c.id))

    return contributors, clans
开发者ID:echurmanov,项目名称:the-tale,代码行数:13,代码来源:views.py

示例2: __init__

    def __init__(self):
        register_user('forum_user', '[email protected]', '111111')
        register_user('forum_user_2', '[email protected]', '111111')

        self.account_1 = AccountPrototype.get_by_nick('forum_user')
        self.account_2 = AccountPrototype.get_by_nick('forum_user_2')

        # cat1
        # |-subcat1
        # | |-thread1
        # | | |-post1
        # | |-thread2
        # |-subcat2
        # cat2
        # | subcat3
        # | |- thread3
        # cat3

        self.cat_1 = CategoryPrototype.create(caption='cat1-caption', slug='cat1-slug', order=0)
        # to test, that subcat.id not correlate with order
        self.subcat_2 = SubCategoryPrototype.create(category=self.cat_1, caption='subcat2-caption', order=1, closed=True)
        self.subcat_1 = SubCategoryPrototype.create(category=self.cat_1, caption='subcat1-caption', order=0)
        self.cat_2 = CategoryPrototype.create(caption='cat2-caption', slug='cat2-slug', order=0)
        self.subcat_3 = SubCategoryPrototype.create(category=self.cat_2, caption='subcat3-caption', order=0)
        self.cat_3 = CategoryPrototype.create(caption='cat3-caption', slug='cat3-slug', order=0)

        self.thread_1 = ThreadPrototype.create(self.subcat_1, 'thread1-caption', self.account_1, 'thread1-text')
        self.thread_2 = ThreadPrototype.create(self.subcat_1, 'thread2-caption', self.account_1, 'thread2-text')
        self.thread_3 = ThreadPrototype.create(self.subcat_3, 'thread3-caption', self.account_1, 'thread3-text')

        self.post_1 = PostPrototype.create(self.thread_1, self.account_1, 'post1-text')

        # create test clan and clean it's forum artifacts
        self.clan_category = CategoryPrototype.create(caption='category-1', slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)
        self.clan_1 = ClanPrototype.create(self.account_1, abbr=u'abbr1', name=u'name1', motto=u'motto', description=u'description')
开发者ID:Alkalit,项目名称:the-tale,代码行数:35,代码来源:helpers.py

示例3: candidates

 def candidates(self):
     candidates = FriendshipPrototype.get_candidates_for(self.account)
     accounts_ids = [account.id for account in candidates]
     clans_ids = [model.clan_id for model in candidates]
     heroes = {hero.account_id: hero for hero in heroes_logic.load_heroes_by_account_ids(accounts_ids)}
     clans = {clan.id: clan for clan in ClanPrototype.get_list_by_id(clans_ids)}
     return self.template(
         "friends/friends_candidates.html", {"candidates": candidates, "heroes": heroes, "clans": clans}
     )
开发者ID:Tiendil,项目名称:the-tale,代码行数:9,代码来源:views.py

示例4: candidates

 def candidates(self):
     candidates = FriendshipPrototype.get_candidates_for(self.account)
     accounts_ids = [account.id for account in candidates]
     clans_ids = [ model.clan_id for model in candidates]
     heroes = dict( (model.account_id, HeroPrototype(model=model)) for model in Hero.objects.filter(account_id__in=accounts_ids))
     clans = {clan.id:clan for clan in ClanPrototype.get_list_by_id(clans_ids)}
     return self.template('friends/friends_candidates.html',
                          {'candidates': candidates,
                           'heroes': heroes,
                           'clans': clans})
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:views.py

示例5: setUp

    def setUp(self):
        super(ClanPrototypeTransactionTests, self).setUp()
        create_test_map()

        self.forum_category = CategoryPrototype.create(caption='category-1', slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)

        result, account_id, bundle_id = register_user('test_user', '[email protected]', '111111')

        self.account = AccountPrototype.get_by_id(account_id)
        self.clan = ClanPrototype.create(self.account, abbr=u'abbr', name=u'clan-name', motto='clan-motto', description=u'clan-description')
开发者ID:Alkalit,项目名称:the-tale,代码行数:10,代码来源:test_prototypes.py

示例6: test_unique_owner

 def test_unique_owner(self):
     self.assertRaises(IntegrityError,
                       ClanPrototype.create,
                       self.account,
                       abbr='abr2',
                       name='bla-name',
                       motto='bla-motto',
                       description=u'bla-description')
     self.assertEqual(ClanPrototype._db_count(), 1)
     self.assertEqual(MembershipPrototype._db_count(), 1)
     self.assertEqual(ForumPermissionPrototype._db_count(), 1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:11,代码来源:test_prototypes.py

示例7: friends

 def friends(self):
     friends = FriendshipPrototype.get_friends_for(self.account)
     candidates = FriendshipPrototype.get_candidates_for(self.account)
     accounts_ids = [account.id for account in friends]
     clans_ids = [ model.clan_id for model in friends]
     heroes = {hero.account_id: hero for hero in  heroes_logic.load_heroes_by_account_ids(accounts_ids)}
     clans = {clan.id:clan for clan in ClanPrototype.get_list_by_id(clans_ids)}
     return self.template('friends/friends_list.html',
                          {'friends': friends,
                           'candidates': candidates,
                           'heroes': heroes,
                           'clans': clans})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:12,代码来源:views.py

示例8: test_unique_abbr

 def test_unique_abbr(self):
     result, account_id, bundle_id = register_user('test_user_2', '[email protected]', '111111')
     self.assertRaises(IntegrityError,
                       ClanPrototype.create,
                       AccountPrototype.get_by_id(account_id),
                       abbr=self.clan.abbr,
                       name='bla-name',
                       motto='bla-motto',
                       description=u'bla-description')
     self.assertEqual(ClanPrototype._db_count(), 1)
     self.assertEqual(MembershipPrototype._db_count(), 1)
     self.assertEqual(ForumPermissionPrototype._db_count(), 1)
开发者ID:Alkalit,项目名称:the-tale,代码行数:12,代码来源:test_prototypes.py

示例9: pvp_page

    def pvp_page(self):

        battle = Battle1x1Prototype.get_by_account_id(self.account.id)

        if battle is None or not battle.state.is_PROCESSING:
            return self.redirect(reverse("game:"))

        own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME)

        enemy_account = AccountPrototype.get_by_id(battle.enemy_id)

        enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id)
        enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME)

        say_form = SayForm()

        clan = None
        if self.account.clan_id is not None:
            clan = ClanPrototype.get_by_id(self.account.clan_id)

        enemy_clan = None
        if enemy_account.clan_id is not None:
            enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id)

        return self.template(
            "pvp/pvp_page.html",
            {
                "enemy_account": AccountPrototype.get_by_id(battle.enemy_id),
                "own_hero": self.own_hero,
                "own_abilities": own_abilities,
                "enemy_abilities": enemy_abilities,
                "game_settings": game_settings,
                "say_form": say_form,
                "clan": clan,
                "enemy_clan": enemy_clan,
                "battle": battle,
                "EQUIPMENT_SLOT": EQUIPMENT_SLOT,
                "ABILITIES": (Ice, Blood, Flame),
            },
        )
开发者ID:nbadp,项目名称:the-tale,代码行数:40,代码来源:views.py

示例10: setUp

    def setUp(self):
        super(AccountRequestsTests, self).setUp()
        self.place1, self.place2, self.place3 = create_test_map()

        result, account_id, bundle_id = logic.register_user('test_user1', '[email protected]', '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = logic.register_user('test_user2', '[email protected]', '111111')
        self.account_2 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = logic.register_user('test_user3', '[email protected]', '111111')
        self.account_3 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = logic.register_user('test_user_bot', '[email protected]', '111111', is_bot=True)
        self.account_bot = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = logic.register_user('test_user4')
        self.account_4 = AccountPrototype.get_by_id(account_id)

        CategoryPrototype.create(caption='category-1', slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)

        self.clan_2 = ClanPrototype.create(self.account_2, abbr=u'abbr2', name=u'name2', motto=u'motto', description=u'description')
        self.clan_3 = ClanPrototype.create(self.account_3, abbr=u'abbr3', name=u'name3', motto=u'motto', description=u'description')
开发者ID:Jazzis18,项目名称:the-tale,代码行数:23,代码来源:test_requests_account.py

示例11: index

    def index(self):

        if portal_settings.ENABLE_FIRST_TIME_REDIRECT and accounts_logic.is_first_time_visit(self.request):
            return self.redirect(random.choice(portal_settings.FIRST_TIME_LANDING_URLS))

        news = news_logic.load_news_from_query(news_models.News.objects.all().order_by('-created_at')[:portal_settings.NEWS_ON_INDEX])

        bills = BillPrototype.get_recently_modified_bills(portal_settings.BILLS_ON_INDEX)

        account_of_the_day_id = settings.get(portal_settings.SETTINGS_ACCOUNT_OF_THE_DAY_KEY)

        hero_of_the_day = None
        account_of_the_day = None
        clan_of_the_day = None

        if account_of_the_day_id is not None:
            hero_of_the_day = heroes_logic.load_hero(account_id=account_of_the_day_id)
            account_of_the_day = AccountPrototype.get_by_id(account_of_the_day_id)

            if account_of_the_day.clan_id is not None:
                clan_of_the_day = ClanPrototype.get_by_id(account_of_the_day.clan_id)

        forum_threads = ThreadPrototype.get_last_threads(account=self.account if self.account.is_authenticated() else None,
                                                         limit=portal_settings.FORUM_THREADS_ON_INDEX)

        blog_posts = [ BlogPostPrototype(blog_post_model)
                       for blog_post_model in BlogPost.objects.filter(state__in=[BLOG_POST_STATE.ACCEPTED, BLOG_POST_STATE.NOT_MODERATED],
                                                                      votes__gte=0).order_by('-created_at')[:portal_settings.BLOG_POSTS_ON_INDEX] ]

        map_info = map_info_storage.item

        chronicle_records = ChronicleRecordPrototype.get_last_records(portal_settings.CHRONICLE_RECORDS_ON_INDEX)

        chronicle_actors = RecordToActorPrototype.get_actors_for_records(chronicle_records)

        return self.template('portal/index.html',
                             {'news': news,
                              'forum_threads': forum_threads,
                              'bills': bills,
                              'hero_of_the_day': hero_of_the_day,
                              'account_of_the_day': account_of_the_day,
                              'clan_of_the_day': clan_of_the_day,
                              'map_info': map_info,
                              'blog_posts': blog_posts,
                              'TERRAIN': TERRAIN,
                              'MAP_STATISTICS': MAP_STATISTICS,
                              'chronicle_records': chronicle_records,
                              'chronicle_actors': chronicle_actors,
                              'RACE': RACE})
开发者ID:Jazzis18,项目名称:the-tale,代码行数:49,代码来源:views.py

示例12: pvp_page

    def pvp_page(self):

        battle = Battle1x1Prototype.get_by_account_id(self.account.id)

        if battle is None or not battle.state.is_PROCESSING:
            return self.redirect(reverse('game:'))

        own_abilities = sorted(self.own_hero.abilities.all, key=lambda x: x.NAME)

        enemy_account = AccountPrototype.get_by_id(battle.enemy_id)

        enemy_hero = HeroPrototype.get_by_account_id(battle.enemy_id)
        enemy_abilities = sorted(enemy_hero.abilities.all, key=lambda x: x.NAME)

        say_form = SayForm()

        clan = None
        if self.account.clan_id is not None:
            clan = ClanPrototype.get_by_id(self.account.clan_id)

        enemy_clan = None
        if enemy_account.clan_id is not None:
            enemy_clan = ClanPrototype.get_by_id(enemy_account.clan_id)

        return self.template('pvp/pvp_page.html',
                             {'enemy_account': AccountPrototype.get_by_id(battle.enemy_id),
                              'own_hero': self.own_hero,
                              'own_abilities': own_abilities,
                              'enemy_abilities': enemy_abilities,
                              'game_settings': game_settings,
                              'say_form': say_form,
                              'clan': clan,
                              'enemy_clan': enemy_clan,
                              'battle': battle,
                              'EQUIPMENT_SLOT': EQUIPMENT_SLOT,
                              'ABILITIES': (Ice, Blood, Flame)} )
开发者ID:alexudracul,项目名称:the-tale,代码行数:36,代码来源:views.py

示例13: setUp

    def setUp(self):
        super(BaseTestRequests, self).setUp()
        self.place1, self.place2, self.place3 = create_test_map()
        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()

        self.client = client.Client()

        helpers.prepair_forum()

        CategoryPrototype.create(caption="category-1", slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)

        self.clan_2 = ClanPrototype.create(
            self.account_2, abbr="abbr2", name="name2", motto="motto", description="description"
        )
开发者ID:Tiendil,项目名称:the-tale,代码行数:15,代码来源:test_requests.py

示例14: setUp

    def setUp(self):
        super(BaseTestRequests, self).setUp()
        self.place1, self.place2, self.place3 = create_test_map()

        result, account_id, bundle_id = register_user('test_user_1', '[email protected]', '111111')
        self.account_1 = AccountPrototype.get_by_id(account_id)

        result, account_id, bundle_id = register_user('test_user_2', '[email protected]', '111111')
        self.account_2 = AccountPrototype.get_by_id(account_id)

        self.client = client.Client()

        helpers.prepair_forum()

        CategoryPrototype.create(caption='category-1', slug=clans_settings.FORUM_CATEGORY_SLUG, order=0)

        self.clan_2 = ClanPrototype.create(self.account_2, abbr=u'abbr2', name=u'name2', motto=u'motto', description=u'description')
开发者ID:Alkalit,项目名称:the-tale,代码行数:17,代码来源:test_requests.py

示例15: index

def index(context):

    accounts_query = AccountPrototype.live_query()

    if context.prefix:
        accounts_query = accounts_query.filter(nick__istartswith=context.prefix)

    accounts_count = accounts_query.count()

    url_builder = UrlBuilder(reverse("accounts:"), arguments={"page": context.page, "prefix": context.prefix})

    paginator = Paginator(context.page, accounts_count, conf.accounts_settings.ACCOUNTS_ON_PAGE, url_builder)

    if paginator.wrong_page_number:
        return dext_views.Redirect(paginator.last_page_url, permanent=False)

    account_from, account_to = paginator.page_borders(context.page)

    accounts_models = accounts_query.select_related().order_by("nick")[account_from:account_to]

    accounts = [AccountPrototype(model) for model in accounts_models]

    accounts_ids = [model.id for model in accounts_models]
    clans_ids = [model.clan_id for model in accounts_models]

    heroes = dict(
        (model.account_id, heroes_logic.load_hero(hero_model=model))
        for model in Hero.objects.filter(account_id__in=accounts_ids)
    )

    clans = {clan.id: clan for clan in ClanPrototype.get_list_by_id(clans_ids)}

    return dext_views.Page(
        "accounts/index.html",
        content={
            "heroes": heroes,
            "prefix": context.prefix,
            "accounts": accounts,
            "clans": clans,
            "resource": context.resource,
            "current_page_number": context.page,
            "paginator": paginator,
        },
    )
开发者ID:Tiendil,项目名称:the-tale,代码行数:44,代码来源:views.py


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