Skip to content

Commit

Permalink
Merge pull request #1478 from makeplane/stage-release
Browse files Browse the repository at this point in the history
promote: stage-release to master
  • Loading branch information
pablohashescobar authored Jul 5, 2023
2 parents 6394f51 + d05d814 commit fd3f6ab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
1 change: 0 additions & 1 deletion apiserver/plane/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@
{
"delete": "destroy",
"get": "retrieve",
"get": "retrieve",
}
),
name="workspace",
Expand Down
45 changes: 37 additions & 8 deletions apiserver/plane/api/views/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
from django.db.models.functions import ExtractWeek, Cast, ExtractDay
from django.db.models.fields import DateField
from django.contrib.auth.hashers import make_password

# Third party modules
from rest_framework import status
Expand Down Expand Up @@ -276,14 +277,18 @@ def post(self, request, slug):

# create the user if signup is disabled
if settings.DOCKERIZED and not settings.ENABLE_SIGNUP:
_ = User.objects.bulk_create([
User(
email=email.get("email"),
password=str(uuid4().hex),
is_password_autoset=True
)
for email in emails
], batch_size=100)
_ = User.objects.bulk_create(
[
User(
username=str(uuid4().hex),
email=invitation.email,
password=make_password(uuid4().hex),
is_password_autoset=True,
)
for invitation in workspace_invitations
],
batch_size=100,
)

for invitation in workspace_invitations:
workspace_invitation.delay(
Expand Down Expand Up @@ -400,6 +405,30 @@ def get_queryset(self):
.select_related("workspace", "workspace__owner", "created_by")
)

def destroy(self, request, slug, pk):
try:
workspace_member_invite = WorkspaceMemberInvite.objects.get(
pk=pk, workspace__slug=slug
)
# delete the user if signup is disabled
if settings.DOCKERIZED and not settings.ENABLE_SIGNUP:
user = User.objects.filter(email=workspace_member_invite.email).first()
if user is not None:
user.delete()
workspace_member_invite.delete()
return Response(status=status.HTTP_204_NO_CONTENT)
except WorkspaceMemberInvite.DoesNotExist:
return Response(
{"error": "Workspace member invite does not exists"},
status=status.HTTP_400_BAD_REQUEST,
)
except Exception as e:
capture_exception(e)
return Response(
{"error": "Something went wrong please try again later"},
status=status.HTTP_400_BAD_REQUEST,
)


class UserWorkspaceInvitationsEndpoint(BaseViewSet):
serializer_class = WorkSpaceMemberInviteSerializer
Expand Down

0 comments on commit fd3f6ab

Please sign in to comment.