diff --git a/iaso/api/org_unit_types/serializers.py b/iaso/api/org_unit_types/serializers.py index 91e901fcac..3f30e5f2a7 100644 --- a/iaso/api/org_unit_types/serializers.py +++ b/iaso/api/org_unit_types/serializers.py @@ -81,7 +81,9 @@ class Meta: # Fixme make this directly in db ! def get_units_count(self, obj: OrgUnitType): # Show count if it's a detail view OR if with_units_count parameter is present - if self.context.get('view_action') == 'retrieve' or self.context["request"].query_params.get("with_units_count"): + if self.context.get("view_action") == "retrieve" or self.context["request"].query_params.get( + "with_units_count" + ): orgUnits = OrgUnit.objects.filter_for_user_and_app_id( self.context["request"].user, self.context["request"].query_params.get("app_id") ).filter(Q(validated=True) & Q(org_unit_type__id=obj.id)) @@ -189,7 +191,9 @@ class Meta: # Fixme make this directly in db ! def get_units_count(self, obj: OrgUnitType): # Show count if it's a detail view OR if with_units_count parameter is present - if self.context.get('view_action') == 'retrieve' or self.context["request"].query_params.get("with_units_count"): + if self.context.get("view_action") == "retrieve" or self.context["request"].query_params.get( + "with_units_count" + ): orgUnits = OrgUnit.objects.filter_for_user_and_app_id( self.context["request"].user, self.context["request"].query_params.get("app_id") ).filter(Q(validation_status=OrgUnit.VALIDATION_VALID) & Q(org_unit_type__id=obj.id)) @@ -257,7 +261,9 @@ def validate(self, data: typing.Mapping): def to_representation(self, instance): # Remove units_count from fields if not requested - if not self.context.get('view_action') == 'retrieve' and not self.context["request"].query_params.get("with_units_count"): + if not self.context.get("view_action") == "retrieve" and not self.context["request"].query_params.get( + "with_units_count" + ): self.fields.pop("units_count", None) return super().to_representation(instance) diff --git a/iaso/api/org_unit_types/viewsets.py b/iaso/api/org_unit_types/viewsets.py index 30548b6757..be24ae987f 100644 --- a/iaso/api/org_unit_types/viewsets.py +++ b/iaso/api/org_unit_types/viewsets.py @@ -47,7 +47,7 @@ def get_queryset(self): def get_serializer_context(self): context = super().get_serializer_context() - context['view_action'] = self.action + context["view_action"] = self.action return context @@ -109,5 +109,5 @@ def dropdown(self, request, *args): def get_serializer_context(self): context = super().get_serializer_context() - context['view_action'] = self.action + context["view_action"] = self.action return context