Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 search add parent #1394

Merged
merged 2 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions api/v1/views/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from arkid.core.extension import Extension
from arkid.core.schema import ResponseSchema
from arkid.extension.utils import import_extension, restart_celery
from arkid.extension.models import TenantExtensionConfig, Extension as ExtensionModel
from arkid.extension.models import TenantExtensionConfig, ArkStoreCategory ,Extension as ExtensionModel
from arkid.core.error import ErrorCode, ErrorDict, SuccessDict
from ninja.pagination import paginate
from oauth2_provider.models import Application
Expand Down Expand Up @@ -127,7 +127,12 @@ def list_extensions(request, query_data: ExtensionListQueryIn=Query(...)):

category_id = query_data.category_id
if category_id and category_id != "" and category_id != "0":
qs = qs.filter(category_id=int(category_id))
arkstorecategory = ArkStoreCategory.valid_objects.filter(
arkstore_id=int(category_id)
).first()
if arkstorecategory:
item_category_ids = arkstorecategory.get_all_child([])
qs = qs.filter(category_id__in=item_category_ids)

if settings.IS_CENTRAL_ARKID:
return qs
Expand Down
16 changes: 13 additions & 3 deletions api/v1/views/tenant_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from arkid.core import actions
from arkid.core.extension import Extension
from arkid.core.models import Tenant
from arkid.extension.models import TenantExtensionConfig, TenantExtension, Extension as ExtensionModel
from arkid.extension.models import ArkStoreCategory, TenantExtensionConfig, TenantExtension, Extension as ExtensionModel
from arkid.core.translation import gettext_default as _
from arkid.core.pagenation import CustomPagination
from ninja.pagination import paginate
Expand Down Expand Up @@ -229,7 +229,12 @@ def get_platform_extensions(request, tenant_id: str, category_id: str = None):
tenant = Tenant.objects.get(id=tenant_id)
extensions = ExtensionModel.active_objects.filter()
if category_id and category_id != "" and category_id != "0":
extensions = extensions.filter(category_id=int(category_id))
arkstorecategory = ArkStoreCategory.valid_objects.filter(
arkstore_id=int(category_id)
).first()
if arkstorecategory:
item_category_ids = arkstorecategory.get_all_child([])
extensions = extensions.filter(category_id__in=item_category_ids)
if settings.IS_CENTRAL_ARKID:
return extensions

Expand Down Expand Up @@ -278,7 +283,12 @@ def get_tenant_extensions(request, tenant_id: str, query_data: TenantExtensionLi
extensions = extensions.filter(package__icontains=query_data.package)

if category_id and category_id != "" and category_id != "0":
extensions = extensions.filter(category_id=int(category_id))
arkstorecategory = ArkStoreCategory.valid_objects.filter(
arkstore_id=int(category_id)
).first()
if arkstorecategory:
item_category_ids = arkstorecategory.get_all_child([])
extensions = extensions.filter(category_id__in=item_category_ids)

# 使用TenantExtension的is_active覆盖ExtensionModel的is_active
extension_ids = TenantExtension.valid_objects.filter(tenant_id=tenant_id, is_active=True).values('extension_id')
Expand Down