33Handles all REST API endpoints for the application
44"""
55
6+ import logging
67from django .shortcuts import get_object_or_404
78from django .contrib .auth import authenticate
89from django .db .models import Count , Sum , Q
4950 CanManageProjectParticipants , CanUploadProjectProgress
5051)
5152from .filters import ProjectFilter , SchoolFilter , EnvironmentalImpactFilter
52- from rest_framework .permissions import AllowAny
5353from rest_framework import serializers
5454from rest_framework .exceptions import PermissionDenied
5555
56+ logger = logging .getLogger (__name__ )
57+
5658
5759# =============================================================================
5860# AUTHENTICATION & LOGIN VIEWS (Grouped at the top for clarity)
@@ -397,6 +399,15 @@ class ClassViewSet(viewsets.ModelViewSet):
397399 filterset_fields = ['school' ]
398400 search_fields = ['name' ]
399401
402+ @action (detail = False , methods = ['get' ], url_path = 'class-choices' )
403+ def class_choices (self , request ):
404+ """Return available class name choices"""
405+ choices = [
406+ {"value" : choice [0 ], "label" : choice [1 ]}
407+ for choice in Class .ClassName .choices
408+ ]
409+ return Response (choices )
410+
400411
401412# =============================================================================
402413# PROFILE VIEWSETS
@@ -1249,15 +1260,4 @@ def check_school_exists(request):
12491260 })
12501261
12511262
1252- @api_view (['GET' ])
1253- @permission_classes ([permissions .AllowAny ])
1254- def get_class_choices (request ):
1255- """Return available class name choices"""
1256- choices = [
1257- {"value" : choice [0 ], "label" : choice [1 ]}
1258- for choice in Class .ClassName .choices
1259- ]
1260- return Response (choices )
1261-
1262-
12631263from .additional_views import *
0 commit comments