You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
846 B
27 lines
846 B
|
|
from rest_framework.generics import ListAPIView
|
|
from rest_framework.exceptions import NotFound
|
|
from drf_yasg.utils import swagger_auto_schema
|
|
from drf_yasg import openapi
|
|
|
|
from apps.account.models import StudentUser
|
|
from apps.course.models import Participant, Course
|
|
from apps.account.serializers import UserProfileSerializer
|
|
from apps.course.doc import *
|
|
|
|
|
|
|
|
class CourseParticipantsView(ListAPIView):
|
|
serializer_class = UserProfileSerializer
|
|
|
|
@swagger_auto_schema(
|
|
operation_description=doc_course_participants(),
|
|
)
|
|
def get_queryset(self):
|
|
course_slug = self.kwargs.get('slug')
|
|
try:
|
|
course = Course.objects.get(slug=course_slug)
|
|
except Course.DoesNotExist:
|
|
raise NotFound("Course not found")
|
|
|
|
return StudentUser.objects.filter(participated_courses__course=course)
|