From a45fb440207c788aa2d6f1eb6111f190239c953c Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 13 Dec 2022 23:27:59 +0530 Subject: [PATCH] feat: create column and endpoint to store user project issue views --- apiserver/plane/api/views/project.py | 33 ++++++++++++++++++++++++++++ apiserver/plane/db/models/project.py | 1 + 2 files changed, 34 insertions(+) diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index 28878f275..0b3fb1113 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -584,3 +584,36 @@ class ProjectJoinEndpoint(BaseAPIView): {"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) + + +class ProjectUserViewsEndpoint(BaseAPIView): + def post(self, request, slug, project_id): + try: + + project = Project.objects.get(pk=project_id, workspace__slug=slug) + + project_member = ProjectMember.objects.filter( + member=request.user, project=project + ).first() + + if project_member is None: + return Response( + {"error": "Forbidden"}, status=status.HTTP_403_FORBIDDEN + ) + + project_member.view_props = request.data + + project_member.save() + + return Response(status=status.HTTP_200_OK) + + except Project.DoesNotExist: + return Response( + {"error": "The requested resource does not exists"}, + status=status.HTTP_404_NOT_FOUND, + ) + except Exception as e: + return Response( + {"error": "Something went wrong please try again later"}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR, + ) diff --git a/apiserver/plane/db/models/project.py b/apiserver/plane/db/models/project.py index 9e8913dd5..2e253ea1b 100644 --- a/apiserver/plane/db/models/project.py +++ b/apiserver/plane/db/models/project.py @@ -116,6 +116,7 @@ class ProjectMember(ProjectBaseModel): ) comment = models.TextField(blank=True, null=True) role = models.PositiveSmallIntegerField(choices=ROLE_CHOICES, default=10) + view_props = models.JSONField(null=True) class Meta: unique_together = ["project", "member"]