Files
edx-platform/common/djangoapps/entitlements/api/v1/serializers.py
Michael LoTurco 2807d9915e Add enrollment_course_run to entitlementserializer
The marketing site currently cannot use the entitlement
api to determine whether a user has an unfilled entitlement.
Including the entitlement enrollment_course_run makes this
information accessible to consumers of the entitlement API.

Learner-3731
2018-01-03 11:28:53 -05:00

27 lines
741 B
Python

from django.contrib.auth import get_user_model
from rest_framework import serializers
from entitlements.models import CourseEntitlement
class CourseEntitlementSerializer(serializers.ModelSerializer):
user = serializers.SlugRelatedField(slug_field='username', queryset=get_user_model().objects.all())
enrollment_course_run = serializers.CharField(
source='enrollment_course_run.course_id',
read_only=True
)
class Meta:
model = CourseEntitlement
fields = (
'user',
'uuid',
'course_uuid',
'enrollment_course_run',
'expired_at',
'created',
'modified',
'mode',
'order_number'
)