From 43b88010cc6e3f2276ca4ffa165824b822381a84 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Wed, 13 Dec 2023 12:33:13 +0530 Subject: [PATCH 1/2] chore: user can rejoin a project by invite --- apiserver/plane/app/views/project.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apiserver/plane/app/views/project.py b/apiserver/plane/app/views/project.py index c67575db5ff..fe9c9e00eda 100644 --- a/apiserver/plane/app/views/project.py +++ b/apiserver/plane/app/views/project.py @@ -679,6 +679,25 @@ def create(self, request, slug, project_id): ) ) + # Check if the user is already a member of the project and is inactive + if ProjectMember.objects.filter( + workspace__slug=slug, + project_id=project_id, + member_id=member.get("member_id"), + is_active=False, + ).exists(): + member_detail = ProjectMember.objects.get( + workspace__slug=slug, + project_id=project_id, + member_id=member.get("member_id"), + is_active=False, + ) + # Check if the user has not deactivated the account + user = User.objects.filter(pk=member.get("member_id")).first() + if user.is_active: + member_detail.is_active = True + member_detail.save(update_fields=["is_active"]) + project_members = ProjectMember.objects.bulk_create( bulk_project_members, batch_size=10, From 8109d7d726202662d2d690f169babc8217dcbd91 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Wed, 13 Dec 2023 15:40:39 +0530 Subject: [PATCH 2/2] chore: workspace member leave --- apiserver/plane/app/views/workspace.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apiserver/plane/app/views/workspace.py b/apiserver/plane/app/views/workspace.py index ed72dbcf118..11170114aaa 100644 --- a/apiserver/plane/app/views/workspace.py +++ b/apiserver/plane/app/views/workspace.py @@ -70,6 +70,7 @@ WorkSpaceAdminPermission, WorkspaceEntityPermission, WorkspaceViewerPermission, + WorkspaceUserPermission, ) from plane.bgtasks.workspace_invitation_task import workspace_invitation from plane.utils.issue_filters import issue_filters @@ -495,6 +496,18 @@ class WorkSpaceMemberViewSet(BaseViewSet): WorkspaceEntityPermission, ] + def get_permissions(self): + if self.action == "leave": + self.permission_classes = [ + WorkspaceUserPermission, + ] + else: + self.permission_classes = [ + WorkspaceEntityPermission, + ] + + return super(WorkSpaceMemberViewSet, self).get_permissions() + search_fields = [ "member__display_name", "member__first_name",