diff --git a/platform_plugin_aspects/sinks/serializers.py b/platform_plugin_aspects/sinks/serializers.py index a8596d9..ca04686 100644 --- a/platform_plugin_aspects/sinks/serializers.py +++ b/platform_plugin_aspects/sinks/serializers.py @@ -211,7 +211,7 @@ def get_course_key(self, obj): class TagSerializer(BaseSinkSerializer, serializers.ModelSerializer): """Serializer for the Tag model.""" - lineage = serializers.CharField(source="get_lineage") + lineage = serializers.SerializerMethodField() class Meta: """Meta class for the TagSerializer.""" @@ -228,26 +228,14 @@ class Meta: "time_last_dumped", ] - -class TaxonomySerializer(BaseSinkSerializer, serializers.ModelSerializer): - """Serializer for the Taxonomy model.""" - - class Meta: - """Meta class for the TaxonomySerializer.""" - - model = get_model("taxonomy") - fields = [ - "id", - "name", - "dump_id", - "time_last_dumped", - ] + def get_lineage(self, instance): + return json.dumps(instance.get_lineage()) class ObjectTagSerializer(BaseSinkSerializer, serializers.ModelSerializer): """Serializer for the ObjectTag model.""" - lineage = serializers.CharField(source="get_lineage") + lineage = serializers.SerializerMethodField() class Meta: """Meta class for the ObjectTagSerializer""" @@ -264,3 +252,21 @@ class Meta: "dump_id", "time_last_dumped", ] + + def get_lineage(self, instance): + return json.dumps(instance.get_lineage()) + + +class TaxonomySerializer(BaseSinkSerializer, serializers.ModelSerializer): + """Serializer for the Taxonomy model.""" + + class Meta: + """Meta class for the TaxonomySerializer.""" + + model = get_model("taxonomy") + fields = [ + "id", + "name", + "dump_id", + "time_last_dumped", + ]