class EditProfile(UserChangeForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['bio'].required = False self.fields['name'].required = False name = forms.CharField(label='تغییر نام', widget=forms.TextInput(attrs={ 'class': 'form-control', 'dir': 'rtl', })) email = forms.EmailField(label='تغییر ایمیل', widget=forms.EmailInput(attrs={ 'class': 'form-control', })) bio = forms.CharField( label='تغییر بیو', widget=forms.Textarea(attrs={ 'rows': 1, 'cols': 15, 'class': 'form-control', 'dir': 'rtl', })) avatar = forms.ImageField(label='تغییر عکس') class Meta: model = get_user_model() fields = ('email', 'name', 'bio', 'avatar', 'password')
class UserCreationForm(BaseUserCreationForm): password1 = forms.CharField(label='گذرواژه', widget=forms.PasswordInput) password2 = forms.CharField(label='تکرار گذرواژه', widget=forms.PasswordInput) name = forms.CharField(label='نام کامل', widget=forms.TextInput(attrs={ 'class': 'form-control', 'dir': 'rtl', })) email = forms.EmailField(label='ایمیل', widget=forms.EmailInput(attrs={ 'class': 'form-control', })) class Meta: model = get_user_model() fields = ('email', 'name') def clean_password2(self): password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError("Passwords don't match") return password2 def save(self, commit=True): """ Save the user in the database""" user = super().save(commit=False) user.set_password(self.cleaned_data['password1']) if commit: user.save() return user
class EditProfile(UserChangeForm): name = forms.CharField(label='تغییر نام', widget=forms.TextInput(attrs={ 'class': 'form-control', 'dir': 'rtl', })) email = forms.EmailField(label='تغییر ایمیل', widget=forms.EmailInput(attrs={ 'class': 'form-control', })) bio = forms.CharField(label='تغییر بیو', widget=forms.Textarea( attrs={ 'rows': 1, 'cols': 15, 'autofocus': 'autofocus', 'class': 'form-control', 'dir': 'rtl', })) avatar = forms.ImageField(label='تغییر عکس') class Meta: model = User fields = ('email', 'name', 'bio', 'avatar', 'password')
def __init__(self, *args, **kwargs): super(SignUpForm, self).__init__(*args, **kwargs) self.fields['username'].widget = forms.TextInput( attrs={ 'class': 'utf-with-border', 'placeholder': 'Username' }) self.fields['email'].widget = forms.EmailInput(attrs={ 'class': 'utf-with-border', 'placeholder': 'Email' }) self.fields['password1'].widget = forms.PasswordInput( attrs={ 'class': 'utf-with-border', 'name': 'password1', 'placeholder': 'Password' }) self.fields['password2'].widget = forms.PasswordInput( attrs={ 'class': 'utf-with-border', 'name': 'password2', 'placeholder': 'Repeat Password' })
class Meta(UserCreationForm): model = User email = forms.EmailField() fields = ('email', 'first_name', 'last_name') widgets = { 'first_name': forms.TextInput(attrs={ 'class': 'form-control', 'required': 'required' }), 'last_name': forms.TextInput(attrs={ 'class': 'form-control', 'required': 'required' }), 'email': forms.EmailInput(attrs={ 'class': 'form-control', 'required': 'required' }), 'password1': forms.PasswordInput(attrs={'class': 'form-control'}), 'password2': forms.PasswordInput(attrs={'class': 'form-control'}), }
class FormLogin(forms.Form): email_login = forms.CharField( widget=forms.EmailInput(attrs={'class': 'form-control'}), label='Usuario') password_login = forms.CharField( widget=forms.PasswordInput(attrs={'class': 'form-control'}), label='Contraseña')
class SignUpForm(UserCreationForm): email = forms.CharField(max_length=255, required=True, widget=forms.EmailInput()) class Meta: model = User fields = ['username', 'email', 'password1', 'password2']
class Meta: model = User fields = ('email', 'first_name', 'last_name') widgets = { 'email': forms.EmailInput(attrs={'class': 'form-control'}), 'first_name': forms.TextInput(attrs={'class': 'form-control'}), 'last_name': forms.TextInput(attrs={'class': 'form-control'}), }
class PasswordResetCustomForm(PasswordResetForm): """ Standard pass reset form but with validation """ email = forms.EmailField( label="Email", max_length=254, widget=forms.EmailInput(attrs={'autocomplete': 'email'}), validators=[no_user_by_email_validator])
class loginForm(ModelForm): usernameL = forms.EmailField(label="Correo electrónico", widget=forms.EmailInput()) passwordL = forms.CharField(label="Contraseña", widget=forms.PasswordInput()) class Meta: model = User fields = ['usernameL', 'passwordL']
class AuthenticationForm(forms.Form): password = forms.CharField(widget=forms.PasswordInput, label='گذرواژه') email = forms.EmailField( label='ایمیل', widget=forms.EmailInput(attrs={'class': 'form-control'})) class Meta: model = get_user_model() fields = ('email', 'password')
class UpdateUserForm(forms.ModelForm): email = forms.CharField(widget=forms.EmailInput( attrs={'class': 'utf-submit-field'})) username = forms.CharField(widget=forms.TextInput( attrs={'class': 'utf-submit-field'})) first_name = forms.CharField(widget=forms.TextInput( attrs={'class': 'utf-submit-field'})) last_name = forms.CharField(widget=forms.TextInput( attrs={'class': 'utf-submit-field'})) class Meta: model = get_user_model() fields = ['email', 'first_name', 'last_name', 'username']
class ResetPasswordForm(forms.Form): email = forms.EmailField( label="Email", max_length=150, widget=forms.EmailInput(attrs={'placeholder': 'Email'})) def clean(self, *args, **kwargs): email = self.cleaned_data.get("email") if not User.objects.filter(email=email).exists(): raise forms.ValidationError("This Email isn't Found") return super(ResetPasswordForm, self).clean(*args, **kwargs)
class UserForm(ModelForm): username = forms.CharField(label="Usuario", max_length=50) first_name = forms.CharField(label="Nombres", max_length=50) last_name = forms.CharField(label="Apellidos", max_length=50) email = forms.EmailField(label="Correo electrónico", widget=forms.EmailInput()) password = forms.CharField(label="Contraseña", widget=forms.PasswordInput()) password2 = forms.CharField(label="Confirmación de contraseña", widget=forms.PasswordInput()) class Meta: model = User fields = [ 'username', 'first_name', 'last_name', 'email', 'password', 'password2' ] # verificacion correo unico def clean_username(self): username = self.cleaned_data['username'] if User.objects.filter(username=username): raise forms.ValidationError('Correo ya ha sido registrado') return username # verificacion las contraseñas coinciden y seguridad def clean_password2(self): password = self.cleaned_data['password'] password2 = self.cleaned_data['password2'] if password != password2: raise forms.ValidationError('Contraseñas no coinciden') try: password_validation.validate_password(password2) except password_validation.ValidationError as errores: mensajes = [] for m in errores.messages: if m == 'This password is too short. It must contain at least 8 characters.': mensajes.append( 'Contraseña muy corta, debe contener más de 7 caracteres' ) if m == 'This password is too common.': mensajes.append('Contraseña muy común') if m == 'This password is entirely numeric.': mensajes.append( 'Contraseña no puede contener solo números') if m.startswith("The password is too similar"): mensajes.append( 'Contraseña muy similar a los datos del usuario') raise forms.ValidationError(mensajes) return password2
class UserForm(forms.Form): username = forms.CharField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter Your Username' }), required=True, max_length=60) email = forms.CharField( widget=forms.EmailInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter Your Email' }), required=True, max_length=60) first_name = forms.CharField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter Your First Name' }), required=True, max_length=60) last_name = forms.CharField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter Your Last Name' }), required=True, max_length=60) password = forms.CharField( widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'Enter Your Password' }), required=True, max_length=60) confirm_password = forms.CharField( widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': 'Confirm Password' }), required=True, max_length=60) class Meta: model = User fields = ['username', 'email', 'first_name', 'last_name', 'password']
class Meta: model = UserProfile fields = [ 'first_name', 'last_name', 'email', 'addressStreet', 'addressNumber' ] class_bs = {'class':"form-control"} widgets = { 'first_name': forms.TextInput(attrs=class_bs), 'last_name': forms.TextInput(attrs=class_bs), 'email': forms.EmailInput(attrs=class_bs), 'addressStreet': forms.TextInput(attrs=class_bs), 'addressNumber': forms.TextInput(attrs=class_bs) }
class Video_participanteForm(ModelForm): nombres_participante = forms.CharField(label="Nombres", max_length=200) apellidos_participante = forms.CharField(label="Apellidos", max_length=200) correo_participante = forms.EmailField(label="Correo electrónico", widget=forms.EmailInput()) video_original = forms.FileField(required=True, label="Video para participar") descripcion = forms.CharField(label="Descripción", widget=forms.Textarea, max_length=500) class Meta: model = Video_participante fields = [ 'nombres_participante', 'apellidos_participante', 'correo_participante', 'video_original', 'descripcion' ]
class RealUserData(forms.ModelForm): email = forms.CharField(widget=forms.EmailInput(attrs={ 'class': 'utf-submit-field', 'readonly': True })) username = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'utf-submit-field', 'readonly': True })) first_name = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'utf-submit-field', 'readonly': True })) last_name = forms.CharField(widget=forms.TextInput(attrs={ 'class': 'utf-submit-field', 'readonly': True })) class Meta: model = get_user_model() fields = ['email', 'first_name', 'last_name', 'username']
class TrabajadorForm(ModelForm): nombre = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Ingrese sus nombres'}) ) apellidos = forms.CharField( widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Ingrese sus apellidos'}) ) aniosExperiencia = forms.IntegerField( widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'Cantidad de a?os de experiencia'}), label='A?os De Experiencia' ) tiposDeServicio = forms.ModelChoiceField( widget=forms.Select(attrs={'class': 'form-control'}), queryset=TiposDeServicio.objects.all(), empty_label='Seleccione el tipo de servicio que ofrecer?', label='Tipo De Servicio' ) telefono = forms.IntegerField( widget=forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'N?mero telef?nico'}), label='Tel?fono' ) correo = forms.CharField( widget=forms.EmailInput(attrs={'class': 'form-control', 'placeholder': 'Correo electr?nico'}), label='Correo' ) class Meta: model = Trabajador fields = ['nombre', 'apellidos', 'aniosExperiencia', 'tiposDeServicio', 'telefono', 'correo', 'imagen']
class UserRegisterForm(forms.ModelForm): first_name = forms.CharField( label="First Name", max_length=30, min_length=4, widget=forms.TextInput(attrs={ 'autofocus': True, 'placeholder': 'First Name' }), help_text='should enter at least 4 characters and at most 30 characters' ) last_name = forms.CharField( label="Last Name", max_length=150, min_length=4, widget=forms.TextInput(attrs={'placeholder': 'Last Name'}), help_text= 'should enter at least 4 characters and at most 150 characters') email = forms.EmailField( label="Email", max_length=150, widget=forms.EmailInput(attrs={'placeholder': 'Email'})) username = forms.CharField( label="Username", widget=forms.TextInput(attrs={'placeholder': 'Username'}), help_text= "Required. 150 characters or fewer.Letters,digits and @/./+/-/_ only.") password = forms.CharField( label="Password", min_length=8, widget=forms.PasswordInput(attrs={'placeholder': 'Password'}), help_text=[ "Your Password can't be too similar to your other personal information.", "Your Password must contain at least 8 characters." "Your Password can't be a commonly used password.", "Your Password can't be entirely numeric." ]) password1 = forms.CharField( label="Confirm Password", min_length=8, widget=forms.PasswordInput(attrs={'placeholder': 'Confirm Password'}), help_text="Enter the same password as before,for validtion.") errors_messages = { 'password_mismatch': "The two password fields didn’t match.", } class Meta: model = User fields = ['first_name', 'last_name', 'username', 'email', 'password'] def clean(self, *args, **kwargs): password = self.cleaned_data.get('password') password1 = self.cleaned_data.get('password1') email = self.cleaned_data.get('email') if password and password1 and password != password1: raise forms.ValidationError( self.errors_messages['password_mismatch'], code='password_mismatch') if User.objects.filter(email=email).exists(): raise forms.ValidationError( 'Please use another Email,That is already taken') return super(UserRegisterForm, self).clean(*args, **kwargs) def save(self, commit=True): user = super().save(commit=False) user.set_password(self.cleaned_data['password']) if commit: user.save() return user