mirror of https://github.com/zulip/zulip.git
models: Add PreregistrationRealm class.
This commit adds PreregistrationRealm class which will be similar to PreregistrationUser and will store initial information of the realm before its creation as we are changing the organization creation flow as per #24307. Fixes part of #24307.
This commit is contained in:
parent
1874491178
commit
7f1bf9d6ab
|
@ -134,6 +134,7 @@ ALL_ZULIP_TABLES = {
|
||||||
"zerver_missedmessageemailaddress",
|
"zerver_missedmessageemailaddress",
|
||||||
"zerver_multiuseinvite",
|
"zerver_multiuseinvite",
|
||||||
"zerver_multiuseinvite_streams",
|
"zerver_multiuseinvite_streams",
|
||||||
|
"zerver_preregistrationrealm",
|
||||||
"zerver_preregistrationuser",
|
"zerver_preregistrationuser",
|
||||||
"zerver_preregistrationuser_streams",
|
"zerver_preregistrationuser_streams",
|
||||||
"zerver_pushdevicetoken",
|
"zerver_pushdevicetoken",
|
||||||
|
|
|
@ -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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
|
@ -2286,6 +2286,42 @@ def remote_user_to_email(remote_user: str) -> str:
|
||||||
post_save.connect(flush_user_profile, sender=UserProfile)
|
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):
|
class PreregistrationUser(models.Model):
|
||||||
# Data on a partially created user, before the completion of
|
# Data on a partially created user, before the completion of
|
||||||
# registration. This is used in at least three major code paths:
|
# registration. This is used in at least three major code paths:
|
||||||
|
|
Loading…
Reference in New Issue