Skip to content

Commit

Permalink
fix(api): add relation types to schema
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Jun 4, 2024
1 parent 922ec44 commit d9cb009
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apis_ontology/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ class Meta:
class SicprodSerializer(GenericHyperlinkedModelSerializer):
def get_fields(self):
fields = super().get_fields()
fields["relation_types"] = serializers.SerializerMethodField(method_name="get_relation_types")
if self.context["view"].action == "retrieve":
fields["relation_types"] = serializers.SerializerMethodField(method_name="get_relation_types")
fields["references"] = serializers.SerializerMethodField(method_name="get_references")
return fields

def get_relation_types(self, obj):
def get_relation_types(self, obj) -> list[str]:
forward_relations = TempTriple.objects.filter(subj=obj).prefetch_related("subj", "obj")
reverse_relations = TempTriple.objects.filter(obj=obj).prefetch_related("subj", "obj")
relations = set()
Expand Down

0 comments on commit d9cb009

Please sign in to comment.