feat: add extra columns as a response to create and update on issue and issue comments

This commit is contained in:
pablohashescobar 2022-12-16 03:13:30 +05:30
parent bf71be1f75
commit 1d08f01682

View File

@ -7,6 +7,7 @@ from .user import UserLiteSerializer
from .state import StateSerializer from .state import StateSerializer
from .user import UserLiteSerializer from .user import UserLiteSerializer
from .project import ProjectSerializer from .project import ProjectSerializer
from .workspace import WorkSpaceSerializer
from plane.db.models import ( from plane.db.models import (
User, User,
Issue, Issue,
@ -19,8 +20,8 @@ from plane.db.models import (
IssueLabel, IssueLabel,
Label, Label,
IssueBlocker, IssueBlocker,
Cycle,
CycleIssue, CycleIssue,
Cycle,
) )
@ -54,6 +55,9 @@ class IssueStateSerializer(BaseSerializer):
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 = UserLiteSerializer(read_only=True, source="created_by")
project_detail = ProjectSerializer(read_only=True, source="project")
workspace_detail = WorkSpaceSerializer(read_only=True, source="workspace")
assignees_list = serializers.ListField( assignees_list = serializers.ListField(
child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()), child=serializers.PrimaryKeyRelatedField(queryset=User.objects.all()),
@ -213,6 +217,8 @@ class IssueActivitySerializer(BaseSerializer):
class IssueCommentSerializer(BaseSerializer): class IssueCommentSerializer(BaseSerializer):
actor_detail = UserLiteSerializer(read_only=True, source="actor") actor_detail = UserLiteSerializer(read_only=True, source="actor")
issue_detail = IssueFlatSerializer(read_only=True, source="issue")
project_detail = ProjectSerializer(read_only=True, source="project")
class Meta: class Meta:
model = IssueComment model = IssueComment
@ -305,7 +311,6 @@ class IssueAssigneeSerializer(BaseSerializer):
class CycleBaseSerializer(BaseSerializer): class CycleBaseSerializer(BaseSerializer):
class Meta: class Meta:
model = Cycle model = Cycle
fields = "__all__" fields = "__all__"
@ -318,6 +323,7 @@ class CycleBaseSerializer(BaseSerializer):
"updated_at", "updated_at",
] ]
class IssueCycleDetailSerializer(BaseSerializer): class IssueCycleDetailSerializer(BaseSerializer):
cycle_detail = CycleBaseSerializer(read_only=True, source="cycle") cycle_detail = CycleBaseSerializer(read_only=True, source="cycle")
@ -335,7 +341,6 @@ class IssueCycleDetailSerializer(BaseSerializer):
] ]
class IssueSerializer(BaseSerializer): class IssueSerializer(BaseSerializer):
project_detail = ProjectSerializer(read_only=True, source="project") project_detail = ProjectSerializer(read_only=True, source="project")
state_detail = StateSerializer(read_only=True, source="state") state_detail = StateSerializer(read_only=True, source="state")