You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/users/forms.py

65 lines
1.6 KiB

# ~*~ coding: utf-8 ~*~
from django.forms import ModelForm
8 years ago
from django import forms
from captcha.fields import CaptchaField
from django.utils.translation import gettext_lazy as _
8 years ago
from .models import User, UserGroup
class UserLoginForm(forms.Form):
username = forms.CharField(label=_('Username'), max_length=100)
password = forms.CharField(label=_('Password'), widget=forms.PasswordInput, max_length=100)
captcha = CaptchaField()
class UserAddForm(ModelForm):
class Meta:
model = User
fields = [
'username', 'name', 'email', 'groups', 'wechat',
'phone', 'enable_otp', 'role', 'date_expired', 'comment',
]
help_texts = {
'username': '* required',
'email': '* required',
}
widgets = {
'groups': forms.SelectMultiple(attrs={'class': 'select2', 'data-placeholder': _('Join usergroups')}),
}
8 years ago
class UserUpdateForm(ModelForm):
class Meta:
model = User
fields = [
8 years ago
'name', 'email', 'groups', 'wechat',
'phone', 'enable_otp', 'role', 'date_expired', 'comment',
]
help_texts = {
'username': '* required',
'email': '* required',
'groups': '* required'
}
8 years ago
widgets = {
'groups': forms.SelectMultiple(attrs={'class': 'select2', 'data-placeholder': _('Join usergroups')}),
8 years ago
}
class UserGroupForm(ModelForm):
class Meta:
model = UserGroup
8 years ago
fields = [
'name', 'comment',
]
8 years ago
help_texts = {
'name': '* required'
}