Skip to content

Commit

Permalink
feat: patch api
Browse files Browse the repository at this point in the history
  • Loading branch information
sangeethailango committed Jan 3, 2025
1 parent 77a2206 commit 30434b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 6 additions & 0 deletions apiserver/plane/app/urls/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,17 @@
),
name="workspace-quick-links",
),
# Widgets
path(
"workspaces/<str:slug>/home-preferences/",
WorkspacePreferenceViewSet.as_view(),
name="workspace-home-preference",
),
path(
"workspaces/<str:slug>/home-preferences/<uuid:pk>/",
WorkspacePreferenceViewSet.as_view(),
name="workspace-home-preference",
),
path(
"workspaces/<str:slug>/recent-visits/",
UserRecentVisitViewSet.as_view({"get": "list"}),
Expand Down
20 changes: 16 additions & 4 deletions apiserver/plane/app/views/workspace/preference.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def get(self, request, slug):

create_preference_keys = []

print(WorkspaceHomePreference.HomeWidgetKeys.choices, "Print Choices")

keys = [key for key, _ in WorkspaceHomePreference.HomeWidgetKeys.choices]

for preference in keys:
Expand All @@ -46,7 +44,21 @@ def get(self, request, slug):

workspace_user_home_preferences = WorkspaceHomePreference.objects.filter(
workspace=workspace, user=request.user
).values("key", "is_enabled", "sort_order", "config")
).values("key", "is_enabled", "sort_order", "config", "id")

# for preference in home_preferences:
return Response(workspace_user_home_preferences, status=status.HTTP_200_OK)

@allow_permission([ROLE.ADMIN, ROLE.MEMBER, ROLE.GUEST], level="WORKSPACE")
def patch(self, request, slug, pk):
preference = WorkspaceHomePreference.objects.filter(pk=pk, workspace__slug=slug)

if preference:
WorkspaceHomePreference.objects.update(
is_enabled=request.data["is_enabled"]
)

preference = WorkspaceHomePreference.objects.filter(
pk=pk, user=request.user
).values("key", "is_enabled", "sort_order", "config", "id")

return Response(preference, status=status.HTTP_200_OK)

0 comments on commit 30434b4

Please sign in to comment.