diff --git a/corporate/lib/registration.py b/corporate/lib/registration.py index 5cc6fcbcdb..ce410a5f45 100644 --- a/corporate/lib/registration.py +++ b/corporate/lib/registration.py @@ -72,7 +72,11 @@ def check_spare_licenses_available_for_adding_new_users( realm: Realm, number_of_users_to_add: int ) -> None: plan = get_current_plan_by_realm(realm) - if plan is None or plan.automanage_licenses or plan.exempt_from_from_license_number_check: + if ( + plan is None + or plan.automanage_licenses + or plan.customer.exempt_from_from_license_number_check + ): return if plan.licenses() < get_latest_seat_count(realm) + number_of_users_to_add: diff --git a/corporate/migrations/0011_move_exempt_from_from_license_number_check_to_customer_model.py b/corporate/migrations/0011_move_exempt_from_from_license_number_check_to_customer_model.py new file mode 100644 index 0000000000..330fed8afe --- /dev/null +++ b/corporate/migrations/0011_move_exempt_from_from_license_number_check_to_customer_model.py @@ -0,0 +1,27 @@ +# Generated by Django 3.2.4 on 2021-06-18 18:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + """ + We haven't set the values for this field for the relevant organizations + as of this moment, so we can simply drop the column from CustomerPlan + and add it to Customer without worrying about losing the values. + """ + + dependencies = [ + ("corporate", "0010_customerplan_exempt_from_from_license_number_check"), + ] + + operations = [ + migrations.RemoveField( + model_name="customerplan", + name="exempt_from_from_license_number_check", + ), + migrations.AddField( + model_name="customer", + name="exempt_from_from_license_number_check", + field=models.BooleanField(default=False), + ), + ] diff --git a/corporate/models.py b/corporate/models.py index e54aa016b4..d90d8ce90b 100644 --- a/corporate/models.py +++ b/corporate/models.py @@ -22,6 +22,9 @@ class Customer(models.Model): default_discount: Optional[Decimal] = models.DecimalField( decimal_places=4, max_digits=7, null=True ) + # Some non-profit organizations on manual license management pay only for their paid employees. + # We don't prevent these organizations from adding more users than the number of licenses they purchased. + exempt_from_from_license_number_check: bool = models.BooleanField(default=False) def __str__(self) -> str: return f"" @@ -45,10 +48,6 @@ class CustomerPlan(models.Model): automanage_licenses: bool = models.BooleanField(default=False) charge_automatically: bool = models.BooleanField(default=False) - # Some non-profit organizations on manual license management pay only for their paid employees. - # We don't prevent these organizations from adding more users than the number of licenses they purchased. - exempt_from_from_license_number_check: bool = models.BooleanField(default=False) - # Both of these are in cents. Exactly one of price_per_license or # fixed_price should be set. fixed_price is only for manual deals, and # can't be set via the self-serve billing system.