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.

53 lines
1.9 KiB

from django import forms
from user.models import Student, Teacher
class StuLoginForm(forms.Form):
uid = forms.CharField(label='学号', max_length=10)
password = forms.CharField(label='密码', max_length=30, widget=forms.PasswordInput)
class TeaLoginForm(forms.Form):
uid = forms.CharField(label='教职工号', max_length=10)
password = forms.CharField(label='密码', max_length=30, widget=forms.PasswordInput)
class StuRegisterForm(forms.ModelForm):
confirm_password = forms.CharField(label='确认密码', widget=forms.PasswordInput())
class Meta:
model = Student
fields = ('grade', 'name', 'password', 'confirm_password', 'gender', 'birthday', 'email', 'info')
def clean(self):
cleaned_data = super(StuRegisterForm, self).clean()
password = cleaned_data.get('password')
confirm_password = cleaned_data.get('confirm_password', 'Password does not match')
if confirm_password != password:
self.add_error('confirm_password', 'Password does not match.')
class TeaRegisterFrom(forms.ModelForm):
confirm_password = forms.CharField(label='确认密码', widget=forms.PasswordInput())
class Meta:
model = Teacher
fields = ('name', 'password', 'confirm_password', 'gender', 'birthday', 'email', 'info')
def clean(self):
cleaned_data = super(TeaRegisterFrom, self).clean()
password = cleaned_data.get('password')
confirm_password = cleaned_data.get('confirm_password', 'Password does not match')
if confirm_password != password:
self.add_error('confirm_password', 'Password does not match.')
class StuUpdateForm(StuRegisterForm):
class Meta:
model = Student
fields = ('grade', 'name', 'password', 'gender', 'birthday', 'email', 'info')
class TeaUpdateForm(StuRegisterForm):
class Meta:
model = Teacher
fields = ('name', 'password', 'gender', 'birthday', 'email', 'info')