From f36d0691fe7f25eb69f6adef3737c99ae28502e5 Mon Sep 17 00:00:00 2001 From: Dheeraj Kumar Ketireddy Date: Tue, 1 Jul 2025 12:36:27 +0530 Subject: [PATCH] Chore: replace relation choices with TextChoices in IssueRelation model (#7295) --- apiserver/plane/db/models/issue.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apiserver/plane/db/models/issue.py b/apiserver/plane/db/models/issue.py index dad7aab3f..17ec0c60d 100644 --- a/apiserver/plane/db/models/issue.py +++ b/apiserver/plane/db/models/issue.py @@ -271,15 +271,15 @@ class IssueBlocker(ProjectBaseModel): return f"{self.block.name} {self.blocked_by.name}" -class IssueRelation(ProjectBaseModel): - RELATION_CHOICES = ( - ("duplicate", "Duplicate"), - ("relates_to", "Relates To"), - ("blocked_by", "Blocked By"), - ("start_before", "Start Before"), - ("finish_before", "Finish Before"), - ) +class IssueRelationChoices(models.TextChoices): + DUPLICATE = "duplicate", "Duplicate" + RELATES_TO = "relates_to", "Relates To" + BLOCKED_BY = "blocked_by", "Blocked By" + START_BEFORE = "start_before", "Start Before" + FINISH_BEFORE = "finish_before", "Finish Before" + +class IssueRelation(ProjectBaseModel): issue = models.ForeignKey( Issue, related_name="issue_relation", on_delete=models.CASCADE ) @@ -288,9 +288,9 @@ class IssueRelation(ProjectBaseModel): ) relation_type = models.CharField( max_length=20, - choices=RELATION_CHOICES, + choices=IssueRelationChoices.choices, verbose_name="Issue Relation Type", - default="blocked_by", + default=IssueRelationChoices.BLOCKED_BY, ) class Meta: