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
b387189d
Kaydet (Commit)
b387189d
authored
Tem 20, 2016
tarafından
Stanislav Karpov
Kaydeden (comit)
Tim Graham
Agu 11, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26919 -- Added the action form's media in the changelist view.
üst
b785927b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
0 deletions
+21
-0
options.py
django/contrib/admin/options.py
+1
-0
admin.py
tests/admin_views/admin.py
+2
-0
forms.py
tests/admin_views/forms.py
+6
-0
tests.py
tests/admin_views/tests.py
+12
-0
No files found.
django/contrib/admin/options.py
Dosyayı görüntüle @
b387189d
...
...
@@ -1642,6 +1642,7 @@ class ModelAdmin(BaseModelAdmin):
if
actions
:
action_form
=
self
.
action_form
(
auto_id
=
None
)
action_form
.
fields
[
'action'
]
.
choices
=
self
.
get_action_choices
(
request
)
media
+=
action_form
.
media
else
:
action_form
=
None
...
...
tests/admin_views/admin.py
Dosyayı görüntüle @
b387189d
...
...
@@ -22,6 +22,7 @@ from django.utils.html import format_html
from
django.utils.safestring
import
mark_safe
from
django.utils.six
import
StringIO
from
.forms
import
MediaActionForm
from
.models
import
(
Actor
,
AdminOrderedAdminMethod
,
AdminOrderedCallable
,
AdminOrderedField
,
AdminOrderedModelMethod
,
Album
,
Answer
,
Article
,
BarAccount
,
Book
,
...
...
@@ -235,6 +236,7 @@ class PersonaAdmin(admin.ModelAdmin):
class
SubscriberAdmin
(
admin
.
ModelAdmin
):
actions
=
[
'mail_admin'
]
action_form
=
MediaActionForm
def
mail_admin
(
self
,
request
,
selected
):
EmailMessage
(
...
...
tests/admin_views/forms.py
Dosyayı görüntüle @
b387189d
from
django
import
forms
from
django.contrib.admin.forms
import
AdminAuthenticationForm
from
django.contrib.admin.helpers
import
ActionForm
class
CustomAdminAuthenticationForm
(
AdminAuthenticationForm
):
...
...
@@ -12,3 +13,8 @@ class CustomAdminAuthenticationForm(AdminAuthenticationForm):
if
username
==
'customform'
:
raise
forms
.
ValidationError
(
'custom form error'
)
return
username
class
MediaActionForm
(
ActionForm
):
class
Media
:
js
=
[
'path/to/media.js'
]
tests/admin_views/tests.py
Dosyayı görüntüle @
b387189d
...
...
@@ -43,6 +43,7 @@ from django.utils.six.moves.urllib.parse import parse_qsl, urljoin, urlparse
from
.
import
customadmin
from
.admin
import
CityAdmin
,
site
,
site2
from
.forms
import
MediaActionForm
from
.models
import
(
Actor
,
AdminOrderedAdminMethod
,
AdminOrderedCallable
,
AdminOrderedField
,
AdminOrderedModelMethod
,
Answer
,
Article
,
BarAccount
,
Book
,
Bookmark
,
...
...
@@ -3374,6 +3375,17 @@ action)</option>
self
.
assertEqual
(
len
(
mail
.
outbox
),
1
)
self
.
assertEqual
(
mail
.
outbox
[
0
]
.
subject
,
'Greetings from a function action'
)
def
test_media_from_actions_form
(
self
):
"""
The action form's media is included in changelist view's media.
"""
response
=
self
.
client
.
get
(
reverse
(
'admin:admin_views_subscriber_changelist'
))
media_path
=
MediaActionForm
.
Media
.
js
[
0
]
self
.
assertIsInstance
(
response
.
context
[
'action_form'
],
MediaActionForm
)
self
.
assertIn
(
'media'
,
response
.
context
)
self
.
assertIn
(
media_path
,
response
.
context
[
'media'
]
.
_js
)
self
.
assertContains
(
response
,
media_path
)
def
test_user_message_on_none_selected
(
self
):
"""
User should see a warning when 'Go' is pressed and no items are 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