forked from enviPath/enviPy
27 lines
739 B
Python
27 lines
739 B
Python
from django.conf import settings as s
|
|
from ninja import Router
|
|
from ninja_extra.pagination import paginate
|
|
|
|
from epdb.models import JobLog
|
|
from ..pagination import EnhancedPageNumberPagination
|
|
from ..schemas import JobLogOutSchema
|
|
|
|
router = Router()
|
|
|
|
|
|
@router.get("/joblog/", response=EnhancedPageNumberPagination.Output[JobLogOutSchema])
|
|
@paginate(
|
|
EnhancedPageNumberPagination,
|
|
page_size=s.API_PAGINATION_DEFAULT_PAGE_SIZE,
|
|
)
|
|
def list_all_joblogs(request):
|
|
"""
|
|
List all JobLogs from reviewed packages.
|
|
"""
|
|
current_user = request.user
|
|
|
|
if current_user.is_superuser:
|
|
return JobLog.objects.all().order_by("-created")
|
|
else:
|
|
return JobLog.objects.filter(user=current_user).order_by("-created")
|