feat(clients): add clients app basic structure and endpoints

This commit is contained in:
2026-03-11 18:43:11 +08:00
parent 5d1e1cb7cb
commit 7b6b288c41
13 changed files with 286 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
from rest_framework import permissions
from apps.workspaces.models import WorkspaceMembership
class IsClientWorkspaceMember(permissions.BasePermission):
"""
Allows access only to users who are active members of the workspace associated with the client.
"""
message = "شما عضو فضای کاری این مشتری نیستید."
def has_object_permission(self, request, view, obj):
"""
Validates if the user exists in the workspace memberships for the requested client's workspace.
"""
if not request.user.is_authenticated:
return False
return WorkspaceMembership.objects.filter(
workspace=obj.workspace,
user=request.user,
is_active=True
).exists()