mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
Override help text for AbstractUser
This commit is contained in:
parent
98dbca3983
commit
f5116315e8
1 changed files with 29 additions and 0 deletions
|
@ -48,6 +48,35 @@ class MyUserAdminForm(UserChangeForm):
|
||||||
"user_permissions": NoAutocompleteFilteredSelectMultiple("user_permissions", False),
|
"user_permissions": NoAutocompleteFilteredSelectMultiple("user_permissions", False),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
"""Custom init to modify the user form"""
|
||||||
|
super(MyUserAdminForm, self).__init__(*args, **kwargs)
|
||||||
|
self.override_base_help_texts()
|
||||||
|
|
||||||
|
def override_base_help_texts(self):
|
||||||
|
"""
|
||||||
|
Used to override pre-existing help texts in AbstractUser.
|
||||||
|
This is done to avoid modifying the base AbstractUser class.
|
||||||
|
"""
|
||||||
|
is_superuser = self.fields.get("is_superuser")
|
||||||
|
is_staff = self.fields.get("is_staff")
|
||||||
|
password = self.fields.get("password")
|
||||||
|
|
||||||
|
if is_superuser is not None:
|
||||||
|
is_superuser.help_text = (
|
||||||
|
"For development purposes only; provides superuser access on the database level."
|
||||||
|
)
|
||||||
|
|
||||||
|
if is_staff is not None:
|
||||||
|
is_staff.help_text = "Designates whether the user can log in to this admin site."
|
||||||
|
|
||||||
|
if password is not None:
|
||||||
|
link = f"../../{self.instance.pk}/password/"
|
||||||
|
password.help_text = (
|
||||||
|
"Raw passwords are not stored, so they will not display here. "
|
||||||
|
f'You can change the password using <a href="{link}">this form</a>.'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DomainInformationAdminForm(forms.ModelForm):
|
class DomainInformationAdminForm(forms.ModelForm):
|
||||||
"""This form utilizes the custom widget for its class's ManyToMany UIs."""
|
"""This form utilizes the custom widget for its class's ManyToMany UIs."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue