Révision 1f642209
Ajouté par Thomas Noël il y a plus de 9 ans
entrouvert/djommon/multitenant/management/commands/sync_schemas.py | ||
---|---|---|
3 | 3 |
# Email: carneiro.be@gmail.com |
4 | 4 |
# License: MIT license |
5 | 5 |
# Home-page: http://github.com/bcarneiro/django-tenant-schemas |
6 |
from django.conf import settings |
|
7 |
from django.contrib.contenttypes.models import ContentType |
|
8 |
from django.db.models import get_apps, get_models |
|
9 |
if "south" in settings.INSTALLED_APPS: |
|
10 |
from south.management.commands.syncdb import Command as SyncdbCommand |
|
11 |
else: |
|
12 |
from django.core.management.commands.syncdb import Command as SyncdbCommand |
|
13 |
from django.db import connection |
|
14 |
from entrouvert.djommon.multitenant.middleware import TenantMiddleware |
|
6 |
import django |
|
7 |
|
|
8 |
if django.VERSION < (1, 7, 0): |
|
9 |
from django.conf import settings |
|
10 |
from django.contrib.contenttypes.models import ContentType |
|
11 |
from django.db.models import get_apps, get_models |
|
12 |
if "south" in settings.INSTALLED_APPS: |
|
13 |
from south.management.commands.syncdb import Command as SyncdbCommand |
|
14 |
else: |
|
15 |
from django.core.management.commands.syncdb import Command as SyncdbCommand |
|
16 |
from django.db import connection |
|
17 |
from entrouvert.djommon.multitenant.middleware import TenantMiddleware |
|
15 | 18 |
from entrouvert.djommon.multitenant.management.commands import SyncCommon |
16 | 19 |
|
17 | 20 |
|
18 |
class Command(SyncCommon): |
|
21 |
class SyncSchemasCommand(SyncCommon):
|
|
19 | 22 |
help = "Sync schemas based on TENANT_APPS and SHARED_APPS settings" |
20 | 23 |
option_list = SyncdbCommand.option_list + SyncCommon.option_list |
21 | 24 |
|
... | ... | |
78 | 81 |
apps = self.shared_apps or self.installed_apps |
79 | 82 |
self._set_managed_apps(apps) |
80 | 83 |
SyncdbCommand().execute(**self.options) |
84 |
|
|
85 |
if django.VERSION < (1, 7, 0): |
|
86 |
Command = SyncSchemasCommand |
|
87 |
else: |
|
88 |
raise RuntimeError('Django 1.7: use migrate_schemas') |
|
89 |
|
Formats disponibles : Unified diff
migrate_schemas: use django 1.7 if available (#6388)