1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-07-31 12:41:08 +00:00

add change other user password ability to superusers

This commit is contained in:
catborise 2020-07-23 13:16:39 +03:00
parent fb3ef6be98
commit de63d9746d
4 changed files with 41 additions and 2 deletions

View file

@ -1,5 +1,8 @@
from django import forms
from django.contrib.auth.models import Group, User
from django.contrib.auth.forms import ReadOnlyPasswordHashField
from django.urls import reverse_lazy
from django.utils.text import format_lazy
from django.utils.translation import ugettext_lazy as _
from accounts.models import UserAttributes
@ -68,6 +71,16 @@ class UserForm(forms.ModelForm):
'is_superuser',
]
def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
password = ReadOnlyPasswordHashField(label=_("Password"),
help_text=format_lazy(_("""Raw passwords are not stored, so there is no way to see
this user's password, but you can change the password
using <a href='{}'>this form</a>."""),
reverse_lazy('admin:user_update_password', args=[self.instance.id,]))
)
self.fields['Password'] = password
class UserCreateForm(UserForm):
password = forms.CharField(widget=forms.PasswordInput)