mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
dev: serializer updates for workspace, project, inbox etc.
This commit is contained in:
parent
ea3b9456f9
commit
168823e5ba
@ -18,7 +18,7 @@ from .project import (
|
|||||||
ProjectDeployBoardSerializer,
|
ProjectDeployBoardSerializer,
|
||||||
ProjectMemberAdminSerializer,
|
ProjectMemberAdminSerializer,
|
||||||
)
|
)
|
||||||
from .state import StateSerializer, StateLiteSerializer
|
from .state import StateSerializer
|
||||||
from .view import IssueViewSerializer, IssueViewFavoriteSerializer
|
from .view import IssueViewSerializer, IssueViewFavoriteSerializer
|
||||||
from .cycle import CycleSerializer, CycleIssueSerializer, CycleFavoriteSerializer, CycleWriteSerializer
|
from .cycle import CycleSerializer, CycleIssueSerializer, CycleFavoriteSerializer, CycleWriteSerializer
|
||||||
from .asset import FileAssetSerializer
|
from .asset import FileAssetSerializer
|
||||||
@ -70,7 +70,6 @@ from .page import PageSerializer, PageBlockSerializer, PageFavoriteSerializer
|
|||||||
from .estimate import (
|
from .estimate import (
|
||||||
EstimateSerializer,
|
EstimateSerializer,
|
||||||
EstimatePointSerializer,
|
EstimatePointSerializer,
|
||||||
EstimateReadSerializer,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from .inbox import InboxSerializer, InboxIssueSerializer, IssueStateInboxSerializer
|
from .inbox import InboxSerializer, InboxIssueSerializer, IssueStateInboxSerializer
|
||||||
|
@ -6,12 +6,8 @@ from plane.api.serializers import WorkSpaceSerializer, ProjectSerializer
|
|||||||
|
|
||||||
|
|
||||||
class EstimateSerializer(BaseSerializer):
|
class EstimateSerializer(BaseSerializer):
|
||||||
workspace_detail = WorkSpaceSerializer(
|
workspace_detail = WorkSpaceSerializer(source="workspace", read_only=True)
|
||||||
source="workspace",
|
project_detail = ProjectSerializer(read_only=True, source="project")
|
||||||
fields=("id", "name", "slug"),
|
|
||||||
read_only=True,
|
|
||||||
)
|
|
||||||
project_detail = ProjectSerializer(read_only=True, source="project", fields=("id","name","cover_image","icon_prop","emoji","description"))
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Estimate
|
model = Estimate
|
||||||
@ -31,22 +27,3 @@ class EstimatePointSerializer(BaseSerializer):
|
|||||||
"workspace",
|
"workspace",
|
||||||
"project",
|
"project",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class EstimateReadSerializer(BaseSerializer):
|
|
||||||
points = EstimatePointSerializer(read_only=True, many=True)
|
|
||||||
workspace_detail = WorkSpaceSerializer(
|
|
||||||
source="workspace",
|
|
||||||
fields=("id", "name", "slug"),
|
|
||||||
read_only=True,
|
|
||||||
)
|
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id","name","cover_image","icon_prop","emoji","description"), read_only=True)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = Estimate
|
|
||||||
fields = "__all__"
|
|
||||||
read_only_fields = [
|
|
||||||
"points",
|
|
||||||
"name",
|
|
||||||
"description",
|
|
||||||
]
|
|
||||||
|
@ -7,8 +7,8 @@ from plane.db.models import Importer
|
|||||||
|
|
||||||
|
|
||||||
class ImporterSerializer(BaseSerializer):
|
class ImporterSerializer(BaseSerializer):
|
||||||
initiated_by_detail = UserSerializer(source="initiated_by",read_only=True)
|
initiated_by_detail = UserSerializer(source="initiated_by", read_only=True)
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id","name","cover_image","icon_prop","emoji","description"), read_only=True)
|
project_detail = ProjectSerializer(source="project", read_only=True)
|
||||||
workspace_detail = WorkSpaceSerializer(source="workspace", read_only=True)
|
workspace_detail = WorkSpaceSerializer(source="workspace", read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -53,7 +53,11 @@ class IssueFlatSerializer(BaseSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class IssueProjectLiteSerializer(BaseSerializer):
|
class IssueProjectLiteSerializer(BaseSerializer):
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Issue
|
model = Issue
|
||||||
@ -70,13 +74,12 @@ class IssueProjectLiteSerializer(BaseSerializer):
|
|||||||
## Find a better approach to save manytomany?
|
## Find a better approach to save manytomany?
|
||||||
class IssueCreateSerializer(BaseSerializer):
|
class IssueCreateSerializer(BaseSerializer):
|
||||||
state_detail = StateSerializer(read_only=True, source="state")
|
state_detail = StateSerializer(read_only=True, source="state")
|
||||||
created_by_detail = UserSerializer(source="created_by", read_only=True,)
|
created_by_detail = UserSerializer(
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
source="created_by",
|
||||||
workspace_detail = WorkSpaceSerializer(
|
|
||||||
source="workspace",
|
|
||||||
fields=("id", "name", "slug"),
|
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
|
project_detail = ProjectSerializer(source="project", read_only=True)
|
||||||
|
workspace_detail = WorkSpaceSerializer(source="workspace", read_only=True)
|
||||||
|
|
||||||
assignees_list = serializers.ListField(
|
assignees_list = serializers.ListField(
|
||||||
child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
|
child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
|
||||||
@ -305,7 +308,11 @@ class IssueCreateSerializer(BaseSerializer):
|
|||||||
class IssueActivitySerializer(BaseSerializer):
|
class IssueActivitySerializer(BaseSerializer):
|
||||||
actor_detail = UserSerializer(source="actor", read_only=True)
|
actor_detail = UserSerializer(source="actor", read_only=True)
|
||||||
issue_detail = IssueFlatSerializer(read_only=True, source="issue")
|
issue_detail = IssueFlatSerializer(read_only=True, source="issue")
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IssueActivity
|
model = IssueActivity
|
||||||
@ -327,7 +334,11 @@ class LabelSerializer(BaseSerializer):
|
|||||||
workspace_detail = WorkSpaceSerializer(
|
workspace_detail = WorkSpaceSerializer(
|
||||||
source="workspace", fields=("id", "name", "slug"), read_only=True
|
source="workspace", fields=("id", "name", "slug"), read_only=True
|
||||||
)
|
)
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Label
|
model = Label
|
||||||
@ -569,13 +580,17 @@ class IssueVoteSerializer(BaseSerializer):
|
|||||||
class IssueCommentSerializer(BaseSerializer):
|
class IssueCommentSerializer(BaseSerializer):
|
||||||
actor_detail = UserSerializer(source="actor", read_only=True)
|
actor_detail = UserSerializer(source="actor", read_only=True)
|
||||||
issue_detail = IssueFlatSerializer(read_only=True, source="issue")
|
issue_detail = IssueFlatSerializer(read_only=True, source="issue")
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
workspace_details = WorkSpaceSerializer(
|
workspace_details = WorkSpaceSerializer(
|
||||||
source="workspace",
|
source="workspace",
|
||||||
fields=("id", "name", "slug"),
|
fields=("id", "name", "slug"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
comment_reactions = CommentReactionLiteSerializer(read_only=True, many=True)
|
comment_reactions = CommentReactionLiteSerializer(read_only=True, many=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -595,7 +610,11 @@ class IssueCommentSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class IssueStateFlatSerializer(BaseSerializer):
|
class IssueStateFlatSerializer(BaseSerializer):
|
||||||
state_detail = StateLiteSerializer(read_only=True, source="state")
|
state_detail = StateLiteSerializer(read_only=True, source="state")
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Issue
|
model = Issue
|
||||||
@ -612,7 +631,11 @@ class IssueStateFlatSerializer(BaseSerializer):
|
|||||||
class IssueStateSerializer(BaseSerializer):
|
class IssueStateSerializer(BaseSerializer):
|
||||||
label_details = LabelLiteSerializer(read_only=True, source="labels", many=True)
|
label_details = LabelLiteSerializer(read_only=True, source="labels", many=True)
|
||||||
state_detail = StateLiteSerializer(read_only=True, source="state")
|
state_detail = StateLiteSerializer(read_only=True, source="state")
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
assignee_details = UserSerializer(
|
assignee_details = UserSerializer(
|
||||||
source="assignees",
|
source="assignees",
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
@ -630,7 +653,11 @@ class IssueStateSerializer(BaseSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class IssueSerializer(BaseSerializer):
|
class IssueSerializer(BaseSerializer):
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
state_detail = StateSerializer(read_only=True, source="state")
|
state_detail = StateSerializer(read_only=True, source="state")
|
||||||
parent_detail = IssueStateFlatSerializer(read_only=True, source="parent")
|
parent_detail = IssueStateFlatSerializer(read_only=True, source="parent")
|
||||||
label_details = LabelSerializer(read_only=True, source="labels", many=True)
|
label_details = LabelSerializer(read_only=True, source="labels", many=True)
|
||||||
@ -669,8 +696,12 @@ class IssueLiteSerializer(BaseSerializer):
|
|||||||
source="workspace",
|
source="workspace",
|
||||||
fields=("id", "name", "slug"),
|
fields=("id", "name", "slug"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project_detail = ProjectSerializer(
|
||||||
|
source="project",
|
||||||
|
fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"),
|
||||||
|
read_only=True,
|
||||||
|
)
|
||||||
state_detail = StateLiteSerializer(read_only=True, source="state")
|
state_detail = StateLiteSerializer(read_only=True, source="state")
|
||||||
label_details = LabelLiteSerializer(read_only=True, source="labels", many=True)
|
label_details = LabelLiteSerializer(read_only=True, source="labels", many=True)
|
||||||
assignee_details = UserSerializer(
|
assignee_details = UserSerializer(
|
||||||
|
@ -7,7 +7,7 @@ from plane.db.models import Notification
|
|||||||
class NotificationSerializer(BaseSerializer):
|
class NotificationSerializer(BaseSerializer):
|
||||||
triggered_by_details = UserSerializer(
|
triggered_by_details = UserSerializer(
|
||||||
source="triggered_by",
|
source="triggered_by",
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ from plane.db.models import (
|
|||||||
class ProjectSerializer(BaseSerializer):
|
class ProjectSerializer(BaseSerializer):
|
||||||
# workspace = WorkSpaceSerializer(read_only=True)
|
# workspace = WorkSpaceSerializer(read_only=True)
|
||||||
default_assignee = UserSerializer(
|
default_assignee = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
project_lead = UserSerializer(
|
project_lead = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
is_favorite = serializers.BooleanField(read_only=True)
|
is_favorite = serializers.BooleanField(read_only=True)
|
||||||
@ -102,11 +102,11 @@ class ProjectSerializer(BaseSerializer):
|
|||||||
class ProjectDetailSerializer(BaseSerializer):
|
class ProjectDetailSerializer(BaseSerializer):
|
||||||
workspace = WorkSpaceSerializer(read_only=True)
|
workspace = WorkSpaceSerializer(read_only=True)
|
||||||
default_assignee = UserSerializer(
|
default_assignee = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
project_lead = UserSerializer(
|
project_lead = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
is_favorite = serializers.BooleanField(read_only=True)
|
is_favorite = serializers.BooleanField(read_only=True)
|
||||||
@ -127,7 +127,7 @@ class ProjectMemberSerializer(BaseSerializer):
|
|||||||
workspace = WorkSpaceSerializer(read_only=True)
|
workspace = WorkSpaceSerializer(read_only=True)
|
||||||
project = ProjectSerializer(fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project = ProjectSerializer(fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
||||||
member = UserSerializer(
|
member = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -144,15 +144,15 @@ class ProjectMemberAdminSerializer(BaseSerializer):
|
|||||||
)
|
)
|
||||||
project = ProjectSerializer(fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
project = ProjectSerializer(fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
||||||
member = UserSerializer(
|
member = UserSerializer(
|
||||||
fields=(
|
# fields=(
|
||||||
"id",
|
# "id",
|
||||||
"first_name",
|
# "first_name",
|
||||||
"last_name",
|
# "last_name",
|
||||||
"avatar",
|
# "avatar",
|
||||||
"is_bot",
|
# "is_bot",
|
||||||
"display_name",
|
# "display_name",
|
||||||
"email",
|
# "email",
|
||||||
),
|
# ),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class ProjectFavoriteSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class ProjectMemberLiteSerializer(BaseSerializer):
|
class ProjectMemberLiteSerializer(BaseSerializer):
|
||||||
member = UserSerializer(
|
member = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
is_subscribed = serializers.BooleanField(read_only=True)
|
is_subscribed = serializers.BooleanField(read_only=True)
|
||||||
|
@ -7,12 +7,8 @@ from plane.db.models import State
|
|||||||
|
|
||||||
|
|
||||||
class StateSerializer(BaseSerializer):
|
class StateSerializer(BaseSerializer):
|
||||||
workspace_detail = WorkSpaceSerializer(
|
workspace_detail = WorkSpaceSerializer(source="workspace", read_only=True)
|
||||||
source="workspace",
|
project_detail = ProjectSerializer(source="project", read_only=True)
|
||||||
fields=("id", "name", "slug"),
|
|
||||||
read_only=True,
|
|
||||||
)
|
|
||||||
project_detail = ProjectSerializer(source="project", fields=("id", "name", "cover_image", "icon_prop", "emoji", "description"), read_only=True)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = State
|
model = State
|
||||||
|
@ -39,7 +39,7 @@ class WorkSpaceSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class WorkSpaceMemberSerializer(BaseSerializer):
|
class WorkSpaceMemberSerializer(BaseSerializer):
|
||||||
member = UserSerializer(
|
member = UserSerializer(
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name" ,"email"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name" ,"email"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
workspace = WorkSpaceSerializer(
|
workspace = WorkSpaceSerializer(
|
||||||
@ -57,7 +57,7 @@ class WorkSpaceMemberInviteSerializer(BaseSerializer):
|
|||||||
total_members = serializers.IntegerField(read_only=True)
|
total_members = serializers.IntegerField(read_only=True)
|
||||||
created_by_detail = UserSerializer(
|
created_by_detail = UserSerializer(
|
||||||
source="created_by",
|
source="created_by",
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ class WorkSpaceMemberInviteSerializer(BaseSerializer):
|
|||||||
class TeamSerializer(BaseSerializer):
|
class TeamSerializer(BaseSerializer):
|
||||||
members_detail = UserSerializer(
|
members_detail = UserSerializer(
|
||||||
source="members",
|
source="members",
|
||||||
fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
# fields=("id", "first_name", "last_name", "avatar", "is_bot", "display_name"),
|
||||||
read_only=True,
|
read_only=True,
|
||||||
many=True,
|
many=True,
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,6 @@ from plane.db.models import Project, Estimate, EstimatePoint
|
|||||||
from plane.api.serializers import (
|
from plane.api.serializers import (
|
||||||
EstimateSerializer,
|
EstimateSerializer,
|
||||||
EstimatePointSerializer,
|
EstimatePointSerializer,
|
||||||
EstimateReadSerializer,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -51,10 +50,38 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
|
|
||||||
def list(self, request, slug, project_id):
|
def list(self, request, slug, project_id):
|
||||||
try:
|
try:
|
||||||
estimates = Estimate.objects.filter(
|
estimates = (
|
||||||
workspace__slug=slug, project_id=project_id
|
Estimate.objects.filter(workspace__slug=slug, project_id=project_id)
|
||||||
).prefetch_related("points").select_related("workspace", "project")
|
.prefetch_related("points")
|
||||||
serializer = EstimateReadSerializer(estimates, many=True)
|
.select_related("workspace", "project")
|
||||||
|
)
|
||||||
|
serializer = EstimateSerializer(
|
||||||
|
estimates,
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name",
|
||||||
|
"points",
|
||||||
|
"description",
|
||||||
|
],
|
||||||
|
many=True,
|
||||||
|
)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
capture_exception(e)
|
capture_exception(e)
|
||||||
@ -79,7 +106,31 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
)
|
)
|
||||||
|
|
||||||
estimate_serializer = EstimateSerializer(data=request.data.get("estimate"))
|
estimate_serializer = EstimateSerializer(
|
||||||
|
data=request.data.get("estimate"),
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
],
|
||||||
|
)
|
||||||
if not estimate_serializer.is_valid():
|
if not estimate_serializer.is_valid():
|
||||||
return Response(
|
return Response(
|
||||||
estimate_serializer.errors, status=status.HTTP_400_BAD_REQUEST
|
estimate_serializer.errors, status=status.HTTP_400_BAD_REQUEST
|
||||||
@ -137,7 +188,32 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
estimate = Estimate.objects.get(
|
estimate = Estimate.objects.get(
|
||||||
pk=estimate_id, workspace__slug=slug, project_id=project_id
|
pk=estimate_id, workspace__slug=slug, project_id=project_id
|
||||||
)
|
)
|
||||||
serializer = EstimateReadSerializer(estimate)
|
serializer = EstimateSerializer(
|
||||||
|
estimate,
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name",
|
||||||
|
"points",
|
||||||
|
"description",
|
||||||
|
],
|
||||||
|
)
|
||||||
return Response(
|
return Response(
|
||||||
serializer.data,
|
serializer.data,
|
||||||
status=status.HTTP_200_OK,
|
status=status.HTTP_200_OK,
|
||||||
@ -170,7 +246,31 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
estimate = Estimate.objects.get(pk=estimate_id)
|
estimate = Estimate.objects.get(pk=estimate_id)
|
||||||
|
|
||||||
estimate_serializer = EstimateSerializer(
|
estimate_serializer = EstimateSerializer(
|
||||||
estimate, data=request.data.get("estimate"), partial=True
|
estimate,
|
||||||
|
data=request.data.get("estimate"),
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
],
|
||||||
|
partial=True,
|
||||||
)
|
)
|
||||||
if not estimate_serializer.is_valid():
|
if not estimate_serializer.is_valid():
|
||||||
return Response(
|
return Response(
|
||||||
@ -211,7 +311,9 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
EstimatePoint.objects.bulk_update(
|
EstimatePoint.objects.bulk_update(
|
||||||
updated_estimate_points, ["value"], batch_size=10,
|
updated_estimate_points,
|
||||||
|
["value"],
|
||||||
|
batch_size=10,
|
||||||
)
|
)
|
||||||
except IntegrityError as e:
|
except IntegrityError as e:
|
||||||
return Response(
|
return Response(
|
||||||
@ -219,7 +321,9 @@ class BulkEstimatePointEndpoint(BaseViewSet):
|
|||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
)
|
)
|
||||||
|
|
||||||
estimate_point_serializer = EstimatePointSerializer(estimate_points, many=True)
|
estimate_point_serializer = EstimatePointSerializer(
|
||||||
|
estimate_points, many=True
|
||||||
|
)
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"estimate": estimate_serializer.data,
|
"estimate": estimate_serializer.data,
|
||||||
|
@ -42,7 +42,6 @@ from plane.utils.html_processor import strip_tags
|
|||||||
|
|
||||||
|
|
||||||
class ServiceIssueImportSummaryEndpoint(BaseAPIView):
|
class ServiceIssueImportSummaryEndpoint(BaseAPIView):
|
||||||
|
|
||||||
def get(self, request, slug, service):
|
def get(self, request, slug, service):
|
||||||
try:
|
try:
|
||||||
if service == "github":
|
if service == "github":
|
||||||
@ -179,33 +178,44 @@ class ImportServiceEndpoint(BaseAPIView):
|
|||||||
service_importer.delay(service, importer.id)
|
service_importer.delay(service, importer.id)
|
||||||
serializer = ImporterSerializer(
|
serializer = ImporterSerializer(
|
||||||
importer,
|
importer,
|
||||||
fields={
|
fields=[
|
||||||
"id": [],
|
"id",
|
||||||
"created_by": [],
|
"created_by",
|
||||||
"created_at": [],
|
"created_at",
|
||||||
"updated_at": [],
|
"updated_at",
|
||||||
"updated_by": [],
|
"updated_by",
|
||||||
"workspace": [],
|
"workspace",
|
||||||
"project": [],
|
"project",
|
||||||
"initiated_by": [],
|
"service",
|
||||||
"project_detail": [],
|
"status",
|
||||||
"workspace_detail": [],
|
"initiated_by",
|
||||||
"service": [],
|
"metadata",
|
||||||
"status": [],
|
"config",
|
||||||
"metadata": [],
|
"data",
|
||||||
"config": [],
|
"token",
|
||||||
"data": [],
|
"imported_data",
|
||||||
"token": [],
|
{
|
||||||
"imported_data": [],
|
"initiated_by_detail": [
|
||||||
"initiated_by_detail": [
|
"id",
|
||||||
"id",
|
"first_name",
|
||||||
"first_name",
|
"last_name",
|
||||||
"last_name",
|
"avatar",
|
||||||
"avatar",
|
"is_bot",
|
||||||
"is_bot",
|
"display_name",
|
||||||
"display_name",
|
],
|
||||||
],
|
},
|
||||||
},
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
],
|
||||||
)
|
)
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||||
|
|
||||||
@ -244,33 +254,44 @@ class ImportServiceEndpoint(BaseAPIView):
|
|||||||
service_importer.delay(service, importer.id)
|
service_importer.delay(service, importer.id)
|
||||||
serializer = ImporterSerializer(
|
serializer = ImporterSerializer(
|
||||||
importer,
|
importer,
|
||||||
fields={
|
fields=[
|
||||||
"id": [],
|
"id",
|
||||||
"created_by": [],
|
"created_by",
|
||||||
"created_at": [],
|
"created_at",
|
||||||
"updated_at": [],
|
"updated_at",
|
||||||
"updated_by": [],
|
"updated_by",
|
||||||
"workspace": [],
|
"workspace",
|
||||||
"project": [],
|
"project",
|
||||||
"initiated_by": [],
|
"service",
|
||||||
"project_detail": [],
|
"status",
|
||||||
"workspace_detail": [],
|
"initiated_by",
|
||||||
"service": [],
|
"metadata",
|
||||||
"status": [],
|
"config",
|
||||||
"metadata": [],
|
"data",
|
||||||
"config": [],
|
"token",
|
||||||
"data": [],
|
"imported_data",
|
||||||
"token": [],
|
{
|
||||||
"imported_data": [],
|
"initiated_by_detail": [
|
||||||
"initiated_by_detail": [
|
"id",
|
||||||
"id",
|
"first_name",
|
||||||
"first_name",
|
"last_name",
|
||||||
"last_name",
|
"avatar",
|
||||||
"avatar",
|
"is_bot",
|
||||||
"is_bot",
|
"display_name",
|
||||||
"display_name",
|
],
|
||||||
],
|
},
|
||||||
},
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
],
|
||||||
)
|
)
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||||
|
|
||||||
@ -311,11 +332,9 @@ class ImportServiceEndpoint(BaseAPIView):
|
|||||||
"updated_by",
|
"updated_by",
|
||||||
"workspace",
|
"workspace",
|
||||||
"project",
|
"project",
|
||||||
"initiated_by",
|
|
||||||
"project_detail",
|
|
||||||
"workspace_detail",
|
|
||||||
"service",
|
"service",
|
||||||
"status",
|
"status",
|
||||||
|
"initiated_by",
|
||||||
"metadata",
|
"metadata",
|
||||||
"config",
|
"config",
|
||||||
"data",
|
"data",
|
||||||
@ -329,8 +348,19 @@ class ImportServiceEndpoint(BaseAPIView):
|
|||||||
"avatar",
|
"avatar",
|
||||||
"is_bot",
|
"is_bot",
|
||||||
"display_name",
|
"display_name",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
],
|
],
|
||||||
many=True,
|
many=True,
|
||||||
)
|
)
|
||||||
@ -384,11 +414,9 @@ class ImportServiceEndpoint(BaseAPIView):
|
|||||||
"updated_by",
|
"updated_by",
|
||||||
"workspace",
|
"workspace",
|
||||||
"project",
|
"project",
|
||||||
"initiated_by",
|
|
||||||
"project_detail",
|
|
||||||
"workspace_detail",
|
|
||||||
"service",
|
"service",
|
||||||
"status",
|
"status",
|
||||||
|
"initiated_by",
|
||||||
"metadata",
|
"metadata",
|
||||||
"config",
|
"config",
|
||||||
"data",
|
"data",
|
||||||
@ -402,8 +430,19 @@ class ImportServiceEndpoint(BaseAPIView):
|
|||||||
"avatar",
|
"avatar",
|
||||||
"is_bot",
|
"is_bot",
|
||||||
"display_name",
|
"display_name",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
],
|
],
|
||||||
data=request.data,
|
data=request.data,
|
||||||
partial=True,
|
partial=True,
|
||||||
|
@ -297,16 +297,86 @@ class InboxIssueViewSet(BaseViewSet):
|
|||||||
issue_serializer = IssueCreateSerializer(
|
issue_serializer = IssueCreateSerializer(
|
||||||
issue,
|
issue,
|
||||||
data=issue_data,
|
data=issue_data,
|
||||||
nested_fields={
|
fields=[
|
||||||
"created_by_detail": (
|
{
|
||||||
"id",
|
"created_by_detail": [
|
||||||
"first_name",
|
"id",
|
||||||
"last_name",
|
"first_name",
|
||||||
"avatar",
|
"last_name",
|
||||||
"is_bot",
|
"avatar",
|
||||||
"display_name",
|
"is_bot",
|
||||||
)
|
"display_name",
|
||||||
},
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"state_detail": [
|
||||||
|
"id",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"color",
|
||||||
|
"slug",
|
||||||
|
"sequence",
|
||||||
|
"group",
|
||||||
|
"default",
|
||||||
|
"project",
|
||||||
|
"workspace",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
"assignees_list",
|
||||||
|
"blockers_list",
|
||||||
|
"labels_list",
|
||||||
|
"blocks_list",
|
||||||
|
"PRIORITY_CHOICES",
|
||||||
|
"parent",
|
||||||
|
"state",
|
||||||
|
"estimate_point",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"description_html",
|
||||||
|
"description_stripped",
|
||||||
|
"priority",
|
||||||
|
"start_date",
|
||||||
|
"target_date",
|
||||||
|
"assignees",
|
||||||
|
"sequence_id",
|
||||||
|
"labels",
|
||||||
|
"sort_order",
|
||||||
|
"completed_at",
|
||||||
|
"archived_at",
|
||||||
|
],
|
||||||
partial=True,
|
partial=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -335,7 +405,30 @@ class InboxIssueViewSet(BaseViewSet):
|
|||||||
# Only project admins and members can edit inbox issue attributes
|
# Only project admins and members can edit inbox issue attributes
|
||||||
if project_member.role > 10:
|
if project_member.role > 10:
|
||||||
serializer = InboxIssueSerializer(
|
serializer = InboxIssueSerializer(
|
||||||
inbox_issue, data=request.data, partial=True
|
inbox_issue,
|
||||||
|
fields=[
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"inbox",
|
||||||
|
"issue",
|
||||||
|
"status",
|
||||||
|
"snoozed_till",
|
||||||
|
"duplicate_to",
|
||||||
|
"source",
|
||||||
|
],
|
||||||
|
data=request.data,
|
||||||
|
partial=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
@ -692,16 +785,86 @@ class InboxIssuePublicViewSet(BaseViewSet):
|
|||||||
issue_serializer = IssueCreateSerializer(
|
issue_serializer = IssueCreateSerializer(
|
||||||
issue,
|
issue,
|
||||||
data=issue_data,
|
data=issue_data,
|
||||||
nested_fields={
|
fields=[
|
||||||
"created_by_detail": (
|
{
|
||||||
"id",
|
"created_by_detail": [
|
||||||
"first_name",
|
"id",
|
||||||
"last_name",
|
"first_name",
|
||||||
"avatar",
|
"last_name",
|
||||||
"is_bot",
|
"avatar",
|
||||||
"display_name",
|
"is_bot",
|
||||||
)
|
"display_name",
|
||||||
},
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"state_detail": [
|
||||||
|
"id",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"color",
|
||||||
|
"slug",
|
||||||
|
"sequence",
|
||||||
|
"group",
|
||||||
|
"default",
|
||||||
|
"project",
|
||||||
|
"workspace",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
"assignees_list",
|
||||||
|
"blockers_list",
|
||||||
|
"labels_list",
|
||||||
|
"blocks_list",
|
||||||
|
"PRIORITY_CHOICES",
|
||||||
|
"parent",
|
||||||
|
"state",
|
||||||
|
"estimate_point",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"description_html",
|
||||||
|
"description_stripped",
|
||||||
|
"priority",
|
||||||
|
"start_date",
|
||||||
|
"target_date",
|
||||||
|
"assignees",
|
||||||
|
"sequence_id",
|
||||||
|
"labels",
|
||||||
|
"sort_order",
|
||||||
|
"completed_at",
|
||||||
|
"archived_at",
|
||||||
|
],
|
||||||
partial=True,
|
partial=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -281,16 +281,86 @@ class IssueViewSet(BaseViewSet):
|
|||||||
|
|
||||||
serializer = IssueCreateSerializer(
|
serializer = IssueCreateSerializer(
|
||||||
data=request.data,
|
data=request.data,
|
||||||
nested_fields={
|
fields=[
|
||||||
"created_by_detail": (
|
{
|
||||||
"id",
|
"created_by_detail": [
|
||||||
"first_name",
|
"id",
|
||||||
"last_name",
|
"first_name",
|
||||||
"avatar",
|
"last_name",
|
||||||
"is_bot",
|
"avatar",
|
||||||
"display_name",
|
"is_bot",
|
||||||
)
|
"display_name",
|
||||||
},
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"state_detail": [
|
||||||
|
"id",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"color",
|
||||||
|
"slug",
|
||||||
|
"sequence",
|
||||||
|
"group",
|
||||||
|
"default",
|
||||||
|
"project",
|
||||||
|
"workspace",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
"id",
|
||||||
|
"created_at",
|
||||||
|
"created_by",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
"assignees_list",
|
||||||
|
"blockers_list",
|
||||||
|
"labels_list",
|
||||||
|
"blocks_list",
|
||||||
|
"PRIORITY_CHOICES",
|
||||||
|
"parent",
|
||||||
|
"state",
|
||||||
|
"estimate_point",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"description_html",
|
||||||
|
"description_stripped",
|
||||||
|
"priority",
|
||||||
|
"start_date",
|
||||||
|
"target_date",
|
||||||
|
"assignees",
|
||||||
|
"sequence_id",
|
||||||
|
"labels",
|
||||||
|
"sort_order",
|
||||||
|
"completed_at",
|
||||||
|
"archived_at",
|
||||||
|
],
|
||||||
context={
|
context={
|
||||||
"project_id": project_id,
|
"project_id": project_id,
|
||||||
"workspace_id": project.workspace_id,
|
"workspace_id": project.workspace_id,
|
||||||
|
@ -42,7 +42,36 @@ class StateViewSet(BaseViewSet):
|
|||||||
|
|
||||||
def create(self, request, slug, project_id):
|
def create(self, request, slug, project_id):
|
||||||
try:
|
try:
|
||||||
serializer = StateSerializer(data=request.data)
|
serializer = StateSerializer(
|
||||||
|
data=request.data,
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"color",
|
||||||
|
"slug",
|
||||||
|
"sequence",
|
||||||
|
"group",
|
||||||
|
"default",
|
||||||
|
"project",
|
||||||
|
"workspace",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
serializer.save(project_id=project_id)
|
serializer.save(project_id=project_id)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
@ -62,7 +91,37 @@ class StateViewSet(BaseViewSet):
|
|||||||
def list(self, request, slug, project_id):
|
def list(self, request, slug, project_id):
|
||||||
try:
|
try:
|
||||||
state_dict = dict()
|
state_dict = dict()
|
||||||
states = StateSerializer(self.get_queryset(), many=True).data
|
states = StateSerializer(
|
||||||
|
self.get_queryset(),
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"color",
|
||||||
|
"slug",
|
||||||
|
"sequence",
|
||||||
|
"group",
|
||||||
|
"default",
|
||||||
|
"project",
|
||||||
|
"workspace",
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
],
|
||||||
|
many=True,
|
||||||
|
).data
|
||||||
|
|
||||||
for key, value in groupby(
|
for key, value in groupby(
|
||||||
sorted(states, key=lambda state: state["group"]),
|
sorted(states, key=lambda state: state["group"]),
|
||||||
@ -82,7 +141,9 @@ class StateViewSet(BaseViewSet):
|
|||||||
try:
|
try:
|
||||||
state = State.objects.get(
|
state = State.objects.get(
|
||||||
~Q(name="Triage"),
|
~Q(name="Triage"),
|
||||||
pk=pk, project_id=project_id, workspace__slug=slug,
|
pk=pk,
|
||||||
|
project_id=project_id,
|
||||||
|
workspace__slug=slug,
|
||||||
)
|
)
|
||||||
|
|
||||||
if state.default:
|
if state.default:
|
||||||
|
@ -161,7 +161,47 @@ def service_importer(service, importer_id):
|
|||||||
if settings.PROXY_BASE_URL:
|
if settings.PROXY_BASE_URL:
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
import_data_json = json.dumps(
|
import_data_json = json.dumps(
|
||||||
ImporterSerializer(importer,fields=["id","created_by","created_at","updated_at","updated_by","workspace","project","initiated_by","project_detail","workspace_detail","service","status","metadata","config","data","token","imported_data",{"initiated_by_detail":["id", "first_name", "last_name", "avatar", "is_bot", "display_name"]}]).data,
|
ImporterSerializer(
|
||||||
|
importer,
|
||||||
|
fields=[
|
||||||
|
"id",
|
||||||
|
"created_by",
|
||||||
|
"created_at",
|
||||||
|
"updated_at",
|
||||||
|
"updated_by",
|
||||||
|
"workspace",
|
||||||
|
"project",
|
||||||
|
"service",
|
||||||
|
"status",
|
||||||
|
"initiated_by",
|
||||||
|
"metadata",
|
||||||
|
"config",
|
||||||
|
"data",
|
||||||
|
"token",
|
||||||
|
"imported_data",
|
||||||
|
{
|
||||||
|
"initiated_by_detail": [
|
||||||
|
"id",
|
||||||
|
"first_name",
|
||||||
|
"last_name",
|
||||||
|
"avatar",
|
||||||
|
"is_bot",
|
||||||
|
"display_name",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"project_detail": [
|
||||||
|
"id",
|
||||||
|
"name",
|
||||||
|
"cover_image",
|
||||||
|
"icon_prop",
|
||||||
|
"emoji",
|
||||||
|
"description",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{"workspace_detail": ["id", "name", "slug"]},
|
||||||
|
],
|
||||||
|
).data,
|
||||||
cls=DjangoJSONEncoder,
|
cls=DjangoJSONEncoder,
|
||||||
)
|
)
|
||||||
res = requests.post(
|
res = requests.post(
|
||||||
|
Loading…
Reference in New Issue
Block a user