Skip to content

Commit

Permalink
Use pulp's get_url for the namespace link.
Browse files Browse the repository at this point in the history
No-Issue

Signed-off-by: James Tanner <[email protected]>
  • Loading branch information
jctanner committed Sep 11, 2023
1 parent 37b3d67 commit 8567137
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions galaxy_ng/app/api/v1/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from rest_framework import serializers

from pulpcore.plugin.util import get_url

from galaxy_ng.app.models.auth import User
from galaxy_ng.app.api.v1.models import LegacyNamespace
from galaxy_ng.app.api.v1.models import LegacyRole
Expand Down Expand Up @@ -54,10 +56,11 @@ def get_summary_fields(self, obj):
# don't need to query the database to figure it out.
providers = []
if obj.namespace:
pulp_href = get_url(obj.namespace)
providers.append({
'id': obj.namespace.id,
'name': obj.namespace.name,
'pulp_href': f"/api/pulp/api/v3/pulp_ansible/namespaces/{obj.namespace.id}/",
'pulp_href': pulp_href,
})

return {'owners': owners, 'provider_namespaces': providers}
Expand Down Expand Up @@ -243,13 +246,11 @@ def get_summary_fields(self, obj):

provider_ns = None
if obj.namespace and obj.namespace.namespace:
pulp_href = get_url(obj.namespace.namespace)
provider_ns = {
'id': obj.namespace.namespace.id,
'name': obj.namespace.namespace.name,
'pulp_href': (
"/api/pulp/api/v3/pulp_ansible/namespaces/"
+ f"{obj.namespace.namespace.id}/"
)
'pulp_href': pulp_href
}

return {
Expand Down

0 comments on commit 8567137

Please sign in to comment.