From bc457846fe9b4b6b17527ccdc3cb5d82beac1292 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Mon, 10 Apr 2023 23:19:01 +0530 Subject: [PATCH] chore: move theme setting in user level from workspace level --- apiserver/plane/api/urls.py | 6 ------ apiserver/plane/api/views/__init__.py | 1 - apiserver/plane/api/views/workspace.py | 30 -------------------------- apiserver/plane/db/models/user.py | 1 + apiserver/plane/db/models/workspace.py | 3 --- 5 files changed, 1 insertion(+), 40 deletions(-) diff --git a/apiserver/plane/api/urls.py b/apiserver/plane/api/urls.py index 9baf19a54..34554fff5 100644 --- a/apiserver/plane/api/urls.py +++ b/apiserver/plane/api/urls.py @@ -43,7 +43,6 @@ from plane.api.views import ( UserIssueCompletedGraphEndpoint, UserWorkspaceDashboardEndpoint, WorkspaceThemeViewSet, - UserWorkspaceThemeEndpoint, ## End Workspaces # File Assets FileAssetEndpoint, @@ -373,11 +372,6 @@ urlpatterns = [ ), name="workspace-themes", ), - path( - "users/me/workspaces//workspace-themes/", - UserWorkspaceThemeEndpoint.as_view(), - name="user-workspace-themes", - ), ## End Workspaces ## # Projects path( diff --git a/apiserver/plane/api/views/__init__.py b/apiserver/plane/api/views/__init__.py index f12507ea3..82eb49e44 100644 --- a/apiserver/plane/api/views/__init__.py +++ b/apiserver/plane/api/views/__init__.py @@ -41,7 +41,6 @@ from .workspace import ( UserIssueCompletedGraphEndpoint, UserWorkspaceDashboardEndpoint, WorkspaceThemeViewSet, - UserWorkspaceThemeEndpoint, ) from .state import StateViewSet from .shortcut import ShortCutViewSet diff --git a/apiserver/plane/api/views/workspace.py b/apiserver/plane/api/views/workspace.py index 69dd45f1b..915ade2fc 100644 --- a/apiserver/plane/api/views/workspace.py +++ b/apiserver/plane/api/views/workspace.py @@ -786,33 +786,3 @@ class WorkspaceThemeViewSet(BaseViewSet): status=status.HTTP_400_BAD_REQUEST, ) - -class UserWorkspaceThemeEndpoint(BaseAPIView): - def post(self, request, slug): - try: - workspace_theme_id = request.data.get("workspace_theme_id", False) - - if not workspace_theme_id: - return Response( - {"error": "Workspace Theme ID is required"}, - status=status.HTTP_400_BAD_REQUEST, - ) - - workspace_theme = WorkspaceTheme.objects.get( - workspace__slug=slug, pk=workspace_theme_id - ) - - # Update at member level - workspace_member = WorkspaceMember.objects.get( - workspace__slug=slug, member=request.user - ) - workspace_member.workspace_theme = workspace_theme - workspace_member.save() - serializer = WorkSpaceMemberSerializer(workspace_member) - return Response(serializer.data, status=status.HTTP_200_OK) - except Exception as e: - capture_exception(e) - return Response( - {"error": "Something went wrong please try again later"}, - status=status.HTTP_400_BAD_REQUEST, - ) diff --git a/apiserver/plane/db/models/user.py b/apiserver/plane/db/models/user.py index 8a30981f3..334ec3e13 100644 --- a/apiserver/plane/db/models/user.py +++ b/apiserver/plane/db/models/user.py @@ -72,6 +72,7 @@ class User(AbstractBaseUser, PermissionsMixin): my_issues_prop = models.JSONField(null=True) role = models.CharField(max_length=300, null=True, blank=True) is_bot = models.BooleanField(default=False) + theme = models.JSONField(default=dict) USERNAME_FIELD = "email" diff --git a/apiserver/plane/db/models/workspace.py b/apiserver/plane/db/models/workspace.py index 9c3e1eecd..b00d53013 100644 --- a/apiserver/plane/db/models/workspace.py +++ b/apiserver/plane/db/models/workspace.py @@ -48,9 +48,6 @@ class WorkspaceMember(BaseModel): role = models.PositiveSmallIntegerField(choices=ROLE_CHOICES, default=10) company_role = models.TextField(null=True, blank=True) view_props = models.JSONField(null=True, blank=True) - workspace_theme = models.ForeignKey( - "db.WorkspaceTheme", on_delete=models.SET_NULL, related_name="theme", null=True - ) class Meta: unique_together = ["workspace", "member"]