forked from enviPath/enviPy
This implements a version of #274, relying on Pydantics built in JSON schema and JSON rendering. Requires additional UI tagging in the ai model repo but will remove HTML tags. Example scenario with filled information: 5882df9c-dae1-4d80-a40e-db4724271456/scenario/3a4d395a-6a6d-4154-8ce3-ced667fceec0 Reviewed-on: enviPath/enviPy#282 Co-authored-by: Tobias O <tobias.olenyi@envipath.com> Co-committed-by: Tobias O <tobias.olenyi@envipath.com>
28 lines
777 B
Python
28 lines
777 B
Python
from django.conf import settings as s
|
|
from ninja import Router
|
|
from ninja_extra.pagination import paginate
|
|
import logging
|
|
|
|
from ..dal import get_user_packages_for_read
|
|
from ..pagination import EnhancedPageNumberPagination
|
|
from ..schemas import PackageOutSchema, SelfReviewStatusFilter
|
|
|
|
router = Router()
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@router.get("/packages/", response=EnhancedPageNumberPagination.Output[PackageOutSchema], auth=None)
|
|
@paginate(
|
|
EnhancedPageNumberPagination,
|
|
page_size=s.API_PAGINATION_DEFAULT_PAGE_SIZE,
|
|
filter_schema=SelfReviewStatusFilter,
|
|
)
|
|
def list_all_packages(request):
|
|
"""
|
|
List packages accessible to the user.
|
|
|
|
"""
|
|
user = request.user
|
|
qs = get_user_packages_for_read(user)
|
|
return qs.order_by("name").all()
|