Skip to content

Commit

Permalink
add aliases to asset detail
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavomm19 committed Oct 16, 2024
1 parent 290f333 commit 78f9746
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions breathecode/registry/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ class AssetBigAndTechnologyPublishedSerializer(AssetBigSerializer):

technologies = serpy.MethodField()
translations = serpy.MethodField()
aliases = serpy.MethodField()

def get_translations(self, obj):
result = {}
Expand All @@ -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):

Expand Down
3 changes: 3 additions & 0 deletions breathecode/registry/tests/urls/v1/tests_academy_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions breathecode/registry/tests/urls/v1/tests_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 78f9746

Please sign in to comment.