fix: return issue detailing in module list response

This commit is contained in:
pablohashescobar 2022-12-22 14:36:55 +05:30
parent 2397559a0e
commit 49fc8caf5a
4 changed files with 61 additions and 3 deletions

View File

@ -22,6 +22,8 @@ from plane.db.models import (
IssueBlocker,
CycleIssue,
Cycle,
Module,
ModuleIssue,
)
@ -342,6 +344,37 @@ class IssueCycleDetailSerializer(BaseSerializer):
]
class ModuleBaseSerializer(BaseSerializer):
class Meta:
model = Module
fields = "__all__"
read_only_fields = [
"workspace",
"project",
"created_by",
"updated_by",
"created_at",
"updated_at",
]
class IssueModuleDetailSerializer(BaseSerializer):
module_detail = ModuleBaseSerializer(read_only=True, source="module")
class Meta:
model = ModuleIssue
fields = "__all__"
read_only_fields = [
"workspace",
"project",
"created_by",
"updated_by",
"created_at",
"updated_at",
]
class IssueSerializer(BaseSerializer):
project_detail = ProjectSerializer(read_only=True, source="project")
state_detail = StateSerializer(read_only=True, source="state")
@ -351,6 +384,7 @@ class IssueSerializer(BaseSerializer):
blocked_issues = BlockedIssueSerializer(read_only=True, many=True)
blocker_issues = BlockerIssueSerializer(read_only=True, many=True)
issue_cycle = IssueCycleDetailSerializer(read_only=True)
issue_module = IssueModuleDetailSerializer(read_only=True)
class Meta:
model = Issue

View File

@ -44,7 +44,7 @@ class ModuleViewSet(BaseViewSet):
.prefetch_related("members")
.prefetch_related(
Prefetch(
"module_issues",
"issue_module",
queryset=ModuleIssue.objects.select_related("module", "issue"),
)
)

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.14 on 2022-12-22 09:06
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('db', '0013_projectmember_default_props'),
]
operations = [
migrations.AlterField(
model_name='moduleissue',
name='issue',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issue_module', to='db.issue'),
),
migrations.AlterField(
model_name='moduleissue',
name='module',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='issue_module', to='db.module'),
),
]

View File

@ -71,10 +71,10 @@ class ModuleMember(ProjectBaseModel):
class ModuleIssue(ProjectBaseModel):
module = models.ForeignKey(
"db.Module", on_delete=models.CASCADE, related_name="module_issues"
"db.Module", on_delete=models.CASCADE, related_name="issue_module"
)
issue = models.ForeignKey(
"db.Issue", on_delete=models.CASCADE, related_name="module_issues"
"db.Issue", on_delete=models.CASCADE, related_name="issue_module"
)
class Meta: