Skip to content

Commit

Permalink
Use related_services instead of service_reference
Browse files Browse the repository at this point in the history
  • Loading branch information
mhieta committed Sep 28, 2023
1 parent a6423b5 commit d50d146
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion services/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,19 @@ def to_representation(self, obj):
if "parent" in only_fields:
ret["parent"] = obj.parent_id
ret["root"] = self.root_service_nodes(obj)
ret["related_services"] = (
[int(service) for service in obj.service_reference.split(",")]
if obj.service_reference
else []
)
return ret

def root_service_nodes(self, obj):
return next(root_service_nodes([obj], MobilityServiceNode))

class Meta:
model = MobilityServiceNode
fields = "__all__"
exclude = ("service_reference",)


class ServiceSerializer(TranslatedModelSerializer, JSONAPISerializer):
Expand Down

0 comments on commit d50d146

Please sign in to comment.