mirror of https://github.com/jumpserver/jumpserver
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.
57 lines
1.3 KiB
57 lines
1.3 KiB
# ~*~ coding: utf-8 ~*~
|
|
|
|
from django.forms import ModelForm
|
|
from django import forms
|
|
|
|
from .models import User, UserGroup
|
|
|
|
|
|
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': '请选择用户组'}),
|
|
}
|
|
|
|
|
|
class UserUpdateForm(ModelForm):
|
|
class Meta:
|
|
model = User
|
|
fields = [
|
|
'name', 'email', 'groups', 'wechat',
|
|
'phone', 'enable_otp', 'role', 'date_expired', 'comment',
|
|
]
|
|
|
|
help_texts = {
|
|
'username': '* required',
|
|
'email': '* required',
|
|
'groups': '* required'
|
|
}
|
|
|
|
widgets = {
|
|
'groups': forms.SelectMultiple(attrs={'class': 'select2', 'data-placeholder': '请选择用户组'}),
|
|
}
|
|
|
|
|
|
class UserGroupForm(ModelForm):
|
|
class Meta:
|
|
model = UserGroup
|
|
|
|
fields = [
|
|
'name', 'comment',
|
|
]
|
|
|
|
help_texts = {
|
|
'name': '* required'
|
|
}
|