diff --git a/license_manager/apps/api/serializers.py b/license_manager/apps/api/serializers.py index f2d35f22..8e607290 100644 --- a/license_manager/apps/api/serializers.py +++ b/license_manager/apps/api/serializers.py @@ -101,6 +101,24 @@ def get_revocations(self, obj): } +class MinimalCustomerAgreementSerializer(serializers.ModelSerializer): + """ + Minimal serializer for the `CustomerAgreement` model that does not + include information about related subscription plan records. + """ + + class Meta: + model = CustomerAgreement + fields = [ + 'uuid', + 'enterprise_customer_uuid', + 'enterprise_customer_slug', + 'default_enterprise_catalog_uuid', + 'disable_expiration_notifications', + 'net_days_until_expiration', + ] + + class CustomerAgreementSerializer(serializers.ModelSerializer): """ Serializer for the `CustomerAgreement` model. @@ -148,7 +166,7 @@ class LicenseSerializer(serializers.ModelSerializer): """ subscription_plan_uuid = serializers.UUIDField(source='subscription_plan_id') - customer_agreement = CustomerAgreementSerializer(source='subscription_plan.customer_agreement') + customer_agreement = MinimalCustomerAgreementSerializer(source='subscription_plan.customer_agreement') class Meta: model = License diff --git a/license_manager/apps/api/v1/tests/test_views.py b/license_manager/apps/api/v1/tests/test_views.py index 4480b891..5fa77852 100644 --- a/license_manager/apps/api/v1/tests/test_views.py +++ b/license_manager/apps/api/v1/tests/test_views.py @@ -26,7 +26,9 @@ from rest_framework import status from rest_framework.test import APIClient -from license_manager.apps.api.serializers import CustomerAgreementSerializer +from license_manager.apps.api.serializers import ( + MinimalCustomerAgreementSerializer, +) from license_manager.apps.api.tests.factories import BulkEnrollmentJobFactory from license_manager.apps.api.utils import ( acquire_subscription_plan_lock, @@ -346,7 +348,7 @@ 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( + assert response['customer_agreement'] == MinimalCustomerAgreementSerializer( subscription_license.subscription_plan.customer_agreement ).data