Skip to content

Commit

Permalink
feat: add TreeView and its endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 3, 2024
1 parent 866fb07 commit 1578003
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/kernelCI/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"""

from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path("admin/", admin.site.urls),
path('api/', include('kernelCI_app.urls')),
]
7 changes: 7 additions & 0 deletions backend/kernelCI_app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from kernelCI_app import views


urlpatterns = [
path('tree/', views.TreeView.as_view(), name='tree')
]
17 changes: 15 additions & 2 deletions backend/kernelCI_app/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# from django.shortcuts import render
from django.http import JsonResponse
from django.views import View

# Create your views here.
from kernelCI_app.models import Checkouts
from kernelCI_app.serializers import TreeSerializer
from kernelCI_app.utils import get_visible_record_ids


class TreeView(View):

def get(self, _):
checkout_ids = get_visible_record_ids('checkouts')
checkouts = Checkouts.objects.filter(id__in=checkout_ids)
serializer = TreeSerializer(checkouts, many=True)

return JsonResponse(serializer.data, safe=False)

0 comments on commit 1578003

Please sign in to comment.