mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
corporate: Adjust models for RemoteRealm customers.
This commit is contained in:
37
corporate/migrations/0020_add_remote_realm_customers.py
Normal file
37
corporate/migrations/0020_add_remote_realm_customers.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 4.2.7 on 2023-11-17 20:11
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("zilencer", "0035_remoterealmcount_remote_realm_and_more"),
|
||||||
|
("corporate", "0019_zulipsponsorshiprequest_expected_total_users_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveConstraint(
|
||||||
|
model_name="customer",
|
||||||
|
name="cloud_xor_self_hosted",
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="customer",
|
||||||
|
name="remote_realm",
|
||||||
|
field=models.OneToOneField(
|
||||||
|
null=True, on_delete=django.db.models.deletion.CASCADE, to="zilencer.remoterealm"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="customer",
|
||||||
|
constraint=models.CheckConstraint(
|
||||||
|
check=models.Q(
|
||||||
|
("realm__isnull", False),
|
||||||
|
("remote_server__isnull", False),
|
||||||
|
("remote_realm__isnull", False),
|
||||||
|
_connector="OR",
|
||||||
|
),
|
||||||
|
name="has_associated_model_object",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -17,8 +17,12 @@ class Customer(models.Model):
|
|||||||
and the active plan, if any.
|
and the active plan, if any.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# The actual model object that this customer is associated
|
||||||
|
# with. Exactly one of the following will be non-null.
|
||||||
realm = models.OneToOneField(Realm, on_delete=CASCADE, null=True)
|
realm = models.OneToOneField(Realm, on_delete=CASCADE, null=True)
|
||||||
|
remote_realm = models.OneToOneField(RemoteRealm, on_delete=CASCADE, null=True)
|
||||||
remote_server = models.OneToOneField(RemoteZulipServer, on_delete=CASCADE, null=True)
|
remote_server = models.OneToOneField(RemoteZulipServer, on_delete=CASCADE, null=True)
|
||||||
|
|
||||||
stripe_customer_id = models.CharField(max_length=255, null=True, unique=True)
|
stripe_customer_id = models.CharField(max_length=255, null=True, unique=True)
|
||||||
sponsorship_pending = models.BooleanField(default=False)
|
sponsorship_pending = models.BooleanField(default=False)
|
||||||
# A percentage, like 85.
|
# A percentage, like 85.
|
||||||
@@ -30,10 +34,13 @@ class Customer(models.Model):
|
|||||||
exempt_from_license_number_check = models.BooleanField(default=False)
|
exempt_from_license_number_check = models.BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
# Enforce that at least one of these is set.
|
||||||
constraints = [
|
constraints = [
|
||||||
models.CheckConstraint(
|
models.CheckConstraint(
|
||||||
check=Q(realm__isnull=False) ^ Q(remote_server__isnull=False),
|
check=Q(realm__isnull=False)
|
||||||
name="cloud_xor_self_hosted",
|
| Q(remote_server__isnull=False)
|
||||||
|
| Q(remote_realm__isnull=False),
|
||||||
|
name="has_associated_model_object",
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user