Skip to content

Commit

Permalink
Merge pull request openedx#32902 from openedx/eahmadjaved/ENT-7373-73…
Browse files Browse the repository at this point in the history
…74-hook

feat: hook for course hasStarted attribute
  • Loading branch information
jajjibhai008 authored Aug 3, 2023
2 parents 5acc4e5 + 962e451 commit 1b9d9bf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lms/djangoapps/learner_home/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.utils import timezone
from opaque_keys.edx.keys import CourseKey
from rest_framework import serializers
from openedx_filters.learning.filters import CourseEnrollmentAPIRenderStarted

from common.djangoapps.course_modes.models import CourseMode
from openedx.features.course_experience import course_home_url
Expand Down Expand Up @@ -244,6 +245,15 @@ def get_isEmailEnabled(self, enrollment):
def get_hasOptedOutOfEmail(self, enrollment):
return enrollment.course_id in self.context.get("course_optouts", [])

def to_representation(self, instance):
"""Serialize the enrollment instance to be able to update the values before the API finishes rendering."""
serialized_enrollment = super().to_representation(instance)
course_key, serialized_enrollment = CourseEnrollmentAPIRenderStarted().run_filter(
course_key=instance.course_id,
serialized_enrollment=serialized_enrollment,
)
return serialized_enrollment


class GradeDataSerializer(serializers.Serializer):
"""Info about grades for this enrollment"""
Expand Down

0 comments on commit 1b9d9bf

Please sign in to comment.