示例#1
0
    def setUp(self):
        super(IndexRequestsTests, self).setUp()
        self.requested_url = url('game:companions:')
        self.requested_url_disabled = url('game:companions:', state=relations.STATE.DISABLED.value)

        self.companion_1 = logic.create_companion_record(utg_name=names.generator.get_test_name(u'c-1'),
                                                         description='companion-description',
                                                         type=game_relations.BEING_TYPE.random(),
                                                         max_health=100,
                                                         dedication=relations.DEDICATION.random(),
                                                         archetype=game_relations.ARCHETYPE.random(),
                                                         mode=relations.MODE.random(),
                                                         abilities=helpers.FAKE_ABILITIES_CONTAINER_1,
                                                         communication_verbal=game_relations.COMMUNICATION_VERBAL.random(),
                                                         communication_gestures=game_relations.COMMUNICATION_GESTURES.random(),
                                                         communication_telepathic=game_relations.COMMUNICATION_TELEPATHIC.random(),
                                                         intellect_level=game_relations.INTELLECT_LEVEL.random(),
                                                         state=relations.STATE.ENABLED)

        self.companion_2 = logic.create_companion_record(utg_name=names.generator.get_test_name(u'c-2'),
                                                         description='companion-description',
                                                         type=game_relations.BEING_TYPE.random(),
                                                         max_health=100,
                                                         dedication=relations.DEDICATION.random(),
                                                         archetype=game_relations.ARCHETYPE.random(),
                                                         mode=relations.MODE.random(),
                                                         abilities=helpers.FAKE_ABILITIES_CONTAINER_2,
                                                         communication_verbal=game_relations.COMMUNICATION_VERBAL.random(),
                                                         communication_gestures=game_relations.COMMUNICATION_GESTURES.random(),
                                                         communication_telepathic=game_relations.COMMUNICATION_TELEPATHIC.random(),
                                                         intellect_level=game_relations.INTELLECT_LEVEL.random(),
                                                         state=relations.STATE.DISABLED)
示例#2
0
    def test_post_on_forum_already_publish(self):
        self.request_login(self.editor.email)
        self.post_ajax_json(url("news:publish-on-forum", self.news1.id))

        self.check_ajax_error(
            self.post_ajax_json(url("news:publish-on-forum", self.news1.id)), "forum_thread_already_exists"
        )
示例#3
0
    def test_other_hero_page(self):
        texts = (('pgf-health-percents', 2),
                 ('pgf-reset-abilities-timeout-button', 0),
                 ('pgf-reset-abilities-button', 0),
                 ('pgf-experience-percents', 0),
                 ('pgf-energy-percents', 0),
                 ('pgf-physic-power value', 1),
                 ('pgf-magic-power value', 1),
                 ('pgf-money', 1),
                 ('"pgf-health"', 2),
                 ('pgf-max-health', 2),
                 ('pgf-choose-ability-button', 0),
                 ('pgf-choose-preference-button', 0),
                 ('pgf-no-destiny-points', 0),
                 ('pgf-free-destiny-points', 0),
                 ('pgf-settings-container',0),
                 ('pgf-settings-tab-button', 1),
                 ('pgf-moderation-container', 0),
                 'pgf-no-folclor')

        self.request_logout()
        self.check_html_ok(self.request_html(url('game:heroes:show', self.hero.id)), texts=texts)

        account_2 = self.accounts_factory.create_account()
        self.request_login(account_2.email)
        self.check_html_ok(self.request_html(url('game:heroes:show', self.hero.id)), texts=texts)
示例#4
0
    def setUp(self):
        super(InfoRequestsTests, self).setUp()

        self.companion_1 = logic.create_companion_record(utg_name=names.generator.get_test_name(u'c-1'),
                                                         description='companion-description-1',
                                                         type=relations.TYPE.random(),
                                                         max_health=100,
                                                         dedication=relations.DEDICATION.random(),
                                                         archetype=game_relations.ARCHETYPE.random(),
                                                         mode=relations.MODE.random(),
                                                         abilities=helpers.FAKE_ABILITIES_CONTAINER_1,
                                                         state=relations.STATE.ENABLED)

        self.companion_2 = logic.create_companion_record(utg_name=names.generator.get_test_name(u'c-2'),
                                                         description='companion-description-2',
                                                         type=relations.TYPE.random(),
                                                         max_health=100,
                                                         dedication=relations.DEDICATION.random(),
                                                         archetype=game_relations.ARCHETYPE.random(),
                                                         mode=relations.MODE.random(),
                                                         abilities=helpers.FAKE_ABILITIES_CONTAINER_2,
                                                         state=relations.STATE.DISABLED)

        self.requested_url_1 = url('game:companions:info', self.companion_1.id)
        self.requested_url_2 = url('game:companions:info', self.companion_2.id)

        self.account_1 = self.accounts_factory.create_account()
        self.account_2 = self.accounts_factory.create_account()
        self.account_3 = self.accounts_factory.create_account()

        group_edit = sync_group('edit companions', ['companions.create_companionrecord'])
        group_edit.user_set.add(self.account_2._model)

        group_moderate = sync_group('moderate companions', ['companions.moderate_companionrecord'])
        group_moderate.user_set.add(self.account_3._model)
示例#5
0
    def test_full__logged_out_before_token_accept(self):

        api_client = Client()

        request_token_url = url('accounts:third-party:tokens:request-authorisation', api_version='1.0', api_client=project_settings.API_CLIENT)

        response = api_client.post(request_token_url, {'application_name': 'app-name',
                                                       'application_info': 'app-info',
                                                       'application_description': 'app-descr'})

        self.check_ajax_ok(response)

        token_url = s11n.from_json(response.content.decode('utf-8'))['data']['authorisation_page']

        token = prototypes.AccessTokenPrototype._db_latest()

        self.assertEqual(url('accounts:third-party:tokens:show', token.uid), token_url)

        self.check_html_ok(self.request_html(token_url), texts=['app-name', 'app-info', 'app-descr'])


        authorisation_state_url = url('accounts:third-party:tokens:authorisation-state', api_version='1.0', api_client=project_settings.API_CLIENT)

        self.check_ajax_ok(api_client.get(authorisation_state_url),
                           data={'account_id': None,
                                 'account_name': None,
                                 'state': relations.AUTHORISATION_STATE.UNPROCESSED.value,
                                 'session_expire_at': 666.6})

        self.check_ajax_ok(api_client.post(logout_url()))

        self.assertNotIn('_auth_user_id', api_client.session)

        self.assertNotEqual(prototypes.AccessTokenPrototype.get_by_uid(token.uid), None)
        self.assertNotIn(third_party_settings.ACCESS_TOKEN_SESSION_KEY, api_client.session)
示例#6
0
    def test_other_hero_page(self):
        texts = (('pgf-health-percents', 2),
                 ('pgf-reset-abilities-timeout-button', 0),
                 ('pgf-reset-abilities-button', 0),
                 ('pgf-experience-percents', 0),
                 ('pgf-energy-percents', 0),
                 ('pgf-physic-power value', 1),
                 ('pgf-magic-power value', 1),
                 ('pgf-money', 1),
                 ('"pgf-health"', 2),
                 ('pgf-max-health', 2),
                 ('pgf-choose-ability-button', 0),
                 ('pgf-choose-preference-button', 0),
                 ('pgf-no-destiny-points', 0),
                 ('pgf-free-destiny-points', 0),
                 ('pgf-settings-container',0),
                 ('pgf-settings-tab-button', 1),
                 ('pgf-moderation-container', 0),
                 'pgf-no-folclor')

        self.request_logout()
        self.check_html_ok(self.request_html(url('game:heroes:show', self.hero.id)), texts=texts)

        result, account_id, bundle_id = register_user('test_user_2', '*****@*****.**', '111111')

        self.request_login('*****@*****.**')
        self.check_html_ok(self.request_html(url('game:heroes:show', self.hero.id)), texts=texts)
示例#7
0
    def update(self):

        if self._template.state.is_ON_REVIEW and not self.can_moderate_templates and self._template.author_id != self.account.id:
            return self.auto_error('linguistics.templates.update.can_not_edit_anothers_template',
                                   u'Вы не можете редактировать вариант фразы, созданный другим игроком. Подождите пока его проверит модератор.')

        if self._template.get_child():
            return self.auto_error('linguistics.templates.update.template_has_child',
                                   u'У этой фразы уже есть копия. Отредактируйте её или попросите автора копии сделать это.')


        form = forms.TemplateForm(self._template.key,
                                  self._template.get_all_verificatos(),
                                  self.request.POST)

        if not form.is_valid():
            return self.json_error('linguistics.templates.update.form_errors', form.errors)

        utg_template = utg_templates.Template()
        utg_template.parse(form.c.template, externals=[v.value for v in self._template.key.variables])

        if (form.verificators == self._template.get_all_verificatos() and
            form.c.template == self._template.raw_template and
            form.get_restrictions() == self._template.raw_restrictions):
            return self.json_error('linguistics.templates.update.full_copy_restricted', u'Вы пытаетесь создать полную копию шаблона, в этом нет необходимости.')


        if self.can_moderate_templates or (self._template.author_id == self.account.id and self._template.state.is_ON_REVIEW):
            self._template.update(raw_template=form.c.template,
                                  utg_template=utg_template,
                                  verificators=form.verificators,
                                  restrictions=form.get_restrictions())

            prototypes.ContributionPrototype.get_for_or_create(type=relations.CONTRIBUTION_TYPE.TEMPLATE,
                                                               account_id=self.account.id,
                                                               entity_id=self._template.id,
                                                               source=relations.CONTRIBUTION_SOURCE.MODERATOR if self.can_moderate_templates else relations.CONTRIBUTION_SOURCE.PLAYER,
                                                               state=self._template.state.contribution_state)


            return self.json_ok(data={'next_url': url('linguistics:templates:show', self._template.id)})


        template = prototypes.TemplatePrototype.create(key=self._template.key,
                                                       raw_template=form.c.template,
                                                       utg_template=utg_template,
                                                       verificators=form.verificators,
                                                       restrictions=form.get_restrictions(),
                                                       author=self.account,
                                                       parent=self._template)

        prototypes.ContributionPrototype.get_for_or_create(type=relations.CONTRIBUTION_TYPE.TEMPLATE,
                                                           account_id=template.author_id,
                                                           entity_id=template.id,
                                                           source=relations.CONTRIBUTION_SOURCE.MODERATOR if self.can_moderate_templates else relations.CONTRIBUTION_SOURCE.PLAYER,
                                                           state=template.state.contribution_state)


        return self.json_ok(data={'next_url': url('linguistics:templates:show', template.id)})
示例#8
0
 def test_no_rights(self):
     self.check_ajax_error(
         self.post_ajax_json(url("news:disable-send-mails", self.news1.id), {}), "common.login_required"
     )
     self.request_login(self.user.email)
     self.check_ajax_error(
         self.post_ajax_json(url("news:disable-send-mails", self.news1.id), {}), "news.no_edit_rights"
     )
示例#9
0
    def test_post_on_forum_unloggined(self):
        self.check_redirect(url('news:publish-on-forum', self.news1.id),
                            login_page_url(url('news:publish-on-forum', self.news1.id)))

        self.assertEqual(forum_models.Thread.objects.all().count(), 0)

        self.check_html_ok(self.client.get(url('news:show', self.news1.id)), texts=(('pgf-forum-link', 0), ))
        self.check_html_ok(self.client.get(url('news:')), texts=(('pgf-forum-link', 0), ))
示例#10
0
    def test_post_on_forum__no_editor_rights(self):
        self.check_ajax_error(self.post_ajax_json(url('news:publish-on-forum', self.news1.id)),
                              'common.login_required')

        self.request_login(self.user.email)

        self.check_ajax_error(self.post_ajax_json(url('news:publish-on-forum', self.news1.id)),
                              'news.no_edit_rights')
示例#11
0
    def test_moderator_remove_post(self):
        self.request_login('*****@*****.**')
        self.check_ajax_ok(self.client.post(url('forum:posts:delete', self.post.id)))
        self.assertEqual(Post.objects.all().count(), 8)

        # check if edit & remove buttons has dissapeared
        self.check_html_ok(self.request_html(url('forum:threads:show', self.thread.id)), texts=[('pgf-remove-post-button', 2),
                                                                                                         ('pgf-change-post-button', 2)])
示例#12
0
    def test_moderator_create_thread_page_in_closed_theme(self):
        self.request_login('*****@*****.**')
        response = self.client.post(url('forum:subcategories:create-thread',  self.subcategory2.id),
                                    {'caption': 'thread5-caption', 'text': 'thread5-text'})

        thread = Thread.objects.all().order_by('-created_at')[0]

        self.check_ajax_ok(response, {'thread_id': thread.id,
                                      'thread_url': url('forum:threads:show', thread.id)})
示例#13
0
    def test_loggined_create_thread_page(self):
        self.request_login(self.main_account.email)
        response = self.client.post(url('forum:subcategories:create-thread',  self.subcategory.id),
                                    {'caption': 'thread5-caption', 'text': 'thread5-text'})

        thread = Thread.objects.all().order_by('-created_at')[0]

        self.check_ajax_ok(response, {'thread_id': thread.id,
                                      'thread_url': url('forum:threads:show', thread.id)})
示例#14
0
    def test_main_user_remove_post(self):
        self.request_login('*****@*****.**')
        self.assertEqual(Thread.objects.get(id=self.thread.id).posts_count, 3)
        self.assertEqual(SubCategory.objects.get(id=self.subcategory.id).posts_count, 5)

        self.check_ajax_ok(self.client.post(url('forum:posts:delete', self.post.id)))
        self.assertTrue(PostPrototype.get_by_id(self.post.id).is_removed)

        # check if edit & remove buttons has dissapeared
        self.check_html_ok(self.request_html(url('forum:threads:show', self.thread.id)), texts=[('pgf-remove-post-button', 2),
                                                                                                         ('pgf-change-post-button', 2)])
示例#15
0
    def test_post_on_forum_unexisting_category(self):
        self.request_login(self.editor.email)

        forum_models.SubCategory.objects.all().delete()

        self.check_ajax_error(self.post_ajax_json(url('news:publish-on-forum', self.news1.id)),
                              'forum_category_not_exists')

        self.assertEqual(forum_models.Thread.objects.all().count(), 0)

        self.check_html_ok(self.client.get(url('news:show', self.news1.id)), texts=(('pgf-forum-link', 0), ))
        self.check_html_ok(self.client.get(url('news:')), texts=(('pgf-forum-link', 0), ))
示例#16
0
    def test_subscriptions(self):
        self.check_ajax_ok(self.client.post(url('forum:threads:subscribe', self.thread1.id)))
        self.check_ajax_ok(self.client.post(url('forum:threads:subscribe', self.thread3.id)))
        self.check_ajax_ok(self.client.post(url('forum:subcategories:subscribe', self.subcat2.id)))

        texts = [('thread1-caption', 1),
                 ('thread2-caption', 0),
                 ('thread3-caption', 1),
                 ('subcat1-caption', 0),
                 ('subcat2-caption', 1),
                 ('pgf-no-thread-subscriptions-message', 0),
                 ('pgf-no-subcategory-subscriptions-message', 0)]
        self.check_html_ok(self.request_html(url('forum:subscriptions:')), texts=texts)
示例#17
0
    def test_create_with_all_fields(self):
        for word_type in utg_relations.WORD_TYPE.records:
            word = utg_words.Word.create_test_word(word_type, prefix='w-')
            requested_url = url('linguistics:words:create', type=word_type.value)

            with self.check_delta(prototypes.WordPrototype._db_count, 1):
                response = self.client.post(requested_url, helpers.get_word_post_data(word))

            last_prototype = prototypes.WordPrototype._db_latest()

            self.check_ajax_ok(response, data={'next_url': url('linguistics:words:show', last_prototype.id)})

            self.assertEqual(word, last_prototype.utg_word)
示例#18
0
    def test_second_page(self):
        for i in xrange(conf.settings.NEWS_ON_PAGE):
            self.create_news(i)

        first_page_texts = []

        for i in xrange(conf.settings.NEWS_ON_PAGE):
            first_page_texts.extend([('caption-%d' % i, 1), ('description-%d' % i, 1)])

        self.check_html_ok(self.request_html(url('news:', page=1)), texts=first_page_texts)

        self.check_html_ok(self.request_html(url('news:', page=2)), texts=[('news1-caption', 1), ('news1-description', 1),
                                                                           ('news2-caption', 1), ('news2-description', 1),
                                                                           ('news3-caption', 1), ('news3-description', 1) ])
示例#19
0
    def test_create_post_success(self):

        self.assertEqual(ThreadReadInfoPrototype._db_count(), 0)

        response = self.client.post(url('forum:threads:create-post', self.thread3.id), {'text': 'thread3-test-post'})

        post = PostPrototype._db_get_object(4)

        self.check_ajax_ok(response, data={'next_url': url('forum:threads:show', self.thread3.id) + ('?page=1#m%d' % post.id)})

        self.assertEqual(Post.objects.all().count(), 5)

        self.assertEqual(ThreadReadInfoPrototype._db_count(), 1)
        self.assertEqual(ThreadReadInfoPrototype._db_get_object(0).thread_id, self.thread3.id)
示例#20
0
def index(context):
    from the_tale.game.cards.relations import RARITY

    cards = effects.EFFECTS.values()

    if context.cards_availability:
        cards = [card for card in cards if card.TYPE.availability == context.cards_availability]

    if context.cards_rarity:
        cards = [card for card in cards if card.TYPE.rarity == context.cards_rarity]

    if context.cards_order_by.is_RARITY:
        cards = sorted(cards, key=lambda c: (c.TYPE.rarity.value, c.TYPE.text))
    elif context.cards_order_by.is_NAME:
        cards = sorted(cards, key=lambda c: (c.TYPE.text, c.TYPE.rarity.value))

    url_builder = UrlBuilder(url('guide:cards:'), arguments={ 'rarity': context.cards_rarity.value if context.cards_rarity else None,
                                                              'availability': context.cards_availability.value if context.cards_availability else None,
                                                              'order_by': context.cards_order_by.value})

    index_filter = CardsFilter(url_builder=url_builder, values={'rarity': context.cards_rarity.value if context.cards_rarity else None,
                                                                'availability': context.cards_availability.value if context.cards_availability else None,
                                                                'order_by': context.cards_order_by.value if context.cards_order_by else None})


    return dext_views.Page('cards/index.html',
                           content={'section': 'cards',
                                    'CARDS': cards,
                                    'index_filter': index_filter,
                                    'CARD_RARITY': RARITY,
                                    'resource': context.resource})
示例#21
0
 def test_can_reset_abilities(self):
     self.hero.abilities.set_reseted_at(datetime.datetime.fromtimestamp(0))
     self.hero.abilities.updated = True
     logic.save_hero(self.hero)
     self.check_html_ok(self.request_html(url('game:heroes:show', self.hero.id)),
                        texts=(('pgf-reset-abilities-timeout-button', 0),
                               ('pgf-reset-abilities-button', 1)))
示例#22
0
 def test_filter_by_type(self):
     MobRecord.objects.all().delete()
     mobs_storage.clear()
     MobRecordPrototype.create_random(uuid="bandit", type=game_relations.BEING_TYPE.COLDBLOODED)
     self.check_html_ok(
         self.request_html(url("guide:mobs:", type=game_relations.BEING_TYPE.COLDBLOODED.value)), texts=["bandit"]
     )
示例#23
0
文件: views.py 项目: Alkalit/the-tale
    def index(self, page=1, order_by=ORDER_BY.NAME):

        clans_query = ClanPrototype._model_class.objects.all()

        clans_number = clans_query.count()

        page = int(page) - 1

        url_builder = UrlBuilder(url('accounts:clans:'), arguments={'order_by': order_by.value})

        index_filter = IndexFilter(url_builder=url_builder, values={'order_by': order_by.value})

        paginator = Paginator(page, clans_number, clans_settings.CLANS_ON_PAGE, url_builder)

        if paginator.wrong_page_number:
            return self.redirect(paginator.last_page_url, permanent=False)

        clans_query = clans_query.order_by(order_by.order_field)

        clans_from, clans_to = paginator.page_borders(page)

        clans = [ ClanPrototype(clan_model) for clan_model in clans_query[clans_from:clans_to]]

        memberships = [MembershipPrototype(membership_model) for membership_model in MembershipPrototype._db_filter(clan__in=[clan.id for clan in clans],
                                                                                                                    role=MEMBER_ROLE.LEADER)]
        accounts = {account_model.id: AccountPrototype(model=account_model)
                    for account_model in AccountPrototype._db_filter(id__in=[membership.account_id for membership in memberships])}
        leaders = {membership.clan_id:accounts[membership.account_id] for membership in memberships}

        return self.template('clans/index.html',
                             {'clans': clans,
                              'page_id': PAGE_ID.INDEX,
                              'paginator': paginator,
                              'index_filter': index_filter,
                              'leaders': leaders})
示例#24
0
    def create(self, key):

        form = forms.TemplateForm(key,
                                  prototypes.TemplatePrototype.get_start_verificatos(key=key),
                                  self.request.POST)

        if not form.is_valid():
            return self.json_error('linguistics.templates.create.form_errors', form.errors)

        utg_template = utg_templates.Template()
        utg_template.parse(form.c.template, externals=[v.value for v in key.variables])

        template = prototypes.TemplatePrototype.create(key=key,
                                                       raw_template=form.c.template,
                                                       utg_template=utg_template,
                                                       verificators=form.verificators,
                                                       author=self.account,
                                                       restrictions=form.get_restrictions())

        prototypes.ContributionPrototype.get_for_or_create(type=relations.CONTRIBUTION_TYPE.TEMPLATE,
                                                           account_id=template.author_id,
                                                           entity_id=template.id,
                                                           source=relations.CONTRIBUTION_SOURCE.MODERATOR if self.can_moderate_templates else relations.CONTRIBUTION_SOURCE.PLAYER,
                                                           state=template.state.contribution_state)

        return self.json_ok(data={'next_url': url('linguistics:templates:show', template.id)})
示例#25
0
    def test_chooce_preferences_dialog(self):
        self.hero.level = relations.PREFERENCE_TYPE.EQUIPMENT_SLOT.level_required
        logic.save_hero(self.hero)

        for preference_type in relations.PREFERENCE_TYPE.records:
            texts = []
            self.check_html_ok(self.request_html(url('game:heroes:choose-preferences-dialog', self.hero.id) + ('?type=%d' % preference_type.value)), texts=texts)
示例#26
0
 def test_accounts_not_found_message(self):
     self.check_html_ok(self.request_html(url('accounts:', prefix='ac')), texts=(('pgf-account-record', 0),
                                                                                 ('pgf-no-accounts-message', 1),
                                                                                 ('test_user_bot', 0),
                                                                                 ('test_user1', 0),
                                                                                 ('test_user2', 0),
                                                                                 ('test_user3', 0),))
示例#27
0
    def setUp(self):
        super(ShowRequestsTests, self).setUp()
        self.token = prototypes.AccessTokenPrototype.create(application_name='app-name-1',
                                                            application_info='app-info-1',
                                                            application_description='app-descr-1')

        self.requested_url = url('accounts:third-party:tokens:show', self.token.uid)
示例#28
0
 def test_no_description(self):
     artifact = artifacts_storage.all()[0]
     artifact.description = ""
     artifact.save()
     self.check_html_ok(
         self.request_html(url("guide:artifacts:info", artifact.id)), texts=[("pgf-no-description", 1)]
     )
示例#29
0
 def test_last_achievements(self):
     self.request_login(self.account_1.email)
     test_url = url('accounts:achievements:', account=self.account_1.id)
     self.check_html_ok(self.request_html(test_url), texts=[('pgf-last-achievements', 1),
                                                            self.achievement_1.caption,
                                                            ('pgf-all-achievements', 1),
                                                            ('pgf-no-last-achievements', 0)] + [group.text for group in ACHIEVEMENT_GROUP.records])
示例#30
0
    def test_sent(self):
        self.request_login(self.account1.email)
        texts = [('message_1_2 1', 1),
                 ('message_1_2 2', 1),
                 ('message_1_2 3', 1),]

        self.check_html_ok(self.request_html(url('accounts:messages:sent')), texts=texts)
示例#31
0
 def setUp(self):
     super(KitsEditTests, self).setUp()
     self.test_url = url('collections:kits:edit', self.kit_2.id)
示例#32
0
 def setUp(self):
     super(KitsUpdateTests, self).setUp()
     self.test_url = url('collections:kits:update', self.kit_2.id)
示例#33
0
def logout_url():
    return url('accounts:auth:api-logout',
               api_version='1.0',
               api_client=project_settings.API_CLIENT)
示例#34
0
 def test_index__no_friends(self):
     self.check_html_ok(self.request_html(url('accounts:friends:')),
                        texts=['pgf-no-friends-message'])
示例#35
0
 def test_success(self):
     self.request_login(self.editor.email)
     self.check_html_ok(self.request_html(url('news:edit', self.news1.id)),
                        texts=[('news.no_edit_rights', 0)])
示例#36
0
def login_url(target_url='/'):
    return url('accounts:auth:api-login',
               api_version='1.0',
               api_client=project_settings.API_CLIENT,
               next_url=target_url.encode('utf-8'))
示例#37
0
def create_sell_lot_url():
    return url('shop:create-sell-lot')
示例#38
0
 def url(self):
     from dext.common.utils.urls import url
     return url('game:persons:show', self.id)
 def test_processed_view__real(self):
     self.assertEqual(self.task.process(logger=mock.Mock()), None) # sent mail
     postponed_taks = self.task.process(logger=mock.Mock()) # create task
     postponed_taks.process(logger=mock.Mock())
     self.check_ajax_ok(self.client.get(url('postponed-tasks:status', postponed_taks.id)))
     self.assertNotIn('_auth_user_id', self.client.session)
示例#40
0
 def test_already_exists(self):
     self.check_ajax_ok(self.client.post(url('game:bills:vote', self.bill.id, type=VOTE_TYPE.FOR.value), {}))
     self.check_ajax_error(self.client.post(url('game:bills:vote', self.bill.id, type=VOTE_TYPE.FOR.value), {}), 'bills.vote.vote_exists')
     self.check_bill_votes(self.bill.id, 2, 0)
示例#41
0
 def test_candidates__no_candidates(self):
     self.check_html_ok(self.request_html(
         url('accounts:friends:candidates')),
                        texts=['pgf-no-candidates-message'])
示例#42
0
 def test_big_page_number(self):
     self.check_redirect(
         url('news:') + '?page=666',
         url('news:') + '?page=1')
示例#43
0
 def test_no_item(self):
     self.request_login(self.editor.email)
     self.check_html_ok(self.request_html(url('news:edit', 666)),
                        texts=[('news.no_edit_rights', 0)])
示例#44
0
 def setUp(self):
     super(UsePvPAbilityRequestsTests, self).setUp()
     self.ability = random.choice(ABILITIES.values())
     self.change_style_url = url('game:pvp:use-ability',
                                 ability=self.ability.TYPE)
示例#45
0
 def url(self):
     return urls.url('guide:artifacts:show', self.id)
示例#46
0
 def test_form_errors(self):
     self.request_login(self.editor.email)
     self.check_ajax_error(self.post_ajax_json(url('news:create'), {}),
                           'form_errors')
示例#47
0
 def test_no_rights(self):
     self.check_redirect(url('news:edit', self.news1.id),
                         login_page_url(url('news:edit', self.news1.id)))
     self.request_login(self.user.email)
     self.check_html_ok(self.request_html(url('news:edit', self.news1.id)),
                        texts=['news.no_edit_rights'])
示例#48
0
 def test_request_friendship_form_error(self):
     self.check_ajax_error(
         self.client.post(
             url('accounts:friends:request', friend=self.account_2.id), {}),
         'friends.request_friendship.form_errors')
     self.assertEqual(Friendship.objects.all().count(), 0)
示例#49
0
 def test_request_dialog(self):
     self.check_html_ok(
         self.request_html(
             url('accounts:friends:request', friend=self.account_2.id)))
示例#50
0
 def test_request_friendship_system_user(self):
     self.check_ajax_error(
         self.client.post(
             url('accounts:friends:request', friend=get_system_user().id),
             {'text': 'text 1'}), 'friends.request_friendship.system_user')
     self.assertEqual(Friendship.objects.all().count(), 0)
示例#51
0
 def test_no_rights(self):
     self.check_ajax_error(self.post_ajax_json(url('news:create'), {}),
                           'common.login_required')
     self.request_login(self.user.email)
     self.check_ajax_error(self.post_ajax_json(url('news:create'), {}),
                           'news.no_edit_rights')
示例#52
0
 def test_request_dialog__system_user(self):
     self.check_html_ok(self.request_html(
         url('accounts:friends:request', friend=get_system_user().id)),
                        texts=['friends.request_dialog.system_user'])
示例#53
0
 def setUp(self):
     super(KitsCreateTests, self).setUp()
     self.create_url = url('collections:kits:create')
示例#54
0
 def url(self):
     return urls.url('game:heroes:show', self.id)
示例#55
0
 def setUp(self):
     super(KitsNewTests, self).setUp()
     self.test_url = url('collections:kits:new')
示例#56
0
 def setUp(self):
     super(KitsDisapproveTests, self).setUp()
     self.disapprove_url = url('collections:kits:disapprove', self.kit_2.id)
示例#57
0
 def url(self):
     return urls.url('game:persons:show', self.id)
示例#58
0
def login_page_url(target_url='/'):
    return url('accounts:auth:page-login', next_url=target_url.encode('utf-8'))
 def test_create(self):
     self.assertEqual(self.postponed_task.processed_data, {'next_url': url('accounts:profile:edited')})
     self.assertEqual(self.postponed_task.task_id, self.task.id)
     self.assertTrue(self.postponed_task.state.is_UNPROCESSED)
示例#60
0
 def test_success_agains(self):
     self.check_ajax_ok(self.client.post(url('game:bills:vote', self.bill.id, type=VOTE_TYPE.AGAINST.value), {}))
     vote = VotePrototype(Vote.objects.all()[1])
     self.check_vote(vote, self.account2, VOTE_TYPE.AGAINST, self.bill.id)
     self.check_bill_votes(self.bill.id, 1, 1)