From 78f9746380e71e8cbb38e2d28a27c2fb2beb142b Mon Sep 17 00:00:00 2001 From: gustavomm19 Date: Wed, 16 Oct 2024 10:36:06 +0000 Subject: [PATCH] add aliases to asset detail --- breathecode/registry/serializers.py | 8 ++++++++ breathecode/registry/tests/urls/v1/tests_academy_asset.py | 3 +++ breathecode/registry/tests/urls/v1/tests_asset.py | 1 + 3 files changed, 12 insertions(+) diff --git a/breathecode/registry/serializers.py b/breathecode/registry/serializers.py index eaf0cfbcf..e3f9429f2 100644 --- a/breathecode/registry/serializers.py +++ b/breathecode/registry/serializers.py @@ -405,6 +405,7 @@ class AssetBigAndTechnologyPublishedSerializer(AssetBigSerializer): technologies = serpy.MethodField() translations = serpy.MethodField() + aliases = serpy.MethodField() def get_translations(self, obj): result = {} @@ -418,6 +419,13 @@ def get_technologies(self, obj): ) return ParentAssetTechnologySerializer(techs, many=True).data + def get_aliases(self, obj): + aliases = [] + items = AssetAlias.objects.filter(asset=obj) + for item in items: + aliases.append(item.slug) + return aliases + class AssetExpandableSerializer(AssetMidSerializer): diff --git a/breathecode/registry/tests/urls/v1/tests_academy_asset.py b/breathecode/registry/tests/urls/v1/tests_academy_asset.py index d54b39375..66e2c2498 100644 --- a/breathecode/registry/tests/urls/v1/tests_academy_asset.py +++ b/breathecode/registry/tests/urls/v1/tests_academy_asset.py @@ -72,6 +72,8 @@ def database_item(academy, category, data={}): "is_auto_subscribed": True, "superseded_by_id": None, "enable_table_of_content": True, + "agent": None, + "learnpack_deploy_url": None, **data, } @@ -125,6 +127,7 @@ def post_serializer(academy, category, data={}): "with_video": False, "superseded_by": None, "enable_table_of_content": True, + "agent": None, "updated_at": UTC_NOW.isoformat().replace("+00:00", "Z"), **data, } diff --git a/breathecode/registry/tests/urls/v1/tests_asset.py b/breathecode/registry/tests/urls/v1/tests_asset.py index 4805cc93c..93cb9797b 100644 --- a/breathecode/registry/tests/urls/v1/tests_asset.py +++ b/breathecode/registry/tests/urls/v1/tests_asset.py @@ -95,6 +95,7 @@ def get_serializer_technology(technology, data={}): def get_mid_serializer(asset, data={}): return { **get_serializer(asset), + "agent": asset.agent, "with_solutions": asset.with_solutions, "with_video": asset.with_solutions, "updated_at": asset.updated_at,