1
0
mirror of https://github.com/django/django.git synced 2025-10-30 17:16:10 +00:00

Migrated built-in AppCommands to use handle_app_config.

This commit is contained in:
Aymeric Augustin
2013-12-27 15:17:56 +01:00
parent bb8ec71f61
commit a7add2f296
9 changed files with 51 additions and 26 deletions

View File

@@ -18,5 +18,9 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
return '\n'.join(sql_create(app, self.style, connections[options.get('database')]))
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
statements = sql_create(app_config.models_module, self.style, connection)
return '\n'.join(statements)

View File

@@ -18,5 +18,9 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
return '\n'.join(sql_all(app, self.style, connections[options.get('database')]))
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
statements = sql_all(app_config.models_module, self.style, connection)
return '\n'.join(statements)

View File

@@ -18,5 +18,9 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
return '\n'.join(sql_delete(app, self.style, connections[options.get('database')]))
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
statements = sql_delete(app_config.models_module, self.style, connection)
return '\n'.join(statements)

View File

@@ -18,5 +18,9 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
return '\n'.join(sql_custom(app, self.style, connections[options.get('database')]))
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
statements = sql_custom(app_config.models_module, self.style, connection)
return '\n'.join(statements)

View File

@@ -19,5 +19,9 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
return '\n'.join(sql_destroy_indexes(app, self.style, connections[options.get('database')]))
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
statements = sql_destroy_indexes(app_config.models_module, self.style, connection)
return '\n'.join(statements)

View File

@@ -19,5 +19,9 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
return '\n'.join(sql_indexes(app, self.style, connections[options.get('database')]))
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
statements = sql_indexes(app_config.models_module, self.style, connection)
return '\n'.join(statements)

View File

@@ -19,6 +19,10 @@ class Command(AppCommand):
output_transaction = True
def handle_app(self, app, **options):
def handle_app_config(self, app_config, **options):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
return '\n'.join(connection.ops.sequence_reset_sql(self.style, apps.get_models(app, include_auto_created=True)))
models = apps.get_models(app_config.models_module, include_auto_created=True)
statements = connection.ops.sequence_reset_sql(self.style, models)
return '\n'.join(statements)