Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions greyhound/core/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def bulk_create(self, objs, batch_size=None, ignore_conflicts=False):

super().bulk_create(objs, batch_size, ignore_conflicts)

def as_manager(cls):
manager = TenantAwareManager.from_queryset(cls)()
def as_manager(self):
manager = TenantAwareManager.from_queryset(self)()
Comment on lines -29 to +30
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TenantAwareQuerySet.as_manager refactored with the following changes:

manager._built_with_as_manager = True
return manager

Expand Down
10 changes: 6 additions & 4 deletions greyhound/core/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ def split_tenant(path):
if (match := re.search(r'/(.*?)(/.*)', path)):
return match.groups()
elif (match := re.search(r'/(.*)', path)):
if (tenant := match.group(1)):
if tenant := match[1]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function split_tenant refactored with the following changes:

return tenant, ''
raise NoTenant(f'No tenant in {path}')


def tenant_exempt(tenant_name):
if not hasattr(settings, 'TENANTS_EXEMPT'):
return False
return tenant_name in settings.TENANTS_EXEMPT
return (
tenant_name in settings.TENANTS_EXEMPT
if hasattr(settings, 'TENANTS_EXEMPT')
else False
)
Comment on lines -25 to +29
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function tenant_exempt refactored with the following changes:



def current_tenant():
Expand Down
4 changes: 1 addition & 3 deletions indexOutOfBound/core/dbrouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ def allow_relation(self, obj1, obj2, **hints):

def allow_migrate(self, db, app_label, model_name=None, **hints):
# Just migrate tenant model on default db
if model_name == 'tenant' and db != 'default':
return False
return None
return False if model_name == 'tenant' and db != 'default' else None
3 changes: 1 addition & 2 deletions pycore/tenants/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def __init__(self, get_response):
def __call__(self, request):
db = tenant_db_from_request(request)
setattr(THREAD_LOCAL, "DB", db)
response = self.get_response(request)
return response
return self.get_response(request)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TenantMiddleware.__call__ refactored with the following changes:



def get_current_db_name():
Expand Down
1 change: 0 additions & 1 deletion update_sem_where/update_sem_where/core/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
@pytest.mark.django_db
def test_ok():
baker.make('core.User')
assert True
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_ok refactored with the following changes: