Skip to content

Commit

Permalink
feat: manual ordering for issues in kanban
Browse files Browse the repository at this point in the history
  • Loading branch information
pablohashescobar committed Feb 2, 2023
1 parent 7e92efe commit c4fff45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
12 changes: 1 addition & 11 deletions apiserver/plane/api/serializers/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class Meta:
"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")

Expand All @@ -57,7 +57,6 @@ class Meta:
##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")
Expand Down Expand Up @@ -176,7 +175,6 @@ def create(self, validated_data):
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)
Expand Down Expand Up @@ -254,7 +252,6 @@ def update(self, instance, validated_data):


class IssueActivitySerializer(BaseSerializer):

actor_detail = UserLiteSerializer(read_only=True, source="actor")

class Meta:
Expand All @@ -263,7 +260,6 @@ class Meta:


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")
Expand Down Expand Up @@ -319,7 +315,6 @@ class Meta:


class IssueLabelSerializer(BaseSerializer):

# label_details = LabelSerializer(read_only=True, source="label")

class Meta:
Expand All @@ -332,7 +327,6 @@ class Meta:


class BlockedIssueSerializer(BaseSerializer):

blocked_issue_detail = IssueFlatSerializer(source="block", read_only=True)

class Meta:
Expand All @@ -341,7 +335,6 @@ class Meta:


class BlockerIssueSerializer(BaseSerializer):

blocker_issue_detail = IssueFlatSerializer(source="blocked_by", read_only=True)

class Meta:
Expand All @@ -350,7 +343,6 @@ class Meta:


class IssueAssigneeSerializer(BaseSerializer):

assignee_details = UserLiteSerializer(read_only=True, source="assignee")

class Meta:
Expand All @@ -373,7 +365,6 @@ class Meta:


class IssueCycleDetailSerializer(BaseSerializer):

cycle_detail = CycleBaseSerializer(read_only=True, source="cycle")

class Meta:
Expand Down Expand Up @@ -404,7 +395,6 @@ class Meta:


class IssueModuleDetailSerializer(BaseSerializer):

module_detail = ModuleBaseSerializer(read_only=True, source="module")

class Meta:
Expand Down
6 changes: 2 additions & 4 deletions apiserver/plane/db/models/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from . import ProjectBaseModel
from plane.utils.html_processor import strip_tags


# TODO: Handle identifiers for Bulk Inserts - nk
class Issue(ProjectBaseModel):
PRIORITY_CHOICES = (
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -246,7 +248,6 @@ def __str__(self):


class Label(ProjectBaseModel):

parent = models.ForeignKey(
"self",
on_delete=models.CASCADE,
Expand All @@ -269,7 +270,6 @@ def __str__(self):


class IssueLabel(ProjectBaseModel):

issue = models.ForeignKey(
"db.Issue", on_delete=models.CASCADE, related_name="label_issue"
)
Expand All @@ -288,7 +288,6 @@ def __str__(self):


class IssueSequence(ProjectBaseModel):

issue = models.ForeignKey(
Issue, on_delete=models.SET_NULL, related_name="issue_sequence", null=True
)
Expand All @@ -305,7 +304,6 @@ class Meta:
# 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
Expand Down

0 comments on commit c4fff45

Please sign in to comment.