當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。