|
17 | 17 | from rest_framework.authentication import TokenAuthentication |
18 | 18 | from rest_framework.decorators import action |
19 | 19 | from rest_framework.permissions import IsAuthenticated |
| 20 | +from rest_framework.response import Response |
20 | 21 | from rest_framework.settings import api_settings |
21 | 22 |
|
22 | 23 | from api.models import Country |
|
79 | 80 | NiceDocumentSerializer, |
80 | 81 | OpsLearningCSVSerializer, |
81 | 82 | OpsLearningInSerializer, |
| 83 | + OpsLearningOrganizationTypeSerializer, |
82 | 84 | OpsLearningSerializer, |
83 | 85 | OpsLearningSummarySerializer, |
84 | 86 | PerAssessmentSerializer, |
@@ -866,6 +868,30 @@ def get_renderer_context(self): |
866 | 868 |
|
867 | 869 | return context |
868 | 870 |
|
| 871 | + @extend_schema( |
| 872 | + request=None, |
| 873 | + filters=False, |
| 874 | + responses=OpsLearningOrganizationTypeSerializer(many=True), |
| 875 | + ) |
| 876 | + @action( |
| 877 | + detail=False, |
| 878 | + methods=["GET"], |
| 879 | + permission_classes=[DenyGuestUserMutationPermission, OpsLearningPermission], |
| 880 | + serializer_class=OpsLearningOrganizationTypeSerializer, |
| 881 | + url_path="organization-type", |
| 882 | + ) |
| 883 | + def organization(self, request): |
| 884 | + """ |
| 885 | + Get the Organization Types |
| 886 | + """ |
| 887 | + queryset = OrganizationTypes.objects.exclude(is_deprecated=True) |
| 888 | + serializer = OpsLearningOrganizationTypeSerializer(queryset, many=True) |
| 889 | + page = self.paginate_queryset(queryset) |
| 890 | + if page is not None: |
| 891 | + serializer = OpsLearningOrganizationTypeSerializer(page, many=True) |
| 892 | + return self.get_paginated_response(serializer.data) |
| 893 | + return Response(serializer.data) |
| 894 | + |
869 | 895 | @extend_schema( |
870 | 896 | request=None, |
871 | 897 | filters=True, |
|
0 commit comments