Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# from api.utils import pdf_exporter
from api.tasks import generate_url
from api.utils import CountryValidator, RegionValidator
from deployments.models import EmergencyProject, Personnel, PersonnelDeployment
from deployments.models import EmergencyProject, Personnel, PersonnelDeployment, Sector
from dref.models import Dref, DrefFinalReport, DrefOperationalUpdate
from lang.models import String
from lang.serializers import ModelSerializer
Expand Down Expand Up @@ -2455,11 +2455,10 @@ class SearchSerializer(serializers.Serializer):
reports = SearchReportSerializer(many=True, required=False, allow_null=True)


class ProjectPrimarySectorsSerializer(serializers.Serializer):
key = serializers.IntegerField()
label = serializers.CharField()
color = serializers.CharField()
is_deprecated = serializers.BooleanField()
class ProjectPrimarySectorsSerializer(ModelSerializer):
class Meta:
model = Sector
fields = "__all__"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's define the fields we need



class ProjectSecondarySectorsSerializer(serializers.Serializer):
Expand Down
6 changes: 2 additions & 4 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,10 +587,8 @@ class ProjectPrimarySectors(APIView):
responses=ProjectPrimarySectorsSerializer(many=True),
)
def get(cls, request):
keys_labels = [
{"key": s.id, "label": s.title, "color": s.color, "is_deprecated": s.is_deprecated} for s in Sector.objects.all()
]
return Response(ProjectPrimarySectorsSerializer(keys_labels, many=True).data)
queryset = Sector.objects.filter(is_deprecated=False).all()
return Response(ProjectPrimarySectorsSerializer(queryset, many=True).data)


class ProjectSecondarySectors(APIView):
Expand Down
2 changes: 1 addition & 1 deletion assets
Submodule assets updated 1 files
+25 −6 openapi-schema.yaml
Loading