jumpserver/apps/users/forms.py

58 lines
1.3 KiB
Python
Raw Normal View History

2016-08-14 11:18:41 +00:00
# ~*~ coding: utf-8 ~*~
from django.forms import ModelForm
2016-08-16 14:13:06 +00:00
from django import forms
2016-08-14 11:18:41 +00:00
2016-08-21 14:37:55 +00:00
from .models import User, UserGroup
2016-08-14 11:18:41 +00:00
2016-08-17 14:17:16 +00:00
class UserAddForm(ModelForm):
2016-08-14 11:18:41 +00:00
class Meta:
model = User
fields = [
2016-08-17 14:17:16 +00:00
'username', 'name', 'email', 'groups', 'wechat',
2016-08-20 17:16:30 +00:00
'phone', 'enable_otp', 'role', 'date_expired', 'comment',
2016-08-14 11:18:41 +00:00
]
2016-08-19 16:42:50 +00:00
help_texts = {
'username': '* required',
'email': '* required',
'groups': '* required'
}
widgets = {
2016-08-23 06:44:06 +00:00
'groups': forms.SelectMultiple(attrs={'class': 'select2', 'data-placeholder': '请选择用户组'}),
2016-08-19 16:42:50 +00:00
}
2016-08-16 14:13:06 +00:00
2016-08-17 14:17:16 +00:00
class UserUpdateForm(ModelForm):
class Meta:
model = User
fields = [
2016-08-22 16:39:07 +00:00
'name', 'email', 'groups', 'wechat',
2016-08-20 17:16:30 +00:00
'phone', 'enable_otp', 'role', 'date_expired', 'comment',
2016-08-17 14:17:16 +00:00
]
2016-08-19 16:42:50 +00:00
help_texts = {
'username': '* required',
'email': '* required',
'groups': '* required'
}
2016-08-21 14:37:55 +00:00
widgets = {
'groups': forms.SelectMultiple(attrs={'class': 'select2', 'data-placeholder': '请选择用户组'}),
2016-08-21 14:37:55 +00:00
}
2016-08-18 17:39:08 +00:00
class UserGroupForm(ModelForm):
class Meta:
model = UserGroup
2016-08-21 14:37:55 +00:00
2016-08-18 17:39:08 +00:00
fields = [
'name', 'comment',
]
2016-08-21 14:37:55 +00:00
2016-08-19 16:42:50 +00:00
help_texts = {
'name': '* required'
}