|
1 |
# -*- coding: utf-8 -*-
|
1 |
2 |
# this file derive from django-tenant-schemas
|
2 |
3 |
# Author: Bernardo Pires Carneiro
|
3 |
4 |
# Email: carneiro.be@gmail.com
|
4 |
5 |
# License: MIT license
|
5 |
6 |
# Home-page: http://github.com/bcarneiro/django-tenant-schemas
|
|
7 |
|
6 |
8 |
import argparse
|
|
9 |
|
|
10 |
from django.conf import settings
|
7 |
11 |
from django.core.management.base import BaseCommand, CommandError
|
8 |
12 |
from django.core.management import call_command, get_commands, load_command_class
|
9 |
13 |
from django.db import connection
|
... | ... | |
40 |
44 |
args_parser.add_argument("--all-tenants", help="apply command to all tenants",
|
41 |
45 |
action='store_true')
|
42 |
46 |
args_parser.add_argument("-d", "--domain", dest="domain_name", help="specify tenant domain name")
|
|
47 |
args_parser.add_argument(
|
|
48 |
'--force-job', dest='force_job', action='store_true',
|
|
49 |
help='Run command even if DISABLE_CRON_JOBS is set')
|
|
50 |
args_parser.add_argument(
|
|
51 |
'-v', '--verbosity', action='store', dest='verbosity', default=1,
|
|
52 |
type=int, choices=[0, 1, 2, 3],
|
|
53 |
help='Verbosity level; 0=minimal output, 1=normal output, '
|
|
54 |
'2=verbose output, 3=very verbose output',
|
|
55 |
)
|
43 |
56 |
args_namespace, args = args_parser.parse_known_args(argv)
|
44 |
57 |
|
|
58 |
if (args_namespace.all_tenants and not args_namespace.force_job and
|
|
59 |
getattr(settings, 'DISABLE_CRON_JOBS', False)):
|
|
60 |
if args_namespace.verbosity > 1:
|
|
61 |
print('Command %s is ignored because DISABLE_CRON_JOBS is set'
|
|
62 |
% app_name)
|
|
63 |
return
|
|
64 |
|
45 |
65 |
if args_namespace.all_tenants:
|
46 |
66 |
for tenant in TenantMiddleware.get_tenants():
|
47 |
67 |
connection.set_tenant(tenant)
|
48 |
|
-
|