-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from hugobessa/dev
Deploy to PyPI
- Loading branch information
Showing
21 changed files
with
378 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,36 @@ | ||
from django.db import models | ||
import django.utils.version | ||
from shared_schema_tenants.settings import DEFAULT_TENANT_SLUG | ||
from shared_schema_tenants.settings import get_setting | ||
from shared_schema_tenants.managers import SingleTenantModelManager, MultipleTenantModelManager | ||
from shared_schema_tenants.models import Tenant | ||
|
||
|
||
def get_default_tenant(): | ||
return Tenant.objects.filter(slug=DEFAULT_TENANT_SLUG).first() | ||
return Tenant.objects.filter(slug=get_setting('DEFAULT_TENANT_SLUG')).first() | ||
|
||
|
||
class SingleTenantModelMixin(models.Model): | ||
tenant = models.ForeignKey('shared_schema_tenants.Tenant', default=get_default_tenant) | ||
|
||
if django.utils.version.get_complete_version()[1] < 10: | ||
objects = models.Manager() | ||
else: | ||
objects = SingleTenantModelManager() | ||
objects = SingleTenantModelManager() | ||
|
||
original_manager = models.Manager() | ||
tenant_objects = SingleTenantModelManager() | ||
|
||
class Meta: | ||
abstract = True | ||
if django.utils.version.get_complete_version()[1] >= 10: | ||
default_manager_name = 'original_manager' | ||
base_manager_name = 'original_manager' | ||
default_manager_name = 'original_manager' | ||
base_manager_name = 'original_manager' | ||
|
||
|
||
class MultipleTenantsModelMixin(models.Model): | ||
tenants = models.ManyToManyField('shared_schema_tenants.Tenant') | ||
|
||
if django.utils.version.get_complete_version()[1] < 10: | ||
objects = models.Manager() | ||
else: | ||
objects = MultipleTenantModelManager() | ||
objects = MultipleTenantModelManager() | ||
|
||
tenant_objects = MultipleTenantModelManager() | ||
original_manager = models.Manager() | ||
|
||
class Meta: | ||
abstract = True | ||
if django.utils.version.get_complete_version()[1] >= 10: | ||
default_manager_name = 'original_manager' | ||
base_manager_name = 'original_manager' | ||
default_manager_name = 'original_manager' | ||
base_manager_name = 'original_manager' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.