diff --git a/license_manager/apps/api/serializers.py b/license_manager/apps/api/serializers.py index da060282..f2d35f22 100644 --- a/license_manager/apps/api/serializers.py +++ b/license_manager/apps/api/serializers.py @@ -148,6 +148,7 @@ class LicenseSerializer(serializers.ModelSerializer): """ subscription_plan_uuid = serializers.UUIDField(source='subscription_plan_id') + customer_agreement = CustomerAgreementSerializer(source='subscription_plan.customer_agreement') class Meta: model = License @@ -160,6 +161,7 @@ class Meta: 'subscription_plan_uuid', 'revoked_date', 'activation_key', + 'customer_agreement' ] diff --git a/license_manager/apps/api/v1/tests/test_views.py b/license_manager/apps/api/v1/tests/test_views.py index cd4e3e34..4480b891 100644 --- a/license_manager/apps/api/v1/tests/test_views.py +++ b/license_manager/apps/api/v1/tests/test_views.py @@ -26,6 +26,7 @@ from rest_framework import status from rest_framework.test import APIClient +from license_manager.apps.api.serializers import CustomerAgreementSerializer from license_manager.apps.api.tests.factories import BulkEnrollmentJobFactory from license_manager.apps.api.utils import ( acquire_subscription_plan_lock, @@ -335,6 +336,7 @@ def _assert_license_response_correct(response, subscription_license): 'revoked_date', 'activation_key', 'activation_date', + 'customer_agreement' } assert set(response.keys()) == expected_fields assert response['uuid'] == str(subscription_license.uuid) @@ -344,6 +346,9 @@ def _assert_license_response_correct(response, subscription_license): assert response['activation_key'] == str(subscription_license.activation_key) assert response['activation_date'] == _iso_8601_format(subscription_license.activation_date) assert response['last_remind_date'] == _iso_8601_format(subscription_license.last_remind_date) + assert response['customer_agreement'] == CustomerAgreementSerializer( + subscription_license.subscription_plan.customer_agreement + ).data @pytest.mark.django_db diff --git a/license_manager/apps/api/v1/views.py b/license_manager/apps/api/v1/views.py index f10ec41b..475152af 100644 --- a/license_manager/apps/api/v1/views.py +++ b/license_manager/apps/api/v1/views.py @@ -401,6 +401,7 @@ class LearnerLicensesViewSet( } ] } + customer_agreement: user_email: "edx@example.com" uuid: "4e03efb7-b4ea-4a52-9cfc-11519920a40a" ]