Merge pull request #24689 from edx/ndalfonso/AA-283-mobile-reset-dates-endpoint
AA-283 mobile reset dates endpoint
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
"""
|
||||
Serializer for Course Deadlines (Mobile)
|
||||
"""
|
||||
from rest_framework import serializers
|
||||
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
from lms.djangoapps.course_home_api.mixins import DatesBannerSerializerMixin
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
|
||||
|
||||
class CourseDeadlinesMobileSerializer(DatesBannerSerializerMixin):
|
||||
pass
|
||||
has_ended = serializers.SerializerMethodField()
|
||||
|
||||
def get_has_ended(self, _):
|
||||
course_key_string = self.context['view'].kwargs.get('course_key_string')
|
||||
course_key = CourseKey.from_string(course_key_string)
|
||||
course = CourseOverview.get_from_id(course_key)
|
||||
|
||||
return course.has_ended()
|
||||
|
||||
@@ -82,6 +82,7 @@ class CourseDeadlinesMobileView(RetrieveAPIView):
|
||||
def get(self, request, *args, **kwargs):
|
||||
course_key_string = kwargs.get('course_key_string')
|
||||
course_key = CourseKey.from_string(course_key_string)
|
||||
# Although this course data is not used this method will return 404 if course does not exist
|
||||
get_course_with_access(request.user, 'load', course_key)
|
||||
|
||||
serializer = self.get_serializer({})
|
||||
|
||||
Reference in New Issue
Block a user