Revert "core: applications api: add option to only list apps with launch url (#10336)"
This reverts commit 42e0ff6492.
This commit is contained in:
@ -147,13 +147,6 @@ class ApplicationViewSet(UsedByMixin, ModelViewSet):
|
|||||||
applications.append(application)
|
applications.append(application)
|
||||||
return applications
|
return applications
|
||||||
|
|
||||||
def _filter_applications_with_launch_url(self, pagined_apps: Iterator[Application]) -> list[Application]:
|
|
||||||
applications = []
|
|
||||||
for app in pagined_apps:
|
|
||||||
if app.get_launch_url():
|
|
||||||
applications.append(app)
|
|
||||||
return applications
|
|
||||||
|
|
||||||
@extend_schema(
|
@extend_schema(
|
||||||
parameters=[
|
parameters=[
|
||||||
OpenApiParameter(
|
OpenApiParameter(
|
||||||
@ -211,11 +204,6 @@ class ApplicationViewSet(UsedByMixin, ModelViewSet):
|
|||||||
location=OpenApiParameter.QUERY,
|
location=OpenApiParameter.QUERY,
|
||||||
type=OpenApiTypes.INT,
|
type=OpenApiTypes.INT,
|
||||||
),
|
),
|
||||||
OpenApiParameter(
|
|
||||||
name="only_with_launch_url",
|
|
||||||
location=OpenApiParameter.QUERY,
|
|
||||||
type=OpenApiTypes.BOOL,
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def list(self, request: Request) -> Response:
|
def list(self, request: Request) -> Response:
|
||||||
@ -228,8 +216,6 @@ class ApplicationViewSet(UsedByMixin, ModelViewSet):
|
|||||||
if superuser_full_list and request.user.is_superuser:
|
if superuser_full_list and request.user.is_superuser:
|
||||||
return super().list(request)
|
return super().list(request)
|
||||||
|
|
||||||
only_with_launch_url = str(request.query_params.get("only_with_launch_url", "false")).lower()
|
|
||||||
|
|
||||||
queryset = self._filter_queryset_for_list(self.get_queryset())
|
queryset = self._filter_queryset_for_list(self.get_queryset())
|
||||||
paginator: Pagination = self.paginator
|
paginator: Pagination = self.paginator
|
||||||
paginated_apps = paginator.paginate_queryset(queryset, request)
|
paginated_apps = paginator.paginate_queryset(queryset, request)
|
||||||
@ -265,10 +251,6 @@ class ApplicationViewSet(UsedByMixin, ModelViewSet):
|
|||||||
allowed_applications,
|
allowed_applications,
|
||||||
timeout=86400,
|
timeout=86400,
|
||||||
)
|
)
|
||||||
|
|
||||||
if only_with_launch_url == "true":
|
|
||||||
allowed_applications = self._filter_applications_with_launch_url(allowed_applications)
|
|
||||||
|
|
||||||
serializer = self.get_serializer(allowed_applications, many=True)
|
serializer = self.get_serializer(allowed_applications, many=True)
|
||||||
return self.get_paginated_response(serializer.data)
|
return self.get_paginated_response(serializer.data)
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
"""authentik core models"""
|
"""authentik core models"""
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from functools import lru_cache
|
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from typing import Any, Optional, Self
|
from typing import Any, Optional, Self
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@ -476,10 +475,6 @@ class Application(SerializerModel, PolicyBindingModel):
|
|||||||
return self.meta_icon.name
|
return self.meta_icon.name
|
||||||
return self.meta_icon.url
|
return self.meta_icon.url
|
||||||
|
|
||||||
# maxsize is set as 2 since that is called once to check
|
|
||||||
# if we should return applications with a launch URL
|
|
||||||
# and a second time to actually get the launch_url
|
|
||||||
@lru_cache(maxsize=2)
|
|
||||||
def get_launch_url(self, user: Optional["User"] = None) -> str | None:
|
def get_launch_url(self, user: Optional["User"] = None) -> str | None:
|
||||||
"""Get launch URL if set, otherwise attempt to get launch URL based on provider."""
|
"""Get launch URL if set, otherwise attempt to get launch URL based on provider."""
|
||||||
url = None
|
url = None
|
||||||
|
|||||||
@ -2682,10 +2682,6 @@ paths:
|
|||||||
name: name
|
name: name
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
- in: query
|
|
||||||
name: only_with_launch_url
|
|
||||||
schema:
|
|
||||||
type: boolean
|
|
||||||
- name: ordering
|
- name: ordering
|
||||||
required: false
|
required: false
|
||||||
in: query
|
in: query
|
||||||
|
|||||||
@ -70,7 +70,6 @@ export class LibraryPage extends AKElement {
|
|||||||
ordering: "name",
|
ordering: "name",
|
||||||
page,
|
page,
|
||||||
pageSize: 100,
|
pageSize: 100,
|
||||||
onlyWithLaunchUrl: true,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const applicationListFetch = await coreApi().coreApplicationsList(applicationListParams(1));
|
const applicationListFetch = await coreApi().coreApplicationsList(applicationListParams(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user