Files
edx-platform/openedx/features/course_experience/api/v1/serializers.py
Michael Terry 2176dd7890 feat: allow unsubcribing from a course goal with just a token
* Add unsubscribe_token uuid field to CourseGoal model
* Add endpoint to unsubcribe from just a token (no login needed)
* Add admin page for the course_goals djangoapp
* Add get_course_overview_or_404 utility method
* Clean up URL handling in course_home_api

AA-907
2021-08-23 12:07:32 -04:00

22 lines
778 B
Python

"""
Serializer for Course Deadlines (Mobile)
"""
from rest_framework import serializers
from opaque_keys.edx.keys import CourseKey
from lms.djangoapps.course_home_api.serializers import DatesBannerSerializer
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
class CourseDeadlinesMobileSerializer(DatesBannerSerializer):
"""Serializer for course deadlines"""
has_ended = serializers.SerializerMethodField()
def get_has_ended(self, _): # lint-amnesty, pylint: disable=missing-function-docstring
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()