Skip to content

Commit

Permalink
Add short documentation for multi tenancy manager
Browse files Browse the repository at this point in the history
  • Loading branch information
wojcikmat committed Feb 14, 2024
1 parent 83dfdfb commit 8209779
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/backend/apps/multitenancy/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@

class TenantManager(models.Manager):
def get_or_create_user_sign_up_tenant(self, user):
"""
Description:
Retrieves or creates a tenant for a given user to ensure there is always at least one tenant associated with the user.
Parameters:
- user (User): The user for whom the tenant is retrieved or created.
Returns:
Tenant: The associated or newly created tenant instance of SIGN_UP type.
"""
sign_up_tenant = self.filter(creator=user, type=TenantType.SIGN_UP).order_by('created').first()
if sign_up_tenant:
return sign_up_tenant, False
Expand Down

0 comments on commit 8209779

Please sign in to comment.