2021-09-29 21:31:40 +02:00
|
|
|
from django.contrib.auth.forms import UserChangeForm
|
|
|
|
from django.urls import reverse
|
|
|
|
from django_registration.forms import RegistrationFormUniqueEmail
|
2021-09-05 22:04:14 +02:00
|
|
|
|
|
|
|
from users.models import TenantUser
|
|
|
|
|
|
|
|
|
2021-09-29 21:31:40 +02:00
|
|
|
class CustomRegistrationForm(RegistrationFormUniqueEmail):
|
|
|
|
class Meta(RegistrationFormUniqueEmail.Meta):
|
2021-09-05 22:04:14 +02:00
|
|
|
model = TenantUser
|
|
|
|
fields = [
|
|
|
|
"name",
|
|
|
|
"email",
|
|
|
|
"password1",
|
|
|
|
"password2",
|
|
|
|
]
|
2021-09-29 21:31:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
class CustomUserChangeForm(UserChangeForm):
|
|
|
|
class Meta(UserChangeForm.Meta):
|
|
|
|
model = TenantUser
|
|
|
|
fields = [
|
|
|
|
"name",
|
|
|
|
"password",
|
|
|
|
"email",
|
|
|
|
"last_login"
|
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
password = self.fields.get('password')
|
|
|
|
print(password.help_text)
|
|
|
|
password.help_text = password.help_text.replace("../password/", reverse("password_change"))
|
|
|
|
print(password.help_text)
|
|
|
|
self.fields['email'].disabled = True
|
|
|
|
self.fields['last_login'].disabled = True
|