forked from github/plane
chore: move theme setting in user level from workspace level
This commit is contained in:
parent
b6c911f484
commit
bc457846fe
@ -43,7 +43,6 @@ from plane.api.views import (
|
|||||||
UserIssueCompletedGraphEndpoint,
|
UserIssueCompletedGraphEndpoint,
|
||||||
UserWorkspaceDashboardEndpoint,
|
UserWorkspaceDashboardEndpoint,
|
||||||
WorkspaceThemeViewSet,
|
WorkspaceThemeViewSet,
|
||||||
UserWorkspaceThemeEndpoint,
|
|
||||||
## End Workspaces
|
## End Workspaces
|
||||||
# File Assets
|
# File Assets
|
||||||
FileAssetEndpoint,
|
FileAssetEndpoint,
|
||||||
@ -373,11 +372,6 @@ urlpatterns = [
|
|||||||
),
|
),
|
||||||
name="workspace-themes",
|
name="workspace-themes",
|
||||||
),
|
),
|
||||||
path(
|
|
||||||
"users/me/workspaces/<str:slug>/workspace-themes/",
|
|
||||||
UserWorkspaceThemeEndpoint.as_view(),
|
|
||||||
name="user-workspace-themes",
|
|
||||||
),
|
|
||||||
## End Workspaces ##
|
## End Workspaces ##
|
||||||
# Projects
|
# Projects
|
||||||
path(
|
path(
|
||||||
|
@ -41,7 +41,6 @@ from .workspace import (
|
|||||||
UserIssueCompletedGraphEndpoint,
|
UserIssueCompletedGraphEndpoint,
|
||||||
UserWorkspaceDashboardEndpoint,
|
UserWorkspaceDashboardEndpoint,
|
||||||
WorkspaceThemeViewSet,
|
WorkspaceThemeViewSet,
|
||||||
UserWorkspaceThemeEndpoint,
|
|
||||||
)
|
)
|
||||||
from .state import StateViewSet
|
from .state import StateViewSet
|
||||||
from .shortcut import ShortCutViewSet
|
from .shortcut import ShortCutViewSet
|
||||||
|
@ -786,33 +786,3 @@ class WorkspaceThemeViewSet(BaseViewSet):
|
|||||||
status=status.HTTP_400_BAD_REQUEST,
|
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,
|
|
||||||
)
|
|
||||||
|
@ -72,6 +72,7 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||||||
my_issues_prop = models.JSONField(null=True)
|
my_issues_prop = models.JSONField(null=True)
|
||||||
role = models.CharField(max_length=300, null=True, blank=True)
|
role = models.CharField(max_length=300, null=True, blank=True)
|
||||||
is_bot = models.BooleanField(default=False)
|
is_bot = models.BooleanField(default=False)
|
||||||
|
theme = models.JSONField(default=dict)
|
||||||
|
|
||||||
USERNAME_FIELD = "email"
|
USERNAME_FIELD = "email"
|
||||||
|
|
||||||
|
@ -48,9 +48,6 @@ class WorkspaceMember(BaseModel):
|
|||||||
role = models.PositiveSmallIntegerField(choices=ROLE_CHOICES, default=10)
|
role = models.PositiveSmallIntegerField(choices=ROLE_CHOICES, default=10)
|
||||||
company_role = models.TextField(null=True, blank=True)
|
company_role = models.TextField(null=True, blank=True)
|
||||||
view_props = models.JSONField(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:
|
class Meta:
|
||||||
unique_together = ["workspace", "member"]
|
unique_together = ["workspace", "member"]
|
||||||
|
Loading…
Reference in New Issue
Block a user