Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
f9ff1df1
Kaydet (Commit)
f9ff1df1
authored
Kas 09, 2018
tarafından
Matthias Kestenholz
Kaydeden (comit)
Tim Graham
Kas 09, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29917 -- Stopped collecting ModelAdmin.actions from base ModelAdmins.
üst
a375e911
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
11 deletions
+46
-11
options.py
django/contrib/admin/options.py
+2
-7
actions.txt
docs/ref/contrib/admin/actions.txt
+2
-4
2.2.txt
docs/releases/2.2.txt
+21
-0
test_actions.py
tests/modeladmin/test_actions.py
+21
-0
No files found.
django/contrib/admin/options.py
Dosyayı görüntüle @
f9ff1df1
...
...
@@ -859,13 +859,8 @@ class ModelAdmin(BaseModelAdmin):
for
(
name
,
func
)
in
self
.
admin_site
.
actions
:
description
=
getattr
(
func
,
'short_description'
,
name
.
replace
(
'_'
,
' '
))
actions
.
append
((
func
,
name
,
description
))
# Then gather them from the model admin and all parent classes,
# starting with self and working back up.
for
klass
in
self
.
__class__
.
mro
()[::
-
1
]:
class_actions
=
getattr
(
klass
,
'actions'
,
[])
or
[]
actions
.
extend
(
self
.
get_action
(
action
)
for
action
in
class_actions
)
# Add actions from this ModelAdmin.
actions
.
extend
(
self
.
get_action
(
action
)
for
action
in
self
.
actions
or
[])
# get_action might have returned None, so filter any of those out.
return
filter
(
None
,
actions
)
...
...
docs/ref/contrib/admin/actions.txt
Dosyayı görüntüle @
f9ff1df1
...
...
@@ -343,10 +343,8 @@ Conditionally enabling or disabling actions
This returns a dictionary of actions allowed. The keys are action names, and
the values are ``(function, name, short_description)`` tuples.
Most of the time you'll use this method to conditionally remove actions from
the list gathered by the superclass. For example, if I only wanted users
whose names begin with 'J' to be able to delete objects in bulk, I could do
the following::
For example, if you only want users whose names begin with 'J' to be able
to delete objects in bulk::
class MyModelAdmin(admin.ModelAdmin):
...
...
...
docs/releases/2.2.txt
Dosyayı görüntüle @
f9ff1df1
...
...
@@ -293,6 +293,27 @@ Database backend API
* Third party database backends must implement support for partial indexes or
set ``DatabaseFeatures.supports_partial_indexes`` to ``False``.
Admin actions are no longer collected from base ``ModelAdmin`` classes
----------------------------------------------------------------------
For example, in older versions of Django::
from django.contrib import admin
class BaseAdmin(admin.ModelAdmin):
actions = ['a']
class SubAdmin(BaseAdmin):
actions = ['b']
``SubAdmin`` will have actions ``'a'`` and ``'b'``.
Now ``actions`` follows standard Python inheritance. To get the same result as
before::
class SubAdmin(BaseAdmin):
actions = BaseAdmin.actions + ['b']
:mod:`django.contrib.gis`
-------------------------
...
...
tests/modeladmin/test_actions.py
Dosyayı görüntüle @
f9ff1df1
...
...
@@ -55,3 +55,24 @@ class AdminActionsTests(TestCase):
mock_request
.
user
=
user
actions
=
ma
.
get_actions
(
mock_request
)
self
.
assertEqual
(
list
(
actions
.
keys
()),
expected
)
def
test_actions_inheritance
(
self
):
class
AdminBase
(
admin
.
ModelAdmin
):
actions
=
[
'custom_action'
]
def
custom_action
(
modeladmin
,
request
,
queryset
):
pass
class
AdminA
(
AdminBase
):
pass
class
AdminB
(
AdminBase
):
actions
=
None
ma1
=
AdminA
(
Band
,
admin
.
AdminSite
())
action_names
=
[
name
for
_
,
name
,
_
in
ma1
.
_get_base_actions
()]
self
.
assertEqual
(
action_names
,
[
'delete_selected'
,
'custom_action'
])
# `actions = None` removes actions from superclasses.
ma2
=
AdminB
(
Band
,
admin
.
AdminSite
())
action_names
=
[
name
for
_
,
name
,
_
in
ma2
.
_get_base_actions
()]
self
.
assertEqual
(
action_names
,
[
'delete_selected'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment