feat: wpr 返回wpr_from_
This commit is contained in:
parent
3e173f7a72
commit
1ffbe0cc44
|
|
@ -1,6 +1,6 @@
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from apps.utils.viewsets import CustomModelViewSet, CustomGenericViewSet
|
from apps.utils.viewsets import CustomModelViewSet, CustomGenericViewSet
|
||||||
from apps.utils.mixins import CustomListModelMixin, RetrieveModelMixin, ComplexQueryMixin
|
from apps.utils.mixins import CustomListModelMixin, CustomRetrieveModelMixin, ComplexQueryMixin
|
||||||
|
|
||||||
from apps.wpmw.models import Wpr, WprDefect
|
from apps.wpmw.models import Wpr, WprDefect
|
||||||
from apps.wpmw.serializers import WprSerializer, WprNewSerializer, WprDetailSerializer, WproutListSerializer, WprChangeNumberSerializer
|
from apps.wpmw.serializers import WprSerializer, WprNewSerializer, WprDetailSerializer, WproutListSerializer, WprChangeNumberSerializer
|
||||||
|
|
@ -13,7 +13,7 @@ from apps.utils.sql import query_one_dict
|
||||||
from django.db.models.expressions import RawSQL
|
from django.db.models.expressions import RawSQL
|
||||||
|
|
||||||
|
|
||||||
class WprViewSet(CustomListModelMixin, RetrieveModelMixin, ComplexQueryMixin, CustomGenericViewSet):
|
class WprViewSet(CustomListModelMixin, CustomRetrieveModelMixin, ComplexQueryMixin, CustomGenericViewSet):
|
||||||
"""动态产品
|
"""动态产品
|
||||||
|
|
||||||
动态产品
|
动态产品
|
||||||
|
|
@ -35,7 +35,7 @@ class WprViewSet(CustomListModelMixin, RetrieveModelMixin, ComplexQueryMixin, Cu
|
||||||
}
|
}
|
||||||
|
|
||||||
def add_info_for_list(self, data):
|
def add_info_for_list(self, data):
|
||||||
parent_ids = [item["wpr_from"] for item in data if item["wpr_from"]]
|
parent_ids = [item["wpr_from"] for item in data if item.get("wpr_from", False)]
|
||||||
if parent_ids:
|
if parent_ids:
|
||||||
parent_data = Wpr.objects.filter(id__in=parent_ids).values("id", "number", "data")
|
parent_data = Wpr.objects.filter(id__in=parent_ids).values("id", "number", "data")
|
||||||
parent_map = {item["id"]: item for item in parent_data}
|
parent_map = {item["id"]: item for item in parent_data}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue