Skip to content

Commit

Permalink
adding endpoint to retreive academy provisioning profile
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavomm19 committed Oct 1, 2024
1 parent 2accedb commit 7317706
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions breathecode/provisioning/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AcademySerializer(serpy.Serializer):
# Use a Field subclass like IntField if you need more validation.
id = serpy.Field()
name = serpy.Field()
slug = serpy.Field()


class ContainerMeSmallSerializer(serpy.Serializer):
Expand Down Expand Up @@ -77,6 +78,12 @@ class GetProvisioningBillSerializer(serpy.Serializer):
title = serpy.Field()


class GetProvisioningProfile(serpy.Serializer):
id = serpy.Field()
vendor = GetProvisioningVendorSerializer(required=False)
academy = AcademySerializer(required=False)


class GetProvisioningConsumptionKindSerializer(serpy.Serializer):
id = serpy.Field()
product_name = serpy.Field()
Expand Down
6 changes: 6 additions & 0 deletions breathecode/provisioning/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .views import (
AcademyProvisioningUserConsumptionView,
AcademyBillView,
ProvisioningProfileView,
UploadView,
redirect_new_container,
redirect_new_container_public,
Expand All @@ -19,6 +20,11 @@
path("academy/userconsumption", AcademyProvisioningUserConsumptionView.as_view(), name="academy_userconsumption"),
path("academy/bill", AcademyBillView.as_view(), name="academy_bill_id"),
path("academy/bill/<int:bill_id>", AcademyBillView.as_view(), name="academy_bill_id"),
path(
"academy/<int:academy_id>/provisioningprofile",
ProvisioningProfileView.as_view(),
name="academy_id_provisioning_profile",
),
path("bill/html", render_html_all_bills, name="bill_html"),
path("bill/<int:id>/html", render_html_bill, name="bill_id_html"),
# path('academy/me/container', ContainerMeView.as_view()),
Expand Down
18 changes: 17 additions & 1 deletion breathecode/provisioning/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ProvisioningBillHTMLSerializer,
ProvisioningBillSerializer,
ProvisioningUserConsumptionHTMLResumeSerializer,
GetProvisioningProfile,
)
from breathecode.utils import capable_of, cut_csv
from breathecode.utils.api_view_extensions.api_view_extensions import APIViewExtensions
Expand All @@ -38,7 +39,7 @@
from breathecode.utils.views import private_view, render_message

from .actions import get_provisioning_vendor
from .models import BILL_STATUS, ProvisioningBill, ProvisioningUserConsumption
from .models import BILL_STATUS, ProvisioningBill, ProvisioningUserConsumption, ProvisioningProfile


@private_view()
Expand Down Expand Up @@ -728,6 +729,21 @@ def put(self, request, bill_id=None, academy_id=None):
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class ProvisioningProfileView(APIView):

extensions = APIViewExtensions(paginate=True)

def get(self, request, academy_id=None):
handler = self.extensions(request)

items = ProvisioningProfile.objects.filter(academy__id=academy_id)

items = handler.queryset(items)
serializer = GetProvisioningProfile(items, many=True)

return handler.response(serializer.data)


# class ContainerMeView(APIView):
# """
# List all snippets, or create a new snippet.
Expand Down

0 comments on commit 7317706

Please sign in to comment.