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
d562527a
Kaydet (Commit)
d562527a
authored
Ock 12, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #21477 -- Renamed db to using in pre/post_migrate signals.
üst
d674fe6d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
20 deletions
+20
-20
__init__.py
django/contrib/auth/management/__init__.py
+7
-7
management.py
django/contrib/contenttypes/management.py
+4
-4
sql.py
django/core/management/sql.py
+2
-2
signals.py
django/db/models/signals.py
+2
-2
signals.txt
docs/ref/signals.txt
+2
-2
tests.py
tests/migrate_signals/tests.py
+3
-3
No files found.
django/contrib/auth/management/__init__.py
Dosyayı görüntüle @
d562527a
...
...
@@ -60,7 +60,7 @@ def _check_permission_clashing(custom, builtin, ctype):
pool
.
add
(
codename
)
def
create_permissions
(
app_config
,
verbosity
=
2
,
interactive
=
True
,
db
=
DEFAULT_DB_ALIAS
,
**
kwargs
):
def
create_permissions
(
app_config
,
verbosity
=
2
,
interactive
=
True
,
using
=
DEFAULT_DB_ALIAS
,
**
kwargs
):
if
not
app_config
.
models_module
:
return
...
...
@@ -69,7 +69,7 @@ def create_permissions(app_config, verbosity=2, interactive=True, db=DEFAULT_DB_
except
LookupError
:
return
if
not
router
.
allow_migrate
(
db
,
Permission
):
if
not
router
.
allow_migrate
(
using
,
Permission
):
return
from
django.contrib.contenttypes.models
import
ContentType
...
...
@@ -82,7 +82,7 @@ def create_permissions(app_config, verbosity=2, interactive=True, db=DEFAULT_DB_
for
klass
in
app_config
.
get_models
():
# Force looking up the content types in the current database
# before creating foreign keys to them.
ctype
=
ContentType
.
objects
.
db_manager
(
db
)
.
get_for_model
(
klass
)
ctype
=
ContentType
.
objects
.
db_manager
(
using
)
.
get_for_model
(
klass
)
ctypes
.
add
(
ctype
)
for
perm
in
_get_all_permissions
(
klass
.
_meta
,
ctype
):
searched_perms
.
append
((
ctype
,
perm
))
...
...
@@ -90,7 +90,7 @@ def create_permissions(app_config, verbosity=2, interactive=True, db=DEFAULT_DB_
# Find all the Permissions that have a content_type for a model we're
# looking for. We don't need to check for codenames since we already have
# a list of the ones we're going to create.
all_perms
=
set
(
Permission
.
objects
.
using
(
db
)
.
filter
(
all_perms
=
set
(
Permission
.
objects
.
using
(
using
)
.
filter
(
content_type__in
=
ctypes
,
)
.
values_list
(
"content_type"
,
"codename"
...
...
@@ -113,13 +113,13 @@ def create_permissions(app_config, verbosity=2, interactive=True, db=DEFAULT_DB_
verbose_name_max_length
,
)
)
Permission
.
objects
.
using
(
db
)
.
bulk_create
(
perms
)
Permission
.
objects
.
using
(
using
)
.
bulk_create
(
perms
)
if
verbosity
>=
2
:
for
perm
in
perms
:
print
(
"Adding permission '
%
s'"
%
perm
)
def
create_superuser
(
app_config
,
verbosity
=
2
,
interactive
=
True
,
db
=
DEFAULT_DB_ALIAS
,
**
kwargs
):
def
create_superuser
(
app_config
,
verbosity
=
2
,
interactive
=
True
,
using
=
DEFAULT_DB_ALIAS
,
**
kwargs
):
try
:
apps
.
get_model
(
'auth'
,
'Permission'
)
except
LookupError
:
...
...
@@ -139,7 +139,7 @@ def create_superuser(app_config, verbosity=2, interactive=True, db=DEFAULT_DB_AL
confirm
=
input
(
'Please enter either "yes" or "no": '
)
continue
if
confirm
==
'yes'
:
call_command
(
"createsuperuser"
,
interactive
=
True
,
database
=
db
)
call_command
(
"createsuperuser"
,
interactive
=
True
,
database
=
using
)
break
...
...
django/contrib/contenttypes/management.py
Dosyayı görüntüle @
d562527a
...
...
@@ -6,7 +6,7 @@ from django.utils import six
from
django.utils.six.moves
import
input
def
update_contenttypes
(
app_config
,
verbosity
=
2
,
interactive
=
True
,
db
=
DEFAULT_DB_ALIAS
,
**
kwargs
):
def
update_contenttypes
(
app_config
,
verbosity
=
2
,
interactive
=
True
,
using
=
DEFAULT_DB_ALIAS
,
**
kwargs
):
"""
Creates content types for models in the given app, removing any model
entries that no longer have a matching model class.
...
...
@@ -19,7 +19,7 @@ def update_contenttypes(app_config, verbosity=2, interactive=True, db=DEFAULT_DB
except
LookupError
:
return
if
not
router
.
allow_migrate
(
db
,
ContentType
):
if
not
router
.
allow_migrate
(
using
,
ContentType
):
return
ContentType
.
objects
.
clear_cache
()
...
...
@@ -36,7 +36,7 @@ def update_contenttypes(app_config, verbosity=2, interactive=True, db=DEFAULT_DB
# Get all the content types
content_types
=
dict
(
(
ct
.
model
,
ct
)
for
ct
in
ContentType
.
objects
.
using
(
db
)
.
filter
(
app_label
=
app_label
)
for
ct
in
ContentType
.
objects
.
using
(
using
)
.
filter
(
app_label
=
app_label
)
)
to_remove
=
[
ct
...
...
@@ -53,7 +53,7 @@ def update_contenttypes(app_config, verbosity=2, interactive=True, db=DEFAULT_DB
for
(
model_name
,
model
)
in
six
.
iteritems
(
app_models
)
if
model_name
not
in
content_types
]
ContentType
.
objects
.
using
(
db
)
.
bulk_create
(
cts
)
ContentType
.
objects
.
using
(
using
)
.
bulk_create
(
cts
)
if
verbosity
>=
2
:
for
ct
in
cts
:
print
(
"Adding content type '
%
s |
%
s'"
%
(
ct
.
app_label
,
ct
.
model
))
...
...
django/core/management/sql.py
Dosyayı görüntüle @
d562527a
...
...
@@ -217,7 +217,7 @@ def emit_pre_migrate_signal(create_models, verbosity, interactive, db):
app_config
=
app_config
,
verbosity
=
verbosity
,
interactive
=
interactive
,
db
=
db
)
using
=
db
)
# For backwards-compatibility -- remove in Django 1.9.
models
.
signals
.
pre_syncdb
.
send
(
sender
=
app_config
.
models_module
,
...
...
@@ -240,7 +240,7 @@ def emit_post_migrate_signal(created_models, verbosity, interactive, db):
app_config
=
app_config
,
verbosity
=
verbosity
,
interactive
=
interactive
,
db
=
db
)
using
=
db
)
# For backwards-compatibility -- remove in Django 1.9.
models
.
signals
.
post_syncdb
.
send
(
sender
=
app_config
.
models_module
,
...
...
django/db/models/signals.py
Dosyayı görüntüle @
d562527a
...
...
@@ -62,8 +62,8 @@ post_delete = ModelSignal(providing_args=["instance", "using"], use_caching=True
m2m_changed
=
ModelSignal
(
providing_args
=
[
"action"
,
"instance"
,
"reverse"
,
"model"
,
"pk_set"
,
"using"
],
use_caching
=
True
)
pre_migrate
=
Signal
(
providing_args
=
[
"app_config"
,
"verbosity"
,
"interactive"
,
"
db
"
])
post_migrate
=
Signal
(
providing_args
=
[
"app_config"
,
"verbosity"
,
"interactive"
,
"
db
"
])
pre_migrate
=
Signal
(
providing_args
=
[
"app_config"
,
"verbosity"
,
"interactive"
,
"
using
"
])
post_migrate
=
Signal
(
providing_args
=
[
"app_config"
,
"verbosity"
,
"interactive"
,
"
using
"
])
pre_syncdb
=
Signal
(
providing_args
=
[
"app"
,
"create_models"
,
"verbosity"
,
"interactive"
,
"db"
])
post_syncdb
=
Signal
(
providing_args
=
[
"class"
,
"app"
,
"created_models"
,
"verbosity"
,
"interactive"
,
"db"
])
docs/ref/signals.txt
Dosyayı görüntüle @
d562527a
...
...
@@ -408,7 +408,7 @@ Arguments sent with this signal:
For example, the :mod:`django.contrib.auth` app only prompts to create a
superuser when ``interactive`` is ``True``.
``
db
``
``
using
``
The alias of database on which a command will operate.
pre_syncdb
...
...
@@ -459,7 +459,7 @@ Arguments sent with this signal:
For example, the :mod:`django.contrib.auth` app only prompts to create a
superuser when ``interactive`` is ``True``.
``
db
``
``
using
``
The alias of database on which a command will operate.
post_migrate
...
...
tests/migrate_signals/tests.py
Dosyayı görüntüle @
d562527a
...
...
@@ -6,7 +6,7 @@ from django.utils import six
APP_CONFIG
=
apps
.
get_app_config
(
'migrate_signals'
)
PRE_MIGRATE_ARGS
=
[
'app_config'
,
'verbosity'
,
'interactive'
,
'
db
'
]
PRE_MIGRATE_ARGS
=
[
'app_config'
,
'verbosity'
,
'interactive'
,
'
using
'
]
MIGRATE_DATABASE
=
'default'
MIGRATE_VERBOSITY
=
1
MIGRATE_INTERACTIVE
=
False
...
...
@@ -35,7 +35,7 @@ class OneTimeReceiver(object):
def
__call__
(
self
,
signal
,
sender
,
**
kwargs
):
# Although test runner calls migrate for several databases,
# testing for only one of them is quite sufficient.
if
kwargs
[
'
db
'
]
==
MIGRATE_DATABASE
:
if
kwargs
[
'
using
'
]
==
MIGRATE_DATABASE
:
self
.
call_counter
=
self
.
call_counter
+
1
self
.
call_args
=
kwargs
# we need to test only one call of migrate
...
...
@@ -74,4 +74,4 @@ class MigrateSignalTests(TestCase):
self
.
assertEqual
(
args
[
'app_config'
],
APP_CONFIG
)
self
.
assertEqual
(
args
[
'verbosity'
],
MIGRATE_VERBOSITY
)
self
.
assertEqual
(
args
[
'interactive'
],
MIGRATE_INTERACTIVE
)
self
.
assertEqual
(
args
[
'
db
'
],
'default'
)
self
.
assertEqual
(
args
[
'
using
'
],
'default'
)
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