Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
billing: Move exempt_from_from_license_number_check to Customer model.
Mateusz Manderabae86ad3dadf
diff --git a/corporate/lib/registration.py b/corporate/lib/registration.pyindex 5cc6fcbcdb3..ce410a5f45b 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+ ):returnif 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.pynew file mode 100644index 00000000000..330fed8afe0--- /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.pyindex e54aa016b44..d90d8ce90ba 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"<Customer {self.realm} {self.stripe_customer_id}>"@@ -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.