Skip to content

Commit

Permalink
package api fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakdinesh1123 committed Sep 3, 2024
1 parent b2f2027 commit e1b0def
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/zango/api/platform/packages/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get(self, request, app_uuid, *args, **kwargs):
status = 500
return get_api_response(True if status == 200 else False, resp, status)
try:
packages = get_all_packages(tenant.name)
packages = get_all_packages(request, tenant)
if search:
packages = [
obj for obj in packages if search.lower() in obj["name"].lower()
Expand Down
18 changes: 16 additions & 2 deletions backend/src/zango/core/package_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
import requests
import shutil
import subprocess
import zipfile
Expand All @@ -12,6 +13,8 @@

from django.conf import settings
from django.db import connection
from django.core import signing
from django.template.response import ContentNotRenderedError

from zango.core.utils import get_current_request_url

Expand All @@ -29,10 +32,10 @@ def get_installed_packages(tenant):
return {package["name"]: package["version"] for package in packages}


def get_all_packages(tenant=None):
def get_all_packages(request, tenant=None):
installed_packages = {}
if tenant is not None:
installed_packages = get_installed_packages(tenant)
installed_packages = get_installed_packages(tenant.name)
packages = {}
s3 = boto3.client(
"s3",
Expand Down Expand Up @@ -77,6 +80,17 @@ def get_all_packages(tenant=None):
"installed_version": installed_packages[local_package],
}
)
for package in resp_data:
try:
url = get_package_configuration_url(
request, tenant, package["name"]
)
resp = requests.get(url)
package["config_url"] = f"{url}?token={signing.dumps(request.user.id)}"
except TypeError:
package["config_url"] = None
except ContentNotRenderedError:
package["config_url"] = f"{url}?token={signing.dumps(request.user.id)}"
return resp_data


Expand Down

0 comments on commit e1b0def

Please sign in to comment.