mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	billing: Allow to exclude realms from license limit check.
This commit is contained in:
		@@ -71,12 +71,10 @@ def send_user_unable_to_signup_message_to_signup_notification_stream(
 | 
				
			|||||||
def check_spare_licenses_available_for_adding_new_users(
 | 
					def check_spare_licenses_available_for_adding_new_users(
 | 
				
			||||||
    realm: Realm, number_of_users_to_add: int
 | 
					    realm: Realm, number_of_users_to_add: int
 | 
				
			||||||
) -> None:
 | 
					) -> None:
 | 
				
			||||||
    if realm.string_id in settings.LICENSE_CHECK_EXEMPTED_REALMS_ON_MANUAL_PLAN:
 | 
					 | 
				
			||||||
        return  # nocoverage
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    plan = get_current_plan_by_realm(realm)
 | 
					    plan = get_current_plan_by_realm(realm)
 | 
				
			||||||
    if plan is None or plan.automanage_licenses:
 | 
					    if plan is None or plan.automanage_licenses or plan.exempt_from_from_license_number_check:
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if plan.licenses() < get_latest_seat_count(realm) + number_of_users_to_add:
 | 
					    if plan.licenses() < get_latest_seat_count(realm) + number_of_users_to_add:
 | 
				
			||||||
        raise LicenseLimitError()
 | 
					        raise LicenseLimitError()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,18 @@
 | 
				
			|||||||
 | 
					# Generated by Django 3.2.2 on 2021-06-08 08:57
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.db import migrations, models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Migration(migrations.Migration):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dependencies = [
 | 
				
			||||||
 | 
					        ("corporate", "0009_customer_sponsorship_pending"),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operations = [
 | 
				
			||||||
 | 
					        migrations.AddField(
 | 
				
			||||||
 | 
					            model_name="customerplan",
 | 
				
			||||||
 | 
					            name="exempt_from_from_license_number_check",
 | 
				
			||||||
 | 
					            field=models.BooleanField(default=False),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
@@ -45,6 +45,10 @@ class CustomerPlan(models.Model):
 | 
				
			|||||||
    automanage_licenses: bool = models.BooleanField(default=False)
 | 
					    automanage_licenses: bool = models.BooleanField(default=False)
 | 
				
			||||||
    charge_automatically: 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
 | 
					    # 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
 | 
					    # fixed_price should be set. fixed_price is only for manual deals, and
 | 
				
			||||||
    # can't be set via the self-serve billing system.
 | 
					    # can't be set via the self-serve billing system.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user