Skip to content

Commit

Permalink
fix: serialize lineage data as json
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Aug 29, 2024
1 parent 7580a90 commit f97f0f0
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions platform_plugin_aspects/sinks/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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())

Check failure on line 232 in platform_plugin_aspects/sinks/serializers.py

View workflow job for this annotation

GitHub Actions / tests (ubuntu-24.04, 3.11, django42)

Missing coverage

Missing coverage on line 232


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"""
Expand All @@ -264,3 +252,21 @@ class Meta:
"dump_id",
"time_last_dumped",
]

def get_lineage(self, instance):
return json.dumps(instance.get_lineage())

Check failure on line 257 in platform_plugin_aspects/sinks/serializers.py

View workflow job for this annotation

GitHub Actions / tests (ubuntu-24.04, 3.11, django42)

Missing coverage

Missing coverage on line 257


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",
]

0 comments on commit f97f0f0

Please sign in to comment.