Projet

Général

Profil

0001-Add-command-list_tenants-fixes-5044.patch

Benjamin Dauvergne, 28 août 2014 12:11

Télécharger (1,4 ko)

Voir les différences:

Subject: [PATCH] Add command list_tenants (fixes #5044)

 .../multitenant/management/commands/list_tenants.py |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 entrouvert/djommon/multitenant/management/commands/list_tenants.py
entrouvert/djommon/multitenant/management/commands/list_tenants.py
1
from django.core.management.base import BaseCommand, CommandError
2
from entrouvert.djommon.multitenant.middleware import TenantMiddleware
3
from django.conf import settings
4

  
5
class Command(BaseCommand):
6
    requires_model_validation = True
7
    can_import_settings = True
8
    option_list = BaseCommand.option_list
9

  
10
    def handle(self, **options):
11
        all_tenants = TenantMiddleware.get_tenants()
12

  
13
        if not all_tenants:
14
            raise CommandError("""There are no tenants in the system. \
15
Please create some in %r""" % getattr(settings, 'TENANT_BASE'))
16

  
17
        for tenant in all_tenants:
18
            print("{0}: {1}".format(tenant.schema_name, tenant.domain_url))
19

  
0
-