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>
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from django.conf import settings as s
|
|
from ninja import Router
|
|
from ninja_extra.pagination import paginate
|
|
from uuid import UUID
|
|
|
|
from epdb.models import Pathway
|
|
from ..pagination import EnhancedPageNumberPagination
|
|
from ..schemas import PathwayOutSchema, ReviewStatusFilter
|
|
from ..dal import get_user_entities_for_read, get_package_entities_for_read
|
|
|
|
router = Router()
|
|
|
|
|
|
@router.get("/pathways/", response=EnhancedPageNumberPagination.Output[PathwayOutSchema])
|
|
@paginate(
|
|
EnhancedPageNumberPagination,
|
|
page_size=s.API_PAGINATION_DEFAULT_PAGE_SIZE,
|
|
filter_schema=ReviewStatusFilter,
|
|
)
|
|
def list_all_pathways(request):
|
|
"""
|
|
List all pathways from reviewed packages.
|
|
"""
|
|
user = request.user
|
|
return get_user_entities_for_read(Pathway, user).order_by("name").all()
|
|
|
|
|
|
@router.get(
|
|
"/package/{uuid:package_uuid}/pathway/",
|
|
response=EnhancedPageNumberPagination.Output[PathwayOutSchema],
|
|
)
|
|
@paginate(
|
|
EnhancedPageNumberPagination,
|
|
page_size=s.API_PAGINATION_DEFAULT_PAGE_SIZE,
|
|
filter_schema=ReviewStatusFilter,
|
|
)
|
|
def list_package_pathways(request, package_uuid: UUID):
|
|
"""
|
|
List all pathways for a specific package.
|
|
"""
|
|
user = request.user
|
|
return get_package_entities_for_read(Pathway, package_uuid, user).order_by("name").all()
|