mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 23:02:19 +00:00
Added default values to form
This commit is contained in:
@@ -30,10 +30,14 @@ def UserServiceAccountForm(user):
|
|||||||
""" Generate a Service Account form based on the user's permissions """
|
""" Generate a Service Account form based on the user's permissions """
|
||||||
|
|
||||||
services = Service.objects.filter(groups__in=user.groups.all())
|
services = Service.objects.filter(groups__in=user.groups.all())
|
||||||
|
defaultuser = user.username
|
||||||
|
defaultpasswd = user.get_profile().default_service_passwd
|
||||||
|
|
||||||
class ServiceAccountForm(forms.Form):
|
class ServiceAccountForm(forms.Form):
|
||||||
service = forms.ModelChoiceField(queryset=services)
|
service = forms.ModelChoiceField(queryset=services)
|
||||||
username = ServiceUsernameField(min_length=4,max_length=50)
|
username = ServiceUsernameField(min_length=4,max_length=50)
|
||||||
password = forms.CharField(label = u'Password',widget = forms.PasswordInput(render_value=False))
|
password = forms.CharField(label = u'Password',widget = forms.PasswordInput(render_value=False))
|
||||||
|
|
||||||
|
default_data = { 'username': defaultuser, 'password': defaultpasswd }
|
||||||
|
|
||||||
return ServiceAccountForm
|
return ServiceAccountForm
|
||||||
|
|||||||
Reference in New Issue
Block a user