Skip to content

Commit

Permalink
chore: track public board comments and reaction users for public depl…
Browse files Browse the repository at this point in the history
…oy boards (#1972)

* chore: track project deploy board comment and reaction users for public deploy boards

* dev: remove tracking from project viewsets
  • Loading branch information
pablohashescobar committed Aug 30, 2023
1 parent 2e5ade0 commit 23f5d5d
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions apiserver/plane/api/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ProjectMemberLiteSerializer,
ProjectDeployBoardSerializer,
ProjectMemberAdminSerializer,
ProjectPublicMemberSerializer
)
from .state import StateSerializer, StateLiteSerializer
from .view import IssueViewSerializer, IssueViewFavoriteSerializer
Expand Down
15 changes: 14 additions & 1 deletion apiserver/plane/api/serializers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ProjectIdentifier,
ProjectFavorite,
ProjectDeployBoard,
ProjectPublicMember,
)


Expand Down Expand Up @@ -177,5 +178,17 @@ class Meta:
fields = "__all__"
read_only_fields = [
"workspace",
"project" "anchor",
"project", "anchor",
]


class ProjectPublicMemberSerializer(BaseSerializer):

class Meta:
model = ProjectPublicMember
fields = "__all__"
read_only_fields = [
"workspace",
"project",
"member",
]
39 changes: 38 additions & 1 deletion apiserver/plane/api/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
CommentReaction,
ProjectDeployBoard,
IssueVote,
ProjectPublicMember,
)
from plane.bgtasks.issue_activites_task import issue_activity
from plane.utils.grouper import group_results
Expand Down Expand Up @@ -1545,6 +1546,16 @@ def create(self, request, slug, project_id, issue_id):
project_id=str(project_id),
current_instance=None,
)
if not ProjectMember.objects.filter(
project_id=project_id,
member=request.user,
).exists():
# Add the user for workspace tracking
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
member=request.user,
)

return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except Exception as e:
Expand Down Expand Up @@ -1671,6 +1682,15 @@ def create(self, request, slug, project_id, issue_id):
serializer.save(
project_id=project_id, issue_id=issue_id, actor=request.user
)
if not ProjectMember.objects.filter(
project_id=project_id,
member=request.user,
).exists():
# Add the user for workspace tracking
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
member=request.user,
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except ProjectDeployBoard.DoesNotExist:
Expand Down Expand Up @@ -1756,6 +1776,14 @@ def create(self, request, slug, project_id, comment_id):
serializer.save(
project_id=project_id, comment_id=comment_id, actor=request.user
)
if not ProjectMember.objects.filter(
project_id=project_id, member=request.user
).exists():
# Add the user for workspace tracking
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
member=request.user,
)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
except ProjectDeployBoard.DoesNotExist:
Expand Down Expand Up @@ -1823,6 +1851,14 @@ def create(self, request, slug, project_id, issue_id):
project_id=project_id,
issue_id=issue_id,
)
# Add the user for workspace tracking
if not ProjectMember.objects.filter(
project_id=project_id, member=request.user
).exists():
_ = ProjectPublicMember.objects.get_or_create(
project_id=project_id,
member=request.user,
)
issue_vote.vote = request.data.get("vote", 1)
issue_vote.save()
serializer = IssueVoteSerializer(issue_vote)
Expand Down Expand Up @@ -2021,4 +2057,5 @@ def get(self, request, slug, project_id):
return Response(
{"error": "Something went wrong please try again later"},
status=status.HTTP_400_BAD_REQUEST,
)
)

1 change: 1 addition & 0 deletions apiserver/plane/db/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
ProjectIdentifier,
ProjectFavorite,
ProjectDeployBoard,
ProjectPublicMember,
)

from .issue import (
Expand Down
15 changes: 15 additions & 0 deletions apiserver/plane/db/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,18 @@ class Meta:
def __str__(self):
"""Return project and anchor"""
return f"{self.anchor} <{self.project.name}>"


class ProjectPublicMember(ProjectBaseModel):
member = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.CASCADE,
related_name="public_project_members",
)

class Meta:
unique_together = ["project", "member"]
verbose_name = "Project Public Member"
verbose_name_plural = "Project Public Members"
db_table = "project_public_members"
ordering = ("-created_at",)

1 comment on commit 23f5d5d

@vercel
Copy link

@vercel vercel bot commented on 23f5d5d Aug 30, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

plane-dev – ./apps/app

plane-dev-plane.vercel.app
plane-dev.vercel.app
plane-dev-git-develop-plane.vercel.app

Please sign in to comment.