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


Python admin.ACTION_CHECKBOX_NAME属性代码示例

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


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

示例1: test_refresh_tags_from_anidb_confirmed

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_refresh_tags_from_anidb_confirmed(self):
        self.add_to_responses('hibike_euphonium.xml')
        self.client.login(username='test', password='test')
        hibike = Work.objects.get(title='Hibike! Euphonium')

        refresh_tags_from_anidb_url = reverse('admin:mangaki_work_changelist')
        context = {
            'action': 'update_tags_via_anidb',
            admin.ACTION_CHECKBOX_NAME: self.work_ids,
            'confirm': 1,
            'to_update_work_ids': [str(hibike.pk)],
            'work_ids': [str(hibike.pk), str(hibike.pk), str(hibike.pk)],
            'tag_titles': ['female protagonist', 'facial distortion', 'training'],
            'weights': ['0', '0', '400'],
            'anidb_tag_ids': ['5851', '4055', '3831'],
            'tag_operations': ['added', 'added', 'added'],
            'tag_checkboxes': [str(hibike.pk)+':5851', str(hibike.pk)+':4055', str(hibike.pk)+':3831']
        }

        response = self.client.post(refresh_tags_from_anidb_url, context)
        self.assertEqual(response.status_code, 302)

        tags = set(Work.objects.get(anidb_aid=10889).taggedwork_set.all().values_list('tag__title', flat=True)) 
开发者ID:mangaki,项目名称:mangaki,代码行数:25,代码来源:test_refresh_from_anidb.py

示例2: test_merge_confirmed

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_merge_confirmed(self):
        self.client.login(username='test', password='test')
        merge_url = reverse('admin:mangaki_work_changelist')
        context = {
            'action': 'merge',
            admin.ACTION_CHECKBOX_NAME: self.work_ids,
            'confirm': 1,
            'id': self.work_ids[0],  # Chosen ID for the canonical work
            'fields_to_choose': '',
            'fields_required': ''
        }
        with self.assertNumQueries(39):
            self.client.post(merge_url, context)
        self.assertEqual(list(Rating.objects.filter(user__in=self.users).values_list('choice', flat=True)), ['favorite'] * 4)
        self.assertEqual(Work.all_objects.filter(redirect__isnull=True).count(), 1)
        self.assertEqual(WorkCluster.objects.count(), 1)
        self.assertEqual(Staff.objects.count(), 2)
        self.assertEqual(Reference.objects.count(), 2)
        self.assertEqual(Work.objects.get(id=self.work_ids[0]).genre.count(), 2)

    # noinspection PyPep8Naming
    # FIXME: classical scenario, we should have a simpler decorator to perform those tests 
开发者ID:mangaki,项目名称:mangaki,代码行数:24,代码来源:test_merge.py

示例3: approve_selected_new_assets

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def approve_selected_new_assets(self, request, queryset):
        """
        用于在申请redis的界面添加一个审批通过按钮
        :param request: Http Request实例
        :param queryset: 勾选实例名称
        :return:
        """
        # 获得被打钩的checkbox对应的Redis的id编号,用于更新数据库的主键
        selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
        success_upline_number = 0
        try:
            for asset_id in selected:
                obj = ApproveRedis(request, asset_id)
                create_redis_ins = obj.create_asset()
                if create_redis_ins:
                    success_upline_number += 1
                    self.message_user(request, "成功批准  %s  个新Redis实例上线!" % success_upline_number)
                    obj.redis_apply_status_update(statu=3)
                else:
                    self.message_user(request, "实例为 {0} 的实例上线失败,已存在上线实例,请检查".format(obj.redis_ins_name))
        except ValueError as e:
            self.message_user(request, "实例为 {0} 的实例上线失败,原因为{1}".format(queryset, e)) 
开发者ID:NaNShaner,项目名称:repoll,代码行数:24,代码来源:admin.py

示例4: deny_selected_new_assets

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def deny_selected_new_assets(self, request, queryset):
        """
        用于在申请redis的界面添加一个审批拒绝按钮
        :param request: Http Request实例
        :param queryset: 勾选实例名称
        :return:
        """
        # 获得被打钩的checkbox对应的Redis的id编号,用于更新数据库的主键
        selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
        deny_upline_number = 0
        try:
            for asset_id in selected:
                obj = ApproveRedis(request, asset_id)
                deny_redis_ins = obj.deny_create()
                if deny_redis_ins:
                    deny_upline_number += 1
                    obj.redis_apply_status_update(statu=4)
                    self.message_user(request, "已拒绝  %s  个新Redis实例上线!" % deny_upline_number)
                else:
                    self.message_user(request, "操作实例为 {0} 的实例失败,已存在上线实例,请检查".format(obj.redis_ins_name))
        except ValueError as e:
            self.message_user(request, "操作实例为 {0} 的实例失败,原因为{1}".format(queryset, e)) 
开发者ID:NaNShaner,项目名称:repoll,代码行数:24,代码来源:admin.py

示例5: cluster_canons_action

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def cluster_canons_action(self, request, queryset):
        selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
        #ct = ContentType.objects.get_for_model(queryset.model)
        #return HttpResponseRedirect("/cluster/?ct=%s&ids=%s" % (ct.pk, ",".join(selected)))
        return HttpResponseRedirect("/admin/crowdataapp/canonicalfieldentrylabel/cluster/?ids=%s" % ",".join(selected)) 
开发者ID:crowdata,项目名称:crowdata,代码行数:7,代码来源:admin.py

示例6: test_prize_key_import_action

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_prize_key_import_action(self):
        self.client.login(username='admin', password='password')

        response = self.client.post(
            reverse('admin:tracker_prize_changelist'),
            {
                'action': 'import_keys_action',
                ACTION_CHECKBOX_NAME: [self.prize.id, self.prize_with_keys.id],
            },
        )
        self.assertRedirects(response, reverse('admin:tracker_prize_changelist'))
        self.assertMessages(response, ['Select exactly one prize that uses keys.'])
        response = self.client.post(
            reverse('admin:tracker_prize_changelist'),
            {'action': 'import_keys_action', ACTION_CHECKBOX_NAME: [self.prize.id]},
        )
        self.assertRedirects(response, reverse('admin:tracker_prize_changelist'))
        self.assertMessages(response, ['Select exactly one prize that uses keys.'])
        response = self.client.post(
            reverse('admin:tracker_prize_changelist'),
            {
                'action': 'import_keys_action',
                ACTION_CHECKBOX_NAME: [self.prize_with_keys.id],
            },
        )
        self.assertRedirects(
            response,
            reverse('admin:tracker_prize_key_import', args=(self.prize_with_keys.id,)),
        ) 
开发者ID:GamesDoneQuick,项目名称:donation-tracker,代码行数:31,代码来源:test_prize.py

示例7: test_refresh_work_from_anidb

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_refresh_work_from_anidb(self):
        self.add_to_responses('hibike_euphonium.xml')
        self.add_to_responses('punchline.xml')

        self.client.login(username='test', password='test')
        refresh_work_from_anidb_url = reverse('admin:mangaki_work_changelist')
        response = self.client.post(
            refresh_work_from_anidb_url,
            {'action': 'refresh_work_from_anidb', admin.ACTION_CHECKBOX_NAME: self.work_ids},
            follow=True
        )
        self.assertEqual(response.status_code, 200)

        self.assertEqual(Work.objects.get(anidb_aid=10889).title, 'Hibike! Euphonium') 
开发者ID:mangaki,项目名称:mangaki,代码行数:16,代码来源:test_refresh_from_anidb.py

示例8: test_refresh_tags_from_anidb

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_refresh_tags_from_anidb(self):
        self.add_to_responses('hibike_euphonium.xml')
        self.client.login(username='test', password='test')

        refresh_tags_from_anidb_url = reverse('admin:mangaki_work_changelist')
        response = self.client.post(
            refresh_tags_from_anidb_url,
            {'action': 'update_tags_via_anidb', admin.ACTION_CHECKBOX_NAME: self.work_ids},
            follow=True
        )
        self.assertEqual(response.status_code, 200) 
开发者ID:mangaki,项目名称:mangaki,代码行数:13,代码来源:test_refresh_from_anidb.py

示例9: test_change_title

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_change_title(self):
        self.client.login(username='test', password='test')
        change_title_url = reverse('admin:mangaki_work_changelist')
        response = self.client.post(
            change_title_url,
            {'action': 'change_title', admin.ACTION_CHECKBOX_NAME: self.work_ids},
            follow=True
        )
        self.assertEqual(response.status_code, 200) 
开发者ID:mangaki,项目名称:mangaki,代码行数:11,代码来源:test_change_default_title.py

示例10: test_change_title_no_alternative_titles

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_change_title_no_alternative_titles(self):
        self.client.login(username='test', password='test')
        change_title_url = reverse('admin:mangaki_work_changelist')
        response = self.client.post(
            change_title_url,
            {'action': 'change_title', admin.ACTION_CHECKBOX_NAME: self.work_ids[2]},
            follow=True
        )
        self.assertEqual(response.status_code, 200) 
开发者ID:mangaki,项目名称:mangaki,代码行数:11,代码来源:test_change_default_title.py

示例11: test_merge

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_merge(self):
        self.client.login(username='test', password='test')
        merge_url = reverse('admin:mangaki_work_changelist')
        response = self.client.post(merge_url, {'action': 'merge', admin.ACTION_CHECKBOX_NAME: self.work_ids})
        self.assertEqual(response.status_code, 200) 
开发者ID:mangaki,项目名称:mangaki,代码行数:7,代码来源:test_merge.py

示例12: test_approval_action_approves_application

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_approval_action_approves_application(self):
        self.client.force_login(self.admin)
        change_url = reverse_lazy("admin:application_application_changelist")

        self.client.post(
            change_url,
            {"action": "approve", admin.ACTION_CHECKBOX_NAME: [self.app.pk]},
            follow=True,
        )

        self.app.refresh_from_db()
        self.assertEqual(self.app.status, STATUS_ADMITTED) 
开发者ID:tamuhack-org,项目名称:Ouroboros,代码行数:14,代码来源:application.py

示例13: test_approval_action_sends_approval_email

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_approval_action_sends_approval_email(self):
        self.client.force_login(self.admin)
        change_url = reverse_lazy("admin:application_application_changelist")

        self.client.post(
            change_url, {"action": "approve", admin.ACTION_CHECKBOX_NAME: [self.app.pk]}
        )

        self.assertEqual(len(mail.outbox), 1) 
开发者ID:tamuhack-org,项目名称:Ouroboros,代码行数:11,代码来源:application.py

示例14: test_reject_action_sends_rejection_email

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_reject_action_sends_rejection_email(self):
        self.client.force_login(self.admin)
        change_url = reverse_lazy("admin:application_application_changelist")

        self.client.post(
            change_url,
            {"action": "reject", admin.ACTION_CHECKBOX_NAME: [self.app.pk]},
            follow=True,
        )

        self.assertEqual(len(mail.outbox), 1) 
开发者ID:tamuhack-org,项目名称:Ouroboros,代码行数:13,代码来源:application.py

示例15: test_reject_action_rejects_application

# 需要导入模块: from django.contrib import admin [as 别名]
# 或者: from django.contrib.admin import ACTION_CHECKBOX_NAME [as 别名]
def test_reject_action_rejects_application(self):
        self.client.force_login(self.admin)
        change_url = reverse_lazy("admin:application_application_changelist")
        self.client.post(
            change_url,
            {"action": "reject", admin.ACTION_CHECKBOX_NAME: [self.app.pk]},
            follow=True,
        )
        self.app.refresh_from_db()
        self.assertEqual(self.app.status, STATUS_REJECTED) 
开发者ID:tamuhack-org,项目名称:Ouroboros,代码行数:12,代码来源:application.py


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