diff --git a/apis_ontology/api/serializers.py b/apis_ontology/api/serializers.py index 9386bff..b5d00d9 100644 --- a/apis_ontology/api/serializers.py +++ b/apis_ontology/api/serializers.py @@ -44,7 +44,10 @@ class PlaceDataSerializerMin(serializers.ModelSerializer): class Meta: model = Place - exclude = ["self_contenttype", "data_source"] + exclude = [ + "self_contenttype", + "data_source", + ] class PlaceDataSerializer(PlaceDataSerializerMin): @@ -145,7 +148,10 @@ class ArchiveDataSerializer(serializers.ModelSerializer): class Meta: model = Archive - exclude = ["self_contenttype", "data_source"] + exclude = [ + "self_contenttype", + "data_source", + ] class PhysicalObjectDataSerializer(serializers.ModelSerializer): @@ -153,13 +159,19 @@ class PhysicalObjectDataSerializer(serializers.ModelSerializer): class Meta: model = PhysicalObject - exclude = ["self_contenttype", "data_source"] + exclude = [ + "self_contenttype", + "data_source", + ] class TopicDataSerializer(serializers.ModelSerializer): class Meta: model = Topic - exclude = ["self_contenttype", "data_source"] + exclude = [ + "self_contenttype", + "data_source", + ] class PersonDataSerializer(serializers.ModelSerializer): @@ -170,7 +182,10 @@ class PersonDataSerializer(serializers.ModelSerializer): class Meta: model = Person - exclude = ["self_contenttype", "data_source"] + exclude = [ + "self_contenttype", + "data_source", + ] class WorkDetailSerializer(serializers.ModelSerializer): @@ -180,24 +195,44 @@ class WorkDetailSerializer(serializers.ModelSerializer): ) related_works = serializers.SerializerMethodField() characters = CharacterDataSerializer( - required=False, allow_empty=True, many=True, source="character_data" + source="character_data", + required=False, + allow_empty=True, + many=True, ) physical_objects = PhysicalObjectDataSerializer( - required=False, allow_empty=True, many=True, source="related_physical_objects" + source="related_physical_objects", + required=False, + allow_empty=True, + many=True, ) topics = TopicDataSerializer( - required=False, allow_empty=True, many=True, source="related_topics" + source="related_topics", + required=False, + allow_empty=True, + many=True, ) persons = PersonDataSerializer( - required=False, allow_empty=True, many=True, source="related_persons" + source="related_persons", + required=False, + allow_empty=True, + many=True, ) places = PlaceDataSerializer( - required=False, allow_empty=True, many=True, source="related_places" + source="related_places", + required=False, + allow_empty=True, + many=True, ) class Meta: model = Work - exclude = ["self_contenttype", "data_source", "notes", "progress_status"] + exclude = [ + "self_contenttype", + "data_source", + "notes", + "progress_status", + ] def get_related_works(self, obj) -> list[RelatedWorksDict]: return list(obj.forward_work_relations) + list(obj.reverse_work_relations) diff --git a/apis_ontology/api/views.py b/apis_ontology/api/views.py index 5249601..f6a232d 100644 --- a/apis_ontology/api/views.py +++ b/apis_ontology/api/views.py @@ -95,7 +95,11 @@ def get_schema_operation_parameters(self, view): "in": "query", "description": "The initial index from which to return the results.", "required": False, - "schema": {"type": "integer", "default": 0, "minimum": 0}, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0, + }, }, ] return params @@ -137,7 +141,12 @@ def get_paginated_response_schema(self, schema): }, }, }, - "example": [{"key": "eng", "count": 100}], + "example": [ + { + "key": "eng", + "count": 100, + } + ], }, "topic": { "type": "array", @@ -155,7 +164,12 @@ def get_paginated_response_schema(self, schema): }, }, }, - "example": [{"key": "Traum", "count": 3}], + "example": [ + { + "key": "Traum", + "count": 3, + } + ], }, }, "type": "object", @@ -272,6 +286,7 @@ def get_queryset(self): Q(root_object_id=OuterRef("pk")), ~Q(uri__startswith="https://frischmuth-dev.acdh-dev.oeaw.ac.at"), ).values_list("uri", flat=True) + work_types = WorkType.objects.filter( triple_set_from_obj__subj_id=OuterRef("pk"), triple_set_from_obj__prop__name_forward__in=["has type"], @@ -285,7 +300,12 @@ def get_queryset(self): expression_publisher = Organisation.objects.filter( triple_set_from_subj__obj_id=OuterRef("pk"), triple_set_from_subj__prop__name_reverse__in=["has publisher"], - ).values(json=JSONObject(id="id", name="name")) + ).values( + json=JSONObject( + id="id", + name="name", + ) + ) related_places = ( Place.objects.all()