class RegistroForm(ModelForm): password = forms.CharField(widget=PasswordInput()) confirmar_password = forms.CharField(widget=PasswordInput()) def __init__(self, *args, **kwargs): super(RegistroForm, self).__init__(*args, **kwargs) self.fields['username'].required = True self.fields['username'].max_length = 50 self.fields['username'].error_messages = { 'required': "Este campo es requerido" } class Meta: """Meta definition for Videoform.""" model = User fields = ('first_name', 'last_name', 'username', 'email', 'password') def clean(self): cleaned_data = super(RegistroForm, self).clean() password = cleaned_data.get("password") confirmar_password = cleaned_data.get("confirmar_password") if password != confirmar_password: raise forms.ValidationError( "Las contraseñas no coinciden, deben ser iguales")
class Change(forms.Form): price = forms.DecimalField(required=True) discount = forms.IntegerField(required=True) description = forms.CharField(required=True) short_description = forms.CharField(required=True) is_active = forms.BooleanField(required=True) update = forms.DateField(widget=forms.SelectDateWidget())
class RegisterForm(forms.Form): full_name = forms.CharField(required=True) email = forms.EmailField(required=True) password = forms.CharField(widget=forms.PasswordInput, required=True) password_confirm = forms.CharField(widget=forms.PasswordInput, required=True) def clean_password(self): password = self.cleaned_data.get('password', None) validate_password(password) return password def clean_password_confirm(self): password = self.cleaned_data.get('password_confirm', None) validate_password(password) return password def clean(self): cleaned_data = super(RegisterForm, self).clean() pwd = cleaned_data.get("password") pwdc = cleaned_data.get("password_confirm") email = cleaned_data.get("email") full_name = cleaned_data.get("full_name") if MyUser.objects.filter(email=email).count() != 0: self.add_error('email', _('this user already exists')) if pwd != pwdc: msg = _("Mismatch passwords") self.add_error('password_confirm', msg)
class SearchForm(forms.Form): empty_choices = [('', '')] empty_choices.extend(list(UserProfile.school_choices)) schools = tuple(empty_choices) restrict_school = forms.ChoiceField(required=False, label="School", choices=schools) empty_choices = [('', '')] empty_choices.extend(list(UserProfile.year_choices)) years = tuple(empty_choices) restrict_year = forms.ChoiceField(required=False, label="Year", choices=years) empty_choices = [('', '')] empty_choices.extend(list(UserProfile.major_choices)) majors = tuple(empty_choices) restrict_major = forms.ChoiceField(required=False, label="Major", choices=majors) class_subject = forms.CharField( required=False, label="Course Designation", widget=forms.TextInput(attrs={'style': 'width:160px'})) class_number = forms.CharField(required=False, label="Course Number") class_name = forms.CharField(required=False, label="Course Title")
class NewBlog(ModelForm): title = forms.CharField( max_length=200, required=True, widget=forms.TextInput( attrs={'placeholder': 'Enter Title For the Bog'})) byline = forms.CharField( max_length=400, required=True, widget=forms.TextInput(attrs={'placeholder': 'Enter byline'})) content = forms.CharField( required=False, widget=forms.Textarea(attrs={'placeholder': 'Enter Content'})) class Meta: model = Post exclude = ('slug', 'is_published', 'updated_on', 'created_on', 'publish_on', 'author', 'list_display', 'search_fields', 'list_filter', 'date_hierarchy') def __init__(self, *args, **kwargs): super(NewBlog, self).__init__(*args, **kwargs) self.fields['title'].widget.attrs['class'] = 'input is-medium' self.fields['featured_image'].widget.attrs['id'] = "file" self.fields['byline'].widget.attrs['class'] = 'input is-medium' self.fields['featured_image'].widget.attrs['class'] = 'file-input' self.fields['tags'].widget.attrs['class'] = ' '
class RegistrationForm(forms.Form): username = forms.RegexField( regex=r'^\w+$', widget=forms.TextInput(attrs=dict(required=True, max_length=30)), label=_("Username"), error_messages={ 'invalid': ("This value must contain only letters, numbers and underscores.") }) email = forms.EmailField( widget=forms.TextInput(attrs=dict(required=True, max_length=30)), label=("Email address")) password1 = forms.CharField(widget=forms.PasswordInput( attrs=dict(required=True, max_length=30, render_value=False)), label=("Password")) password2 = forms.CharField(widget=forms.PasswordInput( attrs=dict(required=True, max_length=30, render_value=False)), label=("Password (again)")) def clean_username(self): try: user = User.objects.get( username__iexact=self.cleaned_data['username']) except User.DoesNotExist: return self.cleaned_data['username'] raise forms.ValidationError( _("The username already exists. Please try another one.")) def clean(self): if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data: if self.cleaned_data['password1'] != self.cleaned_data['password2']: raise forms.ValidationError( _("The two password fields did not match.")) return self.cleaned_data
class UserRegistartionForm(forms.ModelForm): username = forms.CharField( max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}), label='Имя пользователя') first_name = forms.CharField( max_length=30, widget=forms.TextInput(attrs={'class': 'form-control'}), label='Имя') last_name = forms.CharField( max_length=40, widget=forms.TextInput(attrs={'class': 'form-control'}), label='Фамилия') email = forms.EmailField( max_length=100, widget=forms.EmailInput(attrs={'class': 'form-control'}), label='Email') password = forms.CharField( max_length=128, strip=False, widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='Пароль') password2 = forms.CharField( max_length=128, strip=False, widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='Повторите пароль') error_messages = { 'password_mismatch': _("The two password fields didn't match."), } class Meta: model = AllUsers fields = ('username', 'email')
class SignupForm(ModelForm): group = forms.ModelChoiceField(queryset=Group.objects.all()) password = forms.CharField(widget=PasswordInput) confirm_password = forms.CharField(widget=PasswordInput) def __init__(self, *args, **kwargs): super(SignupForm, self).__init__(*args, **kwargs) self.fields['first_name'].required = True self.fields['last_name'].required = True self.fields['username'].required = True def clean(self): password1 = self.cleaned_data.get('password') password2 = self.cleaned_data.get('confirm_password') if password1 and password2: if password1 != password2: raise forms.ValidationError("Passwords must be the same") class Meta: model = User fields = [ "first_name", "last_name", "username", "email", "group", "password", "confirm_password" ]
class SignupForm(forms.Form): first_name = forms.CharField( max_length=40, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter First Name' })) last_name = forms.CharField( max_length=40, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter Last Name' })) username = forms.CharField( max_length=40, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter User Name' })) password = forms.CharField( max_length=40, required=True, widget=forms.PasswordInput(attrs={ 'class': 'input', 'placeholder': 'Enter password' }))
class RegistrationForm(forms.Form): # username = forms.CharField(label="",widget=forms.TextInput(attrs={'placeholder': 'Nom d\'utilisateur','class':'form-control input-perso'}),max_length=30,min_length=3,validators=[isValidUsername, validators.validate_slug]) # email = forms.EmailField(label="",widget=forms.EmailInput(attrs={'placeholder': 'Email','class':'form-control input-perso'}),max_length=100,error_messages={'invalid': ("Email invalide.")},validators=[isValidEmail]) password1 = forms.CharField( label="", max_length=50, min_length=6, widget=forms.PasswordInput(attrs={ 'placeholder': 'Mot de passe', 'class': 'form-control input-perso' })) password2 = forms.CharField( label="", max_length=50, min_length=6, widget=forms.PasswordInput( attrs={ 'placeholder': 'Confirmer mot de passe', 'class': 'form-control input-perso' })) def clean(self): password1 = self.cleaned_data.get('password1') password2 = self.cleaned_data.get('password2') if password1 and password1 != password2: self._errors['password2'] = ErrorList( [u"Le mot de passe ne correspond pas."]) return self.cleaned_data
class SignUpForm(forms.Form): first_name = forms.CharField( max_length=15, required=True, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'First Name ' })) last_name = forms.CharField( max_length=15, required=True, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Last Name ' })) username = forms.CharField( max_length=15, required=True, widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'User Nsme' })) password = forms.CharField( max_length=15, required=True, widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'First Name ' }))
class UserForm(forms.ModelForm): username = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่อผู้ใช้ ') password = forms.CharField( widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='รหัสผ่าน ') first_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่อจริง ') last_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='นามสกุล ') email = forms.EmailField( widget=forms.EmailInput(attrs={'class': 'form-control'}), label='อีเมล์ ') class Meta: model = User fields = ['username', 'password', 'email', 'first_name', 'last_name'] help_texts = { 'username': str('Required. 30 characters or fewer. Usernames may contain alphanumeric, _, @, +, . and - characters.<br><br>' ) }
class RegisterForm(forms.Form): username = forms.CharField(min_length=6, max_length=20, validators=[UnicodeUsernameValidator]) email = forms.EmailField(max_length=150) password = forms.CharField(label="密码", min_length=6, max_length=25) repeat_password = forms.CharField(label="确认密码") def clean(self): cleaned_data = super().clean() username = cleaned_data.get("username") password = cleaned_data.get("password") repeat_password = cleaned_data.get("repeat_password") email = cleaned_data.get("email") if not password: raise forms.ValidationError("密码为空") if password != repeat_password: raise forms.ValidationError("两次密码输入不一致") users = Users.objects.filter(Q(username=username) | Q(email=email)).first() if users: if username == users.username: raise forms.ValidationError("用户名已存在") if email == users.email: raise forms.ValidationError("邮箱已被注册")
class ClassForm(forms.Form): class_subject = forms.CharField( required=False, label="Course Designation", widget=forms.TextInput(attrs={'style': 'width:160px'})) class_number = forms.CharField(required=False, label="Course Number") class_name = forms.CharField(required=False, label="Course Title")
class PasswordChangeForm(forms.ModelForm): password = forms.CharField(label="Новый пароль", strip=False, widget=forms.PasswordInput) password_confirm = forms.CharField(label="Подтвердите пароль", widget=forms.PasswordInput, strip=False) old_password = forms.CharField(label="Старый пароль", strip=False, widget=forms.PasswordInput) def clean_password_confirm(self): password = self.cleaned_data.get("password") password_confirm = self.cleaned_data.get("password_confirm") if password and password_confirm and password != password_confirm: raise forms.ValidationError('Пароли не совпадают!') return password_confirm def clean_old_password(self): old_password = self.cleaned_data.get('old_password') if not self.instance.check_password(old_password): raise forms.ValidationError('Старый пароль неправильный!') return old_password def save(self, commit=True): user = self.instance user.set_password(self.cleaned_data["password"]) if commit: user.save() return user class Meta: model = get_user_model() fields = ['password', 'password_confirm', 'old_password']
def __init__(self, *args, **kwargs): super(TenxSequencingForm, self).__init__(*args, **kwargs) if not self.instance.pk: self.fields['jira_user'] = forms.CharField(max_length=100) self.fields['jira_password'] = forms.CharField(widget=forms.PasswordInput) else: self.fields['jira_user'] = forms.CharField(max_length=100, required=False) self.fields['jira_password'] = forms.CharField(widget=forms.PasswordInput, required=False)
class LoginForm(forms.Form): username = forms.CharField(required=True, label="Kullanici Adi veya Email") password = forms.CharField(widget=forms.PasswordInput, required=True, label="Parola") def clean_form(self): return self.cleaned_data
class SignUpForm(UserCreationForm): first_name = forms.CharField(max_length=30, required=False, help_text='Optional.') last_name = forms.CharField(max_length=30, required=False, help_text='Optional.') account_type = forms.CharField(max_length=30, required = False, help_text='Optional.') email = forms.EmailField(max_length=254, help_text='Required. Inform a valid email address.')# class Meta: model = User fields = '__all__'
class Add(forms.Form): Username = forms.CharField(label='Your name', max_length=100,initial=" ") Password=forms.CharField(widget=forms.PasswordInput,label="Password",initial=" ") Email = forms.EmailField(label="Email Id:", initial="",) age=forms.IntegerField(label="Your age") Description=forms.CharField(label="Describe Yourself",widget=forms.Textarea) Profile_Picture = forms.FileField(label="Your Profile Picture:")
def __init__(self, *args, **kwargs): super(TenxLibraryForm, self).__init__(*args, **kwargs) if not self.instance.pk: # Get Jira info self.fields['additional_title'] = forms.CharField(max_length=100) self.fields['jira_user'] = forms.CharField(max_length=100) self.fields['jira_password'] = forms.CharField(widget=forms.PasswordInput, ) # Remove the field which allows explicitly setting the Jira # ticket ID (since it's done automatically) self.fields.pop('jira_ticket')
class LoginForm(forms.Form): username = forms.CharField(min_length=4, max_length=8) password = forms.CharField(min_length=8, max_length=20) captcha = forms.CharField(min_length=4, max_length=4) def clean_username(self): username = self.cleaned_data['username'] if not USERNAME_PATTERN.fullmatch(username): raise ValidationError('无效的用户名') return username def clean_password(self): return to_md5_hex(self.cleaned_data['password'])
class UserRegistrationForm(forms.ModelForm): password = forms.CharField(label='Пароль', widget=forms.PasswordInput) password2 = forms.CharField(label='Еще раз', widget=forms.PasswordInput) class Meta: model = User fields = ('username', 'email') def clean_password2(self): cd = self.cleaned_data if cd['password'] != cd['password2']: raise forms.ValidationError('Passwords don\'t match.') return cd['password2']
class EventRegistrationForm(forms.Form): eventname=forms.CharField(max_length=30,label="eventname",required=True,error_messages={'invalid':'Event Name should be unique'}) description=forms.CharField(max_length=500, label="description", required=True) year=forms.ChoiceField(choices=[('1','1'),('2','2'),('3','3'),('4','4')]) resourceperson=forms.CharField(max_length=30,required = True) res_person_workplace=forms.CharField(max_length=100,required=True) branch=forms.ChoiceField(choices=[('CSE','CSE'),('IT','IT'),('ECE','ECE'),('EEE','EEE')]) section=forms.ChoiceField(choices=[('A','A'),('B','B'),('both','both')]) date=forms.DateField() venue = forms.ModelMultipleChoiceField(queryset=Resources.objects.all(),widget=forms.SelectMultiple) starttime=forms.TimeField() endtime=forms.TimeField()
class EditProfileForm(forms.ModelForm): first_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่อจริง ') last_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='นามสกุล ') email = forms.EmailField( widget=forms.EmailInput(attrs={'class': 'form-control'}), label='อีเมล์ ') class Meta: model = User fields = ['first_name', 'last_name', 'email']
class LoginForm(forms.Form): username = forms.CharField( max_length=50, required=True, widget=forms.TextInput(attrs={ 'class': 'input', 'placeholder': 'Enter Username' })) password = forms.CharField( max_length=50, required=True, widget=forms.PasswordInput(attrs={ 'class': 'input', 'placeholder': 'Enter Password' }))
def __init__(self,*args, **kwargs): super(DlpLibraryForm, self).__init__(*args, **kwargs) if not self.instance.pk: # Get Jira info self.fields['additional_title'] = forms.CharField(max_length=100) self.fields['jira_user'] = forms.CharField(max_length=100) self.fields['jira_password'] = forms.CharField(widget=forms.PasswordInput) # Remove the field which allows explicitly setting the Jira # ticket ID (since it's done automatically) self.fields.pop('jira_ticket') else: uneditable_fields = ['pool_id'] for field in uneditable_fields: self.fields[field].widget.attrs['readonly'] = 'true'
class DeviceProfileForm(forms.ModelForm): owner = forms.ModelChoiceField(queryset=User.objects.all(), widget=forms.HiddenInput(), label='เจ้าของ ') device_id = forms.IntegerField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='รหัสระจำตัวอุปกรณ์ ') device_name = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control'}), label='ชื่ออุปกรณ์ ') openTime = forms.DateTimeField( widget=forms.DateTimeInput(attrs={'class': 'form-control'}), initial=(timezone.make_aware(datetime.datetime.now(), timezone.get_default_timezone())), label='เวลาเปิดอุปกรณ์ ', required=False) closeTime = forms.DateTimeField( widget=forms.DateTimeInput(attrs={'class': 'form-control'}), initial=(timezone.make_aware(datetime.datetime.now(), timezone.get_default_timezone())), label='เวลาปิดอุปกรณ์ ', required=False) class Meta: model = DeviceProfile fields = ('owner', 'device_id', 'device_name', 'openTime', 'closeTime')
class StudentsInformationForm(forms.Form): fullname = forms.CharField(max_length=64, required=True) options = [('Masters', 'Masters'), ('Graduation', 'Graduation'), ('UnderGraduate', 'Under Graduate')] qualification = forms.ChoiceField(widget=forms.RadioSelect(), choices=options, required=True) university = forms.CharField(max_length=32, required=True) phonenumber = forms.CharField(max_length=12, required=True) country = forms.CharField(max_length=32, required=True) def clean_phonenumber(self): if (self.cleaned_data['phonenumber'].__len__() < 10): raise forms.ValidationError("Invalid Phone Number") else: return self.cleaned_data['phonenumber']
class PasswordForm(forms.Form): client_password = forms.CharField( max_length=32, widget=forms.PasswordInput(attrs={ "name": "password", "class": "w3-input w3-border" }))
class NewItemForm(ModelForm): class Meta: model = Item fields = [ 'item_name', 'image', 'min_bid', 'categories', ] # Extra fields: item_description = forms.CharField(widget=forms.Textarea, max_length=4000) owner = None is_active = True date = None def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def clean(self): item_name = self.cleaned_data['item_name'] if (len(item_name) < 3): raise forms.ValidationError( message="Item name must contain at least three characters") item_description = self.cleaned_data['item_description'] min_bid = self.cleaned_data['min_bid'] if min_bid < 1.0: raise forms.ValidationError( message="Min bid must be at least USD 1")