fix: changed name workspace view to global view

This commit is contained in:
NarayanBavisetti 2023-09-19 18:51:08 +05:30
parent ed67a64e79
commit 8ef9df28c4
9 changed files with 64 additions and 77 deletions

View File

@ -23,7 +23,7 @@ from .project import (
ProjectPublicMemberSerializer
)
from .state import StateSerializer, StateLiteSerializer
from .view import WorkspaceViewSerializer, IssueViewSerializer, IssueViewFavoriteSerializer
from .view import GlobalViewSerializer, IssueViewSerializer, IssueViewFavoriteSerializer
from .cycle import CycleSerializer, CycleIssueSerializer, CycleFavoriteSerializer, CycleWriteSerializer
from .asset import FileAssetSerializer
from .issue import (

View File

@ -5,15 +5,15 @@ from rest_framework import serializers
from .base import BaseSerializer
from .workspace import WorkspaceLiteSerializer
from .project import ProjectLiteSerializer
from plane.db.models import WorkspaceView, IssueView, IssueViewFavorite
from plane.db.models import GlobalView, IssueView, IssueViewFavorite
from plane.utils.issue_filters import issue_filters
class WorkspaceViewSerializer(BaseSerializer):
class GlobalViewSerializer(BaseSerializer):
workspace_detail = WorkspaceLiteSerializer(source="workspace", read_only=True)
class Meta:
model = WorkspaceView
model = GlobalView
fields = "__all__"
read_only_fields = [
"workspace",
@ -26,7 +26,7 @@ class WorkspaceViewSerializer(BaseSerializer):
validated_data["query"] = issue_filters(query_params, "POST")
else:
validated_data["query"] = dict()
return WorkspaceView.objects.create(**validated_data)
return GlobalView.objects.create(**validated_data)
def update(self, instance, validated_data):
query_params = validated_data.get("query_data", {})

View File

@ -102,8 +102,8 @@ from plane.api.views import (
BulkEstimatePointEndpoint,
## End Estimates
# Views
WorkspaceViewViewSet,
WorkspaceViewIssuesViewSet,
GlobalViewViewSet,
GlobalViewIssuesViewSet,
IssueViewViewSet,
ViewIssuesEndpoint,
IssueViewFavoriteViewSet,
@ -186,7 +186,6 @@ from plane.api.views import (
## Exporter
ExportIssuesEndpoint,
## End Exporter
)
@ -243,7 +242,11 @@ urlpatterns = [
UpdateUserTourCompletedEndpoint.as_view(),
name="user-tour",
),
path("users/workspaces/<str:slug>/activities/", UserActivityEndpoint.as_view(), name="user-activities"),
path(
"users/workspaces/<str:slug>/activities/",
UserActivityEndpoint.as_view(),
name="user-activities",
),
# user workspaces
path(
"users/me/workspaces/",
@ -653,17 +656,17 @@ urlpatterns = [
),
path(
"workspaces/<str:slug>/views/",
WorkspaceViewViewSet.as_view(
GlobalViewViewSet.as_view(
{
"get": "list",
"post": "create",
}
),
name="workspace-view",
name="global-view",
),
path(
"workspaces/<str:slug>/views/<uuid:pk>/",
WorkspaceViewViewSet.as_view(
GlobalViewViewSet.as_view(
{
"get": "retrieve",
"put": "update",
@ -671,16 +674,7 @@ urlpatterns = [
"delete": "destroy",
}
),
name="workspace-view",
),
path(
"workspaces/<str:slug>/views/<uuid:view_id>/issues/",
WorkspaceViewIssuesViewSet.as_view(
{
"get": "list",
}
),
name="workspace-view-issues",
name="global-view",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/user-favorite-views/",
@ -802,8 +796,12 @@ urlpatterns = [
),
path(
"workspaces/<str:slug>/issues/",
WorkSpaceIssuesEndpoint.as_view(),
name="workspace-issue",
GlobalViewIssuesViewSet.as_view(
{
"get": "list",
}
),
name="global-view-issues",
),
path(
"workspaces/<str:slug>/projects/<uuid:project_id>/issue-labels/",

View File

@ -56,7 +56,7 @@ from .workspace import (
LeaveWorkspaceEndpoint,
)
from .state import StateViewSet
from .view import WorkspaceViewViewSet, WorkspaceViewIssuesViewSet, IssueViewViewSet, ViewIssuesEndpoint, IssueViewFavoriteViewSet
from .view import GlobalViewViewSet, GlobalViewIssuesViewSet, IssueViewViewSet, ViewIssuesEndpoint, IssueViewFavoriteViewSet
from .cycle import (
CycleViewSet,
CycleIssueViewSet,

View File

@ -24,7 +24,7 @@ from sentry_sdk import capture_exception
# Module imports
from . import BaseViewSet, BaseAPIView
from plane.api.serializers import (
WorkspaceViewSerializer,
GlobalViewSerializer,
IssueViewSerializer,
IssueLiteSerializer,
IssueViewFavoriteSerializer,
@ -32,7 +32,7 @@ from plane.api.serializers import (
from plane.api.permissions import WorkspaceEntityPermission, ProjectEntityPermission
from plane.db.models import (
Workspace,
WorkspaceView,
GlobalView,
IssueView,
Issue,
IssueViewFavorite,
@ -44,9 +44,9 @@ from plane.utils.issue_filters import issue_filters
from plane.utils.grouper import group_results
class WorkspaceViewViewSet(BaseViewSet):
serializer_class = WorkspaceViewSerializer
model = WorkspaceView
class GlobalViewViewSet(BaseViewSet):
serializer_class = GlobalViewSerializer
model = GlobalView
permission_classes = [
WorkspaceEntityPermission,
]
@ -66,7 +66,7 @@ class WorkspaceViewViewSet(BaseViewSet):
)
class WorkspaceViewIssuesViewSet(BaseViewSet):
class GlobalViewIssuesViewSet(BaseViewSet):
permission_classes = [
WorkspaceEntityPermission,
]
@ -80,6 +80,7 @@ class WorkspaceViewIssuesViewSet(BaseViewSet):
.values("count")
)
.filter(workspace__slug=self.kwargs.get("slug"))
.select_related("project")
.select_related("workspace")
.select_related("state")
.select_related("parent")
@ -95,7 +96,7 @@ class WorkspaceViewIssuesViewSet(BaseViewSet):
@method_decorator(gzip_page)
def list(self, request, slug, view_id):
def list(self, request, slug):
try:
filters = issue_filters(request.query_params, "GET")

View File

@ -1,38 +0,0 @@
# Generated by Django 4.2.3 on 2023-09-14 13:17
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
dependencies = [
('db', '0044_auto_20230913_0709'),
]
operations = [
migrations.CreateModel(
name='WorkspaceView',
fields=[
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
('name', models.CharField(max_length=255, verbose_name='View Name')),
('description', models.TextField(blank=True, verbose_name='View Description')),
('query', models.JSONField(verbose_name='View Query')),
('access', models.PositiveSmallIntegerField(choices=[(0, 'Private'), (1, 'Public')], default=1)),
('query_data', models.JSONField(default=dict)),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workspace_views', to='db.workspace')),
],
options={
'verbose_name': 'Workspace View',
'verbose_name_plural': 'Workspace Views',
'db_table': 'workspace_views',
'ordering': ('-created_at',),
},
),
]

View File

@ -1,6 +1,10 @@
# Generated by Django 4.2.3 on 2023-09-15 06:55
from django.db import migrations
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid
def update_issue_activity(apps, schema_editor):
IssueActivityModel = apps.get_model("db", "IssueActivity")
@ -19,5 +23,27 @@ class Migration(migrations.Migration):
]
operations = [
migrations.CreateModel(
name='GlobalView',
fields=[
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Last Modified At')),
('id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True)),
('name', models.CharField(max_length=255, verbose_name='View Name')),
('description', models.TextField(blank=True, verbose_name='View Description')),
('query', models.JSONField(verbose_name='View Query')),
('access', models.PositiveSmallIntegerField(choices=[(0, 'Private'), (1, 'Public')], default=1)),
('query_data', models.JSONField(default=dict)),
('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_created_by', to=settings.AUTH_USER_MODEL, verbose_name='Created By')),
('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='%(class)s_updated_by', to=settings.AUTH_USER_MODEL, verbose_name='Last Modified By')),
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='global_views', to='db.workspace')),
],
options={
'verbose_name': 'Global View',
'verbose_name_plural': 'Global Views',
'db_table': 'global_views',
'ordering': ('-created_at',),
},
),
migrations.RunPython(update_issue_activity),
]

View File

@ -50,7 +50,7 @@ from .state import State
from .cycle import Cycle, CycleIssue, CycleFavorite
from .view import WorkspaceView, IssueView, IssueViewFavorite
from .view import GlobalView, IssueView, IssueViewFavorite
from .module import Module, ModuleMember, ModuleIssue, ModuleLink, ModuleFavorite

View File

@ -6,9 +6,9 @@ from django.conf import settings
from . import ProjectBaseModel, BaseModel
class WorkspaceView(BaseModel):
class GlobalView(BaseModel):
workspace = models.ForeignKey(
"db.Workspace", on_delete=models.CASCADE, related_name="workspace_views"
"db.Workspace", on_delete=models.CASCADE, related_name="global_views"
)
name = models.CharField(max_length=255, verbose_name="View Name")
description = models.TextField(verbose_name="View Description", blank=True)
@ -19,9 +19,9 @@ class WorkspaceView(BaseModel):
query_data = models.JSONField(default=dict)
class Meta:
verbose_name = "Workspace View"
verbose_name_plural = "Workspace Views"
db_table = "workspace_views"
verbose_name = "Global View"
verbose_name_plural = "Global Views"
db_table = "global_views"
ordering = ("-created_at",)
def __str__(self):