Skip to content

Commit

Permalink
Merge pull request #581 from openedx/pwnage101/ENT-8269-4
Browse files Browse the repository at this point in the history
fix: make subscription plans editable again
  • Loading branch information
pwnage101 authored Jan 31, 2024
2 parents 430a3e8 + d760d35 commit 9c03ca5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions license_manager/apps/subscriptions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,16 @@ def save_model(self, request, obj, form, change):

super().save_model(request, obj, form, change)

num_new_licenses = obj.desired_num_licenses - obj.num_licenses
if num_new_licenses <= PROVISION_LICENSES_BATCH_SIZE:
# We can handle just one batch synchronously.
SubscriptionPlan.increase_num_licenses(obj, num_new_licenses)
else:
# Multiple batches of licenses will need to be created, so provision them asynchronously.
provision_licenses_task.delay(subscription_plan_uuid=obj.uuid)
# Finally, provision any additional licenses if necessary.
if obj.desired_num_licenses:
license_count_gap = obj.desired_num_licenses - obj.num_licenses
if license_count_gap > 0:
if license_count_gap <= PROVISION_LICENSES_BATCH_SIZE:
# We can handle just one batch synchronously.
SubscriptionPlan.increase_num_licenses(obj, license_count_gap)
else:
# Multiple batches of licenses will need to be created, so provision them asynchronously.
provision_licenses_task.delay(subscription_plan_uuid=obj.uuid)


@admin.register(CustomerAgreement)
Expand Down

0 comments on commit 9c03ca5

Please sign in to comment.