Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use LearnerLicenseSerializer for auto-apply API #610

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

adamstankiewicz
Copy link
Member

Description

https://2u-internal.atlassian.net/browse/ENT-8563

Makes use of the LearnerLicenseSerializer on the auto-apply API endpoint for consistent data representations between the list of licenses returned by learner-licenses and when a license is auto-applied (e.g., for integrated customers).

The primary difference is that the associated subscription_plan is now returned alongside the license.

{
    "uuid": "00dd289d-694e-49ec-9c63-160938ce6090",
    "status": "activated",
    "userEmail": "[email protected]",
    "activationDate": "2023-10-18T17:40:08.461063Z",
    "lastRemindDate": "2023-10-18T17:40:08.461063Z",
    "subscriptionPlanUuid": "0aa4a80b-5772-4734-b73f-4d26de3326e5",
    "revokedDate": null,
    "activationKey": "503f6607-c2eb-4333-940f-96707669106a",
    "customerAgreement": {
        "uuid": "d5733156-5f3d-439d-bcd5-89cfc3ad2bde",
        "enterpriseCustomerUuid": "02982884-1f1f-4103-b6d7-3a602c1afcbd",
        "enterpriseCustomerSlug": "adam-autoapplied-enterprise",
        "defaultEnterpriseCatalogUuid": null,
        "disableExpirationNotifications": false,
        "netDaysUntilExpiration": 228,
        "subscriptionForAutoAppliedLicenses": "0aa4a80b-5772-4734-b73f-4d26de3326e5"
    },
    "subscriptionPlan": {
        "title": "Test Auto-Applied Subscription",
        "uuid": "0aa4a80b-5772-4734-b73f-4d26de3326e5",
        "startDate": "2023-10-18T16:30:57Z",
        "expirationDate": "2024-10-18T16:30:58Z",
        "enterpriseCustomerUuid": "02982884-1f1f-4103-b6d7-3a602c1afcbd",
        "enterpriseCatalogUuid": "0005bb70-a1c6-4d8e-a801-9a9fa287a13b",
        "isActive": true,
        "isRevocationCapEnabled": false,
        "daysUntilExpiration": 228,
        "daysUntilExpirationIncludingRenewals": 228,
        "isLockedForRenewalProcessing": false,
        "shouldAutoApplyLicenses": true
    }
}

Copy link
Contributor

@iloveagent57 iloveagent57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small suggestion: in _auto_apply_new_license(), could you try changing the license fetch to be

auto_applied_license = subscription_plan.unassigned_licenses.select_related(
    'subscription_plan',
    'subscription_plan__customer_agreement',
).first()

so that LearnerLicenseSerializer doesn't make two more reads to fetch the plan and agreement?

@adamstankiewicz
Copy link
Member Author

small suggestion: in _auto_apply_new_license(), could you try changing the license fetch to be

auto_applied_license = subscription_plan.unassigned_licenses.select_related(
    'subscription_plan',
    'subscription_plan__customer_agreement',
).first()

so that LearnerLicenseSerializer doesn't make two more reads to fetch the plan and agreement?

Good call! Updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants