mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
feat: create a dedicated endpoint to view logged in users project attributes
This commit is contained in:
parent
eae7e68947
commit
2bacbedeb7
@ -58,6 +58,7 @@ from plane.api.views import (
|
|||||||
ModuleIssueViewSet,
|
ModuleIssueViewSet,
|
||||||
UserLastProjectWithWorkspaceEndpoint,
|
UserLastProjectWithWorkspaceEndpoint,
|
||||||
UserWorkSpaceIssues,
|
UserWorkSpaceIssues,
|
||||||
|
ProjectMemberUserEndpoint,
|
||||||
)
|
)
|
||||||
|
|
||||||
from plane.api.views.project import AddTeamToProjectEndpoint
|
from plane.api.views.project import AddTeamToProjectEndpoint
|
||||||
@ -320,6 +321,12 @@ urlpatterns = [
|
|||||||
ProjectUserViewsEndpoint.as_view(),
|
ProjectUserViewsEndpoint.as_view(),
|
||||||
name="project-view",
|
name="project-view",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"workspaces/<str:slug>/projects/<uuid:project_id>/project-member/me/",
|
||||||
|
ProjectMemberUserEndpoint.as_view(),
|
||||||
|
name="project-view",
|
||||||
|
),
|
||||||
|
# End Projects
|
||||||
# States
|
# States
|
||||||
path(
|
path(
|
||||||
"workspaces/<str:slug>/projects/<uuid:project_id>/states/",
|
"workspaces/<str:slug>/projects/<uuid:project_id>/states/",
|
||||||
|
@ -10,6 +10,7 @@ from .project import (
|
|||||||
AddMemberToProjectEndpoint,
|
AddMemberToProjectEndpoint,
|
||||||
ProjectJoinEndpoint,
|
ProjectJoinEndpoint,
|
||||||
ProjectUserViewsEndpoint,
|
ProjectUserViewsEndpoint,
|
||||||
|
ProjectMemberUserEndpoint,
|
||||||
)
|
)
|
||||||
from .people import (
|
from .people import (
|
||||||
PeopleEndpoint,
|
PeopleEndpoint,
|
||||||
|
@ -625,3 +625,27 @@ class ProjectUserViewsEndpoint(BaseAPIView):
|
|||||||
{"error": "Something went wrong please try again later"},
|
{"error": "Something went wrong please try again later"},
|
||||||
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ProjectMemberUserEndpoint(BaseAPIView):
|
||||||
|
def get(self, request, slug, project_id):
|
||||||
|
try:
|
||||||
|
|
||||||
|
project_member = ProjectMember.objects.get(
|
||||||
|
project=project_id, workpsace__slug=slug, member=request.user
|
||||||
|
)
|
||||||
|
serializer = ProjectMemberSerializer(project_member)
|
||||||
|
|
||||||
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
except ProjectMember.DoesNotExist:
|
||||||
|
return Response(
|
||||||
|
{"error": "User not a member of the project"},
|
||||||
|
status=status.HTTP_404_NOT_FOUND,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
capture_exception(e)
|
||||||
|
return Response(
|
||||||
|
{"error": "Something went wrong please try again later"},
|
||||||
|
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user