mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: migrations and visiblity of views
This commit is contained in:
parent
5d9393cfa6
commit
ffdd515cf8
@ -119,6 +119,15 @@ urlpatterns = [
|
||||
),
|
||||
name="user-workspace-views",
|
||||
),
|
||||
path(
|
||||
"users/me/workspaces/<str:slug>/views/<uuid:pk>/duplicate/",
|
||||
UserWorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"post": "duplicate",
|
||||
}
|
||||
),
|
||||
name="user-workspace-views",
|
||||
),
|
||||
path(
|
||||
"users/me/workspaces/<str:slug>/views/<uuid:pk>/lock/",
|
||||
UserWorkspaceViewViewSet.as_view(
|
||||
@ -149,5 +158,23 @@ urlpatterns = [
|
||||
),
|
||||
name="user-project-views",
|
||||
),
|
||||
path(
|
||||
"users/me/workspaces/<str:slug>/projects/<uuid:project_id>/views/<uuid:pk>/lock/",
|
||||
UserProjectViewViewSet.as_view(
|
||||
{
|
||||
"post": "toggle_lock",
|
||||
}
|
||||
),
|
||||
name="user-project-lock-views",
|
||||
),
|
||||
path(
|
||||
"users/me/workspaces/<str:slug>/projects/<uuid:project_id>/views/<uuid:pk>/duplicate/",
|
||||
UserWorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"post": "duplicate",
|
||||
}
|
||||
),
|
||||
name="user-project-duplicate-views",
|
||||
),
|
||||
|
||||
]
|
||||
|
@ -10,6 +10,65 @@ from plane.app.views import (
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path(
|
||||
"workspaces/<str:slug>/issues/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"get": "list",
|
||||
}
|
||||
),
|
||||
name="workspace-view-issues",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"get": "list",
|
||||
"post": "create",
|
||||
}
|
||||
),
|
||||
name="workspace-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/<uuid:pk>/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"get": "retrieve",
|
||||
"patch": "partial_update",
|
||||
"delete": "destroy",
|
||||
}
|
||||
),
|
||||
name="workspace-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/<uuid:view_id>/duplicate/",
|
||||
WorkspaceViewFavoriteViewSet.as_view(
|
||||
{
|
||||
"post": "duplicate",
|
||||
}
|
||||
),
|
||||
name="workspace-duplicate-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/<uuid:view_id>/favorite/",
|
||||
WorkspaceViewFavoriteViewSet.as_view(
|
||||
{
|
||||
"get": "list",
|
||||
"post": "create",
|
||||
"delete": "destroy",
|
||||
}
|
||||
),
|
||||
name="workspace-favorite-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/<uuid:pk>/visibility/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"post": "visibility",
|
||||
}
|
||||
),
|
||||
name="workspace-duplicate-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/projects/<uuid:project_id>/views/",
|
||||
ProjectViewViewSet.as_view(
|
||||
@ -33,45 +92,22 @@ urlpatterns = [
|
||||
name="project-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
"workspaces/<str:slug>/projects/<uuid:project_id>/views/<uuid:pk>/duplicate/",
|
||||
ProjectViewViewSet.as_view(
|
||||
{
|
||||
"get": "list",
|
||||
"post": "create",
|
||||
"post": "duplicate",
|
||||
}
|
||||
),
|
||||
name="global-view",
|
||||
name="project-duplicate-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/<uuid:pk>/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
"workspaces/<str:slug>/projects/<uuid:project_id>/views/<uuid:pk>/visibility/",
|
||||
ProjectViewViewSet.as_view(
|
||||
{
|
||||
"get": "retrieve",
|
||||
"patch": "partial_update",
|
||||
"delete": "destroy",
|
||||
"post": "visibility",
|
||||
}
|
||||
),
|
||||
name="global-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/issues/",
|
||||
WorkspaceViewViewSet.as_view(
|
||||
{
|
||||
"get": "list",
|
||||
}
|
||||
),
|
||||
name="global-view-issues",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/views/<uuid:view_id>/favorite/",
|
||||
WorkspaceViewFavoriteViewSet.as_view(
|
||||
{
|
||||
"get": "list",
|
||||
"post": "create",
|
||||
"delete": "destroy",
|
||||
}
|
||||
),
|
||||
name="user-workspace-favorite-view",
|
||||
name="project-duplicate-view",
|
||||
),
|
||||
path(
|
||||
"workspaces/<str:slug>/projects/<uuid:project_id>/views/<uuid:view_id>/favorite/",
|
||||
@ -82,6 +118,6 @@ urlpatterns = [
|
||||
"delete": "destroy",
|
||||
}
|
||||
),
|
||||
name="user-project-favorite-view",
|
||||
name="project-favorite-view",
|
||||
),
|
||||
]
|
||||
|
@ -114,6 +114,20 @@ class UserWorkspaceViewViewSet(BaseViewSet):
|
||||
return Response(ViewSerializer(view).data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
def duplicate(self, request, slug, pk):
|
||||
view = View.objects.get(workspace__slug=slug, pk=pk)
|
||||
# Create a shallow copy of the original view object
|
||||
new_view = view
|
||||
|
||||
# Set the primary key of the new view to None to ensure it gets a new primary key
|
||||
new_view.pk = None
|
||||
|
||||
# Modify the name of the new view to indicate that it's a copy
|
||||
new_view.name = f"{view.name} (Copy)"
|
||||
new_view.save(owned_by=request.user)
|
||||
return Response(ViewSerializer(new_view).data, status=status.HTTP_201_CREATED)
|
||||
|
||||
|
||||
def destroy(self, request, slug, pk):
|
||||
view = View.objects.get(workspace__slug=slug, pk=pk)
|
||||
if view.owned_by != self.request.user:
|
||||
@ -160,6 +174,29 @@ class WorkspaceViewViewSet(BaseViewSet):
|
||||
view.is_locked = lock
|
||||
view.save(update_fields=["is_locked"])
|
||||
return Response(ViewSerializer(view).data, status=status.HTTP_200_OK)
|
||||
|
||||
def duplicate(self, request, slug, pk):
|
||||
view = View.objects.get(workspace__slug=slug, pk=pk)
|
||||
# Create a shallow copy of the original view object
|
||||
new_view = view
|
||||
|
||||
# Set the primary key of the new view to None to ensure it gets a new primary key
|
||||
new_view.pk = None
|
||||
|
||||
# Modify the name of the new view to indicate that it's a copy
|
||||
new_view.name = f"{view.name} (Copy)"
|
||||
new_view.save(owned_by=request.user)
|
||||
return Response(ViewSerializer(new_view).data, status=status.HTTP_201_CREATED)
|
||||
|
||||
def visibility(self, request, slug, pk):
|
||||
view = (
|
||||
self.get_queryset()
|
||||
.filter(pk=pk, workspace__slug=slug)
|
||||
.first()
|
||||
)
|
||||
view.access = request.data.get("access", view.access)
|
||||
view.save(update_fields=["access"])
|
||||
return Response(ViewSerializer(view).data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class UserProjectViewViewSet(BaseViewSet):
|
||||
@ -228,6 +265,19 @@ class UserProjectViewViewSet(BaseViewSet):
|
||||
view.is_locked = lock
|
||||
view.save(update_fields=["is_locked"])
|
||||
return Response(ViewSerializer(view).data, status=status.HTTP_200_OK)
|
||||
|
||||
def duplicate(self, request, slug, project_id, pk):
|
||||
view = View.objects.get(workspace__slug=slug, project_id=project_id, pk=pk)
|
||||
# Create a shallow copy of the original view object
|
||||
new_view = view
|
||||
|
||||
# Set the primary key of the new view to None to ensure it gets a new primary key
|
||||
new_view.pk = None
|
||||
|
||||
# Modify the name of the new view to indicate that it's a copy
|
||||
new_view.name = f"{view.name} (Copy)"
|
||||
new_view.save(owned_by=request.user)
|
||||
return Response(ViewSerializer(new_view).data, status=status.HTTP_201_CREATED)
|
||||
|
||||
def destroy(self, request, slug, project_id, pk):
|
||||
view = View.objects.get(
|
||||
@ -288,6 +338,29 @@ class ProjectViewViewSet(BaseViewSet):
|
||||
view.save(update_fields=["is_locked"])
|
||||
return Response(ViewSerializer(view).data, status=status.HTTP_200_OK)
|
||||
|
||||
def duplicate(self, request, slug, project_id, pk):
|
||||
view = View.objects.get(workspace__slug=slug, project_id=project_id, pk=pk)
|
||||
# Create a shallow copy of the original view object
|
||||
new_view = view
|
||||
|
||||
# Set the primary key of the new view to None to ensure it gets a new primary key
|
||||
new_view.pk = None
|
||||
|
||||
# Modify the name of the new view to indicate that it's a copy
|
||||
new_view.name = f"{view.name} (Copy)"
|
||||
new_view.save(owned_by=request.user)
|
||||
return Response(ViewSerializer(new_view).data, status=status.HTTP_201_CREATED)
|
||||
|
||||
def visibility(self, request, slug, project_id, pk):
|
||||
view = (
|
||||
self.get_queryset()
|
||||
.filter(pk=pk, project_id=project_id, workspace__slug=slug)
|
||||
.first()
|
||||
)
|
||||
view.access = request.data.get("access", view.access)
|
||||
view.save(update_fields=["access"])
|
||||
return Response(ViewSerializer(view).data, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
class WorkspaceViewIssuesViewSet(BaseViewSet):
|
||||
permission_classes = [
|
||||
|
@ -12,7 +12,7 @@ def views_owned_by(apps, schema_editor):
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('db', '0058_alter_moduleissue_issue_and_more'),
|
||||
('db', '0060_cycle_progress_snapshot'),
|
||||
]
|
||||
|
||||
operations = [
|
Loading…
Reference in New Issue
Block a user