Simplified emit_post_migrate from flush command

Follow-up of f4f24d30e0.
This commit is contained in:
Claude Paroz 2015-02-28 16:02:20 +01:00
parent 90ab6ee612
commit 23c612199a
2 changed files with 6 additions and 13 deletions

View File

@ -7,7 +7,7 @@ from django.apps import apps
from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
from django.core.management.sql import emit_post_migrate_signal, sql_flush
from django.db import DEFAULT_DB_ALIAS, connections, router, transaction
from django.db import DEFAULT_DB_ALIAS, connections, transaction
from django.utils import six
from django.utils.six.moves import input
@ -76,15 +76,8 @@ Are you sure you want to do this?
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
if not inhibit_post_migrate:
self.emit_post_migrate(verbosity, interactive, database)
# Emit the post migrate signal. This allows individual applications to
# respond as if the database had been migrated from scratch.
emit_post_migrate_signal(verbosity, interactive, database)
else:
self.stdout.write("Flush cancelled.\n")
@staticmethod
def emit_post_migrate(verbosity, interactive, database):
# Emit the post migrate signal. This allows individual applications to
# respond as if the database had been migrated from scratch.
all_models = []
for app_config in apps.get_app_configs():
all_models.extend(router.get_migratable_models(app_config, database, include_auto_created=True))
emit_post_migrate_signal(verbosity, interactive, database)

View File

@ -23,7 +23,7 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.core.handlers.wsgi import WSGIHandler, get_path_info
from django.core.management import call_command
from django.core.management.color import no_style
from django.core.management.commands import flush
from django.core.management.sql import emit_post_migrate_signal
from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer
from django.core.urlresolvers import clear_url_caches, set_urlconf
from django.db import DEFAULT_DB_ALIAS, connection, connections, transaction
@ -777,7 +777,7 @@ class TransactionTestCase(SimpleTestCase):
value=self.available_apps,
enter=True)
for db_name in self._databases_names(include_mirrors=False):
flush.Command.emit_post_migrate(verbosity=0, interactive=False, database=db_name)
emit_post_migrate_signal(verbosity=0, interactive=False, db=db_name)
try:
self._fixture_setup()
except Exception: