Coverage for backend/flowsheetInternals/propertyPackages/viewsets/SimulationObjectPropertyPackageViewSet.py: 53%
17 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-11-06 23:27 +0000
1from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes
2from core.viewset import ModelViewSet
3from rest_framework.response import Response
5from flowsheetInternals.propertyPackages.models.SimulationObjectPropertyPackages import SimulationObjectPropertyPackages
6from flowsheetInternals.propertyPackages.serializers.SimulationObjectPropertyPackageSerializer import SimulationObjectPropertyPackagesSerializer
7class SimulationObjectPropertyPackageViewSet(ModelViewSet):
8 serializer_class = SimulationObjectPropertyPackagesSerializer
10 def get_queryset(self, **kwargs):
11 simulationObjectId = self.request.query_params.get('simulationObject', None)
12 queryset = SimulationObjectPropertyPackages.objects.all()
13 if simulationObjectId is not None:
14 return queryset.filter(simulationObject=simulationObjectId)
15 return queryset
18 @extend_schema(
19 parameters=[
20 OpenApiParameter(name="simulationObject", required=True, type=OpenApiTypes.INT),
21 ]
22 )
23 def list(self, request) -> Response:
24 serializer = SimulationObjectPropertyPackagesSerializer(self.get_queryset(), many=True)
25 return Response(serializer.data)