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
8ab58b80
Kaydet (Commit)
8ab58b80
authored
Ara 10, 2015
tarafından
Sergey Fedoseev
Kaydeden (comit)
Tim Graham
Ara 10, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #25883 -- Fixed admin deletion page summary counts for related objects.
üst
a44dc200
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
5 deletions
+11
-5
utils.py
django/contrib/admin/utils.py
+4
-3
1.9.1.txt
docs/releases/1.9.1.txt
+3
-0
models.py
tests/admin_views/models.py
+1
-0
tests.py
tests/admin_views/tests.py
+3
-2
No files found.
django/contrib/admin/utils.py
Dosyayı görüntüle @
8ab58b80
...
...
@@ -163,8 +163,9 @@ def get_deleted_objects(objs, opts, user, admin_site, using):
to_delete
=
collector
.
nested
(
format_callback
)
protected
=
[
format_callback
(
obj
)
for
obj
in
collector
.
protected
]
model_count
=
{
model
.
_meta
.
verbose_name_plural
:
len
(
objs
)
for
model
,
objs
in
collector
.
model_objs
.
items
()}
return
to_delete
,
collector
.
model_count
,
perms_needed
,
protected
return
to_delete
,
model_count
,
perms_needed
,
protected
class
NestedObjects
(
Collector
):
...
...
@@ -172,7 +173,7 @@ class NestedObjects(Collector):
super
(
NestedObjects
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
edges
=
{}
# {from_instance: [to_instances]}
self
.
protected
=
set
()
self
.
model_
count
=
defaultdict
(
in
t
)
self
.
model_
objs
=
defaultdict
(
se
t
)
def
add_edge
(
self
,
source
,
target
):
self
.
edges
.
setdefault
(
source
,
[])
.
append
(
target
)
...
...
@@ -187,7 +188,7 @@ class NestedObjects(Collector):
self
.
add_edge
(
getattr
(
obj
,
related_name
),
obj
)
else
:
self
.
add_edge
(
None
,
obj
)
self
.
model_
count
[
obj
.
_meta
.
verbose_name_plural
]
+=
1
self
.
model_
objs
[
obj
.
_meta
.
model
]
.
add
(
obj
)
try
:
return
super
(
NestedObjects
,
self
)
.
collect
(
objs
,
source_attr
=
source_attr
,
**
kwargs
)
except
models
.
ProtectedError
as
e
:
...
...
docs/releases/1.9.1.txt
Dosyayı görüntüle @
8ab58b80
...
...
@@ -26,3 +26,6 @@ Bugfixes
* Fixed missing ``varchar/text_pattern_ops`` index on ``CharField`` and
``TextField`` respectively when using ``AlterField`` on PostgreSQL
(:ticket:`25412`).
* Fixed admin's delete confirmation page's summary counts of related objects
(:ticket:`25883`).
tests/admin_views/models.py
Dosyayı görüntüle @
8ab58b80
...
...
@@ -40,6 +40,7 @@ class Article(models.Model):
content
=
models
.
TextField
()
date
=
models
.
DateTimeField
()
section
=
models
.
ForeignKey
(
Section
,
models
.
CASCADE
,
null
=
True
,
blank
=
True
)
another_section
=
models
.
ForeignKey
(
Section
,
models
.
CASCADE
,
null
=
True
,
blank
=
True
,
related_name
=
'+'
)
sub_section
=
models
.
ForeignKey
(
Section
,
models
.
SET_NULL
,
null
=
True
,
blank
=
True
,
related_name
=
'+'
)
def
__str__
(
self
):
...
...
tests/admin_views/tests.py
Dosyayı görüntüle @
8ab58b80
...
...
@@ -1292,7 +1292,8 @@ class AdminViewPermissionsTest(TestCase):
)
cls
.
s1
=
Section
.
objects
.
create
(
name
=
'Test section'
)
cls
.
a1
=
Article
.
objects
.
create
(
content
=
'<p>Middle content</p>'
,
date
=
datetime
.
datetime
(
2008
,
3
,
18
,
11
,
54
,
58
),
section
=
cls
.
s1
content
=
'<p>Middle content</p>'
,
date
=
datetime
.
datetime
(
2008
,
3
,
18
,
11
,
54
,
58
),
section
=
cls
.
s1
,
another_section
=
cls
.
s1
,
)
cls
.
a2
=
Article
.
objects
.
create
(
content
=
'<p>Oldest content</p>'
,
date
=
datetime
.
datetime
(
2000
,
3
,
18
,
11
,
54
,
58
),
section
=
cls
.
s1
...
...
@@ -3203,7 +3204,7 @@ class AdminActionsTest(TestCase):
self
.
assertIsInstance
(
confirmation
,
TemplateResponse
)
self
.
assertContains
(
confirmation
,
"Are you sure you want to delete the selected subscribers?"
)
self
.
assertContains
(
confirmation
,
"<h2>Summary</h2>"
)
self
.
assertContains
(
confirmation
,
"<li>Subscribers:
3
</li>"
)
self
.
assertContains
(
confirmation
,
"<li>Subscribers:
2
</li>"
)
self
.
assertContains
(
confirmation
,
"<li>External subscribers: 1</li>"
)
self
.
assertContains
(
confirmation
,
ACTION_CHECKBOX_NAME
,
count
=
2
)
self
.
client
.
post
(
reverse
(
'admin:admin_views_subscriber_changelist'
),
delete_confirmation_data
)
...
...
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