Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
models: Add PreregistrationRealm class.
Sahil Batra7f1bf9d6abf0
diff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex a9cd7d1d242..764ee5a8978 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -134,6 +134,7 @@ ALL_ZULIP_TABLES = {"zerver_missedmessageemailaddress","zerver_multiuseinvite","zerver_multiuseinvite_streams",+ "zerver_preregistrationrealm","zerver_preregistrationuser","zerver_preregistrationuser_streams","zerver_pushdevicetoken",diff --git a/zerver/migrations/0433_preregistrationrealm.py b/zerver/migrations/0433_preregistrationrealm.pynew file mode 100644index 00000000000..ad7aec7289a--- /dev/null+++ b/zerver/migrations/0433_preregistrationrealm.py@@ -0,0 +1,68 @@+# Generated by Django 4.1.7 on 2023-03-07 09:14++import django.db.models.deletion+from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("zerver", "0432_alter_and_migrate_realm_name_in_notifications"),+ ]++ operations = [+ migrations.CreateModel(+ name="PreregistrationRealm",+ fields=[+ (+ "id",+ models.AutoField(+ auto_created=True, primary_key=True, serialize=False, verbose_name="ID"+ ),+ ),+ ("name", models.CharField(max_length=40)),+ (+ "org_type",+ models.PositiveSmallIntegerField(+ choices=[+ (0, "Unspecified"),+ (10, "Business"),+ (20, "Open-source project"),+ (30, "Education (non-profit)"),+ (35, "Education (for-profit)"),+ (40, "Research"),+ (50, "Event or conference"),+ (60, "Non-profit (registered)"),+ (70, "Government"),+ (80, "Political group"),+ (90, "Community"),+ (100, "Personal"),+ (1000, "Other"),+ ],+ default=0,+ ),+ ),+ ("string_id", models.CharField(max_length=40)),+ ("email", models.EmailField(max_length=254)),+ ("status", models.IntegerField(default=0)),+ (+ "created_realm",+ models.ForeignKey(+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to="zerver.realm",+ ),+ ),+ (+ "created_user",+ models.ForeignKey(+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to=settings.AUTH_USER_MODEL,+ ),+ ),+ ],+ ),+ ]diff --git a/zerver/models.py b/zerver/models.pyindex 71c8ab968ab..7396a552e0b 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -2286,6 +2286,42 @@ def remote_user_to_email(remote_user: str) -> str:post_save.connect(flush_user_profile, sender=UserProfile)+class PreregistrationRealm(models.Model):+ """Data on a partially created realm entered by a user who has+ completed the "new organization" form. Used to transfer the user's+ selections from the pre-confirmation "new organization" form to+ the post-confirmation user registration form.++ Note that the values stored here may not match those of the+ created realm (in the event the user creates a realm at all),+ because we allow the user to edit these values in the registration+ form (and in fact the user will be required to do so if the+ `string_id` is claimed by another realm before registraiton is+ completed).+ """++ name = models.CharField(max_length=Realm.MAX_REALM_NAME_LENGTH)+ org_type = models.PositiveSmallIntegerField(+ default=Realm.ORG_TYPES["unspecified"]["id"],+ choices=[(t["id"], t["name"]) for t in Realm.ORG_TYPES.values()],+ )+ string_id = models.CharField(max_length=Realm.MAX_REALM_SUBDOMAIN_LENGTH)+ email = models.EmailField()++ confirmation = GenericRelation("confirmation.Confirmation", related_query_name="prereg_realm")+ status = models.IntegerField(default=0)++ # The Realm created upon completion of the registration+ # for this PregistrationRealm+ created_realm = models.ForeignKey(Realm, null=True, related_name="+", on_delete=models.SET_NULL)++ # The UserProfile created upon completion of the registration+ # for this PregistrationRealm+ created_user = models.ForeignKey(+ UserProfile, null=True, related_name="+", on_delete=models.SET_NULL+ )++class PreregistrationUser(models.Model):# Data on a partially created user, before the completion of# registration. This is used in at least three major code paths: