mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
templates: Add realm information fields in create_realm.html.
We now show inputs for realm details like name, type and URL in the create_realm.html template opened for "/new" url and these information will be stored in PreregistrationRealm objects in further commits. We add a new class RealmDetailsForm in forms.py for this such that it is used as a base class for RealmCreationForm and we define RealmDetailsForm such that we can use it as a subclass for RegistrationForm as well to avoid duplication.
This commit is contained in:
@@ -259,10 +259,40 @@ def email_is_not_disposable(email: str) -> None:
|
||||
raise ValidationError(_("Please use your real email address."))
|
||||
|
||||
|
||||
class RealmCreationForm(forms.Form):
|
||||
class RealmDetailsForm(forms.Form):
|
||||
realm_subdomain = forms.CharField(max_length=Realm.MAX_REALM_SUBDOMAIN_LENGTH, required=False)
|
||||
realm_type = forms.TypedChoiceField(
|
||||
coerce=int, choices=[(t["id"], t["name"]) for t in Realm.ORG_TYPES.values()]
|
||||
)
|
||||
realm_name = forms.CharField(max_length=Realm.MAX_REALM_NAME_LENGTH)
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
self.realm_creation = kwargs["realm_creation"]
|
||||
del kwargs["realm_creation"]
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def clean_realm_subdomain(self) -> str:
|
||||
if not self.realm_creation:
|
||||
# This field is only used if realm_creation
|
||||
return ""
|
||||
|
||||
subdomain = self.cleaned_data["realm_subdomain"]
|
||||
if "realm_in_root_domain" in self.data:
|
||||
subdomain = Realm.SUBDOMAIN_FOR_ROOT_DOMAIN
|
||||
|
||||
check_subdomain_available(subdomain)
|
||||
return subdomain
|
||||
|
||||
|
||||
class RealmCreationForm(RealmDetailsForm):
|
||||
# This form determines whether users can create a new realm.
|
||||
email = forms.EmailField(validators=[email_not_system_bot, email_is_not_disposable])
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
kwargs["realm_creation"] = True
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class LoggingSetPasswordForm(SetPasswordForm):
|
||||
new_password1 = forms.CharField(
|
||||
|
||||
Reference in New Issue
Block a user