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
fa3cf006
Kaydet (Commit)
fa3cf006
authored
Tem 23, 2014
tarafından
Nick Sandford
Kaydeden (comit)
Tim Graham
Tem 23, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23078 -- Regression in update_contenttypes() interactivity.
Thanks raymond at adaptiv.nl for the report.
üst
8c30df15
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
AUTHORS
AUTHORS
+1
-0
management.py
django/contrib/contenttypes/management.py
+1
-1
tests.py
tests/contenttypes_tests/tests.py
+38
-0
No files found.
AUTHORS
Dosyayı görüntüle @
fa3cf006
...
...
@@ -541,6 +541,7 @@ answer newbie questions, and generally made Django that much better:
Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
Vinay Sajip <vinay_sajip@yahoo.co.uk>
Bartolome Sanchez Salado <i42sasab@uco.es>
Nick Sandford <nick.sandford@gmail.com>
Mark Sandstrom <mark@deliciouslynerdy.com>
Kadesarin Sanjek
Tim Saylor <tim.saylor@gmail.com>
...
...
django/contrib/contenttypes/management.py
Dosyayı görüntüle @
fa3cf006
...
...
@@ -60,7 +60,7 @@ def update_contenttypes(app_config, verbosity=2, interactive=True, using=DEFAULT
# Confirm that the content type is stale before deletion.
if
to_remove
:
if
kwargs
.
get
(
'interactive'
,
False
)
:
if
interactive
:
content_type_display
=
'
\n
'
.
join
(
'
%
s |
%
s'
%
(
ct
.
app_label
,
ct
.
model
)
for
ct
in
to_remove
...
...
tests/contenttypes_tests/tests.py
Dosyayı görüntüle @
fa3cf006
# -*- coding: utf-8 -*-
from
__future__
import
absolute_import
,
unicode_literals
import
sys
from
django.apps.registry
import
Apps
,
apps
from
django.contrib.contenttypes.fields
import
(
GenericForeignKey
,
GenericRelation
)
from
django.contrib.contenttypes
import
management
from
django.contrib.contenttypes.models
import
ContentType
from
django.core
import
checks
from
django.db
import
connections
,
models
,
router
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.utils.encoding
import
force_str
from
django.utils.six
import
StringIO
from
.models
import
Author
,
Article
,
SchemeIncludedURL
...
...
@@ -358,6 +362,40 @@ class GenericRelationshipTests(IsolatedModelsTestCase):
self
.
assertEqual
(
errors
,
expected
)
class
UpdateContentTypesTests
(
TestCase
):
def
setUp
(
self
):
self
.
before_count
=
ContentType
.
objects
.
count
()
ContentType
.
objects
.
create
(
name
=
'fake'
,
app_label
=
'contenttypes_tests'
,
model
=
'Fake'
)
self
.
app_config
=
apps
.
get_app_config
(
'contenttypes_tests'
)
def
test_interactive_true
(
self
):
"""
interactive mode of update_contenttypes() (the default) should delete
stale contenttypes.
"""
self
.
old_stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
management
.
input
=
lambda
x
:
force_str
(
"yes"
)
management
.
update_contenttypes
(
self
.
app_config
)
output
=
sys
.
stdout
.
getvalue
()
sys
.
stdout
=
self
.
old_stdout
self
.
assertIn
(
"Deleting stale content type"
,
output
)
self
.
assertEqual
(
ContentType
.
objects
.
count
(),
self
.
before_count
)
def
test_interactive_false
(
self
):
"""
non-interactive mode of update_contenttypes() shouldn't delete stale
content types.
"""
self
.
old_stdout
=
sys
.
stdout
sys
.
stdout
=
StringIO
()
management
.
update_contenttypes
(
self
.
app_config
,
interactive
=
False
)
output
=
sys
.
stdout
.
getvalue
()
sys
.
stdout
=
self
.
old_stdout
self
.
assertIn
(
"Stale content types remain."
,
output
)
self
.
assertEqual
(
ContentType
.
objects
.
count
(),
self
.
before_count
+
1
)
class
TestRouter
(
object
):
def
db_for_read
(
self
,
model
,
**
hints
):
return
'other'
...
...
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