From c4fff45429524c8bf4799bfa73b95c0224685a4f Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Thu, 2 Feb 2023 13:29:17 +0530 Subject: [PATCH] feat: manual ordering for issues in kanban --- apiserver/plane/api/serializers/issue.py | 12 +----------- apiserver/plane/db/models/issue.py | 6 ++---- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/apiserver/plane/api/serializers/issue.py b/apiserver/plane/api/serializers/issue.py index a148cbfb5..3add8f965 100644 --- a/apiserver/plane/api/serializers/issue.py +++ b/apiserver/plane/api/serializers/issue.py @@ -40,12 +40,12 @@ class IssueFlatSerializer(BaseSerializer): "start_date", "target_date", "sequence_id", + "sort_order", ] # Issue Serializer with state details class IssueStateSerializer(BaseSerializer): - state_detail = StateSerializer(read_only=True, source="state") project_detail = ProjectSerializer(read_only=True, source="project") @@ -57,7 +57,6 @@ class IssueStateSerializer(BaseSerializer): ##TODO: Find a better way to write this serializer ## Find a better approach to save manytomany? class IssueCreateSerializer(BaseSerializer): - 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") @@ -176,7 +175,6 @@ class IssueCreateSerializer(BaseSerializer): return issue def update(self, instance, validated_data): - blockers = validated_data.pop("blockers_list", None) assignees = validated_data.pop("assignees_list", None) labels = validated_data.pop("labels_list", None) @@ -254,7 +252,6 @@ class IssueCreateSerializer(BaseSerializer): class IssueActivitySerializer(BaseSerializer): - actor_detail = UserLiteSerializer(read_only=True, source="actor") class Meta: @@ -263,7 +260,6 @@ class IssueActivitySerializer(BaseSerializer): class IssueCommentSerializer(BaseSerializer): - actor_detail = UserLiteSerializer(read_only=True, source="actor") issue_detail = IssueFlatSerializer(read_only=True, source="issue") project_detail = ProjectSerializer(read_only=True, source="project") @@ -319,7 +315,6 @@ class LabelSerializer(BaseSerializer): class IssueLabelSerializer(BaseSerializer): - # label_details = LabelSerializer(read_only=True, source="label") class Meta: @@ -332,7 +327,6 @@ class IssueLabelSerializer(BaseSerializer): class BlockedIssueSerializer(BaseSerializer): - blocked_issue_detail = IssueFlatSerializer(source="block", read_only=True) class Meta: @@ -341,7 +335,6 @@ class BlockedIssueSerializer(BaseSerializer): class BlockerIssueSerializer(BaseSerializer): - blocker_issue_detail = IssueFlatSerializer(source="blocked_by", read_only=True) class Meta: @@ -350,7 +343,6 @@ class BlockerIssueSerializer(BaseSerializer): class IssueAssigneeSerializer(BaseSerializer): - assignee_details = UserLiteSerializer(read_only=True, source="assignee") class Meta: @@ -373,7 +365,6 @@ class CycleBaseSerializer(BaseSerializer): class IssueCycleDetailSerializer(BaseSerializer): - cycle_detail = CycleBaseSerializer(read_only=True, source="cycle") class Meta: @@ -404,7 +395,6 @@ class ModuleBaseSerializer(BaseSerializer): class IssueModuleDetailSerializer(BaseSerializer): - module_detail = ModuleBaseSerializer(read_only=True, source="module") class Meta: diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index c3984b3d2..be9612acf 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -9,6 +9,7 @@ from django.dispatch import receiver from . import ProjectBaseModel from plane.utils.html_processor import strip_tags + # TODO: Handle identifiers for Bulk Inserts - nk class Issue(ProjectBaseModel): PRIORITY_CHOICES = ( @@ -56,6 +57,7 @@ class Issue(ProjectBaseModel): labels = models.ManyToManyField( "db.Label", blank=True, related_name="labels", through="IssueLabel" ) + sort_order = models.FloatField(default=65535) class Meta: verbose_name = "Issue" @@ -246,7 +248,6 @@ class IssueProperty(ProjectBaseModel): class Label(ProjectBaseModel): - parent = models.ForeignKey( "self", on_delete=models.CASCADE, @@ -269,7 +270,6 @@ class Label(ProjectBaseModel): class IssueLabel(ProjectBaseModel): - issue = models.ForeignKey( "db.Issue", on_delete=models.CASCADE, related_name="label_issue" ) @@ -288,7 +288,6 @@ class IssueLabel(ProjectBaseModel): class IssueSequence(ProjectBaseModel): - issue = models.ForeignKey( Issue, on_delete=models.SET_NULL, related_name="issue_sequence", null=True ) @@ -305,7 +304,6 @@ class IssueSequence(ProjectBaseModel): # TODO: Find a better method to save the model @receiver(post_save, sender=Issue) def create_issue_sequence(sender, instance, created, **kwargs): - if created: IssueSequence.objects.create( issue=instance, sequence=instance.sequence_id, project=instance.project