def get_course_enrollment_info(course_id, include_expired=False): """Returns all course enrollment information for the given course. Based on the course id, return all related course information. Args: course_id (str): The course to retrieve enrollment information for. include_expired (bool): Boolean denoting whether expired course modes should be included in the returned JSON data. Returns: A serializable dictionary representing the course's enrollment information. Raises: CourseNotFoundError """ course_key = CourseKey.from_string(course_id) try: course = CourseOverview.get_from_id(course_key) except CourseOverview.DoesNotExist: msg = u"Requested enrollment information for unknown course {course}".format(course=course_id) log.warning(msg) raise CourseNotFoundError(msg) else: return CourseSerializer(course, include_expired=include_expired).data
def list(self, request, *args, **kwargs): print(request.user) if request.user.is_authenticated: print(request.session) queryset = self.model.objects.filter(is_active=True) serializer = CourseSerializer(queryset, many=True) response = { 'status': 'success', 'data': serializer.data } return JsonResponse(response) else: error_responsse = {'status': 'fail', 'message': 'You need to Login first'} return JsonResponse(error_responsse)