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-25 11:29:59 +00:00
|
|
|
# class UserLoginForm(ModelForm):
|
|
|
|
# class Meta:
|
|
|
|
# model = User
|
|
|
|
# fields = [
|
|
|
|
# "email", "password"
|
|
|
|
# ]
|
|
|
|
|
|
|
|
|
|
|
|
class UserLoginForm(forms.Form):
|
|
|
|
username = forms.CharField(label='用户名', max_length=100)
|
|
|
|
password = forms.CharField(label='密码', widget=forms.PasswordInput, max_length=100)
|
|
|
|
|
|
|
|
|
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',
|
|
|
|
}
|
|
|
|
|
|
|
|
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 = {
|
2016-08-23 09:14:08 +00:00
|
|
|
'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'
|
|
|
|
}
|