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