Skip to content

Commit

Permalink
add count to TagSerializer
Browse files Browse the repository at this point in the history
fixes: pulp#1612
  • Loading branch information
jerabekjiri committed Oct 18, 2023
1 parent 5aae92e commit 6db31c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/1612.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display the ``count`` attribute in the tags of collections.
7 changes: 6 additions & 1 deletion pulp_ansible/app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,14 @@ class TagSerializer(serializers.ModelSerializer):
A serializer for the Tag model.
"""

count = serializers.SerializerMethodField()

def get_count(self, obj):
return obj.ansible_collectionversion.count()

class Meta:
model = Tag
fields = ["name"]
fields = ["name", "count"]


class TagNestedSerializer(ModelSerializer):
Expand Down

0 comments on commit 6db31c4

Please sign in to comment.