Skip to content

Commit

Permalink
Add option to enhanced package data in API
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
  • Loading branch information
TG1999 committed Aug 2, 2023
1 parent 802ef95 commit d8155cb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packagedb/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ class Meta:


class PackageAPISerializer(HyperlinkedModelSerializer):

def to_representation(self, instance):
data = super().to_representation(instance)
request = self.context["request"]
if hasattr(request, "query_params") and request.query_params.get("enhanced", False):
from packagedb.api import get_enhanced_package
data["enhanced_package"] = get_enhanced_package(instance)
return data

dependencies = DependentPackageSerializer(many=True)
parties = PartySerializer(many=True)
resources = HyperlinkedIdentityField(view_name='api:package-resources', lookup_field='uuid')
Expand Down

0 comments on commit d8155cb

Please sign in to comment.