Esempio n. 1
0
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>'
                )
        }
Esempio n. 2
0
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')
Esempio n. 3
0
class TenxGSCSubmissionForm(forms.Form):
    name = forms.CharField(max_length=50, widget=forms.TextInput())
    email = forms.EmailField(max_length=50, widget=forms.EmailInput())
    date = forms.DateField(widget=forms.SelectDateWidget(), initial=datetime.date.today())
    tenxpools = forms.ChoiceField(
        widget=forms.Select(),
        choices=[(pool.id, pool.pool_name) for pool in TenxPool.objects.all().order_by('id')],
        label="TenX Pool",
    )
Esempio n. 4
0
class userform(forms.ModelForm):
    username= forms.CharField(widget=forms.TextInput(
        attrs={'class': 'forms-control', 'placeholder': 'Enter username'}
    ), required=True, max_length=50)
    email = forms.CharField(widget=forms.EmailInput(
        attrs={'class': 'forms-control', 'placeholder': 'Enter email ID'}
    ), required=True, max_length=50)
    first_name = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'forms-control', 'placeholder': 'Enter  first name'}
    ), required=True, max_length=50)
    lastname = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'forms-control', 'placeholder': 'Enter last name'}
    ), required=True, max_length=50)
    password = forms.CharField(widget=forms.PasswordInput(
        attrs={'class': 'forms-control', 'placeholder': 'Enter password'}
    ), required=True, max_length=50)
    confirm_password = forms.CharField(widget=forms.PasswordInput(
        attrs={'class': 'forms-control', 'placeholder': 'Enter confirm password'}
    ), required=True, max_length=50)


    class Meta():
        model = User
        fields =['username','email','first_name','last_name','password','confirm_password']

            def clean_username(self):
                user=self.cleaned_data['username']
                try:
                    match = User.objects.get(username = user)
                except:
                    return self.cleaned_data['username'] #user
                raise forms.ValidationError("Username already exist")

            def clean_email(self):
                email = self.cleaned_data['email']
                try:
                    mt = validate_email(email)
                except:
                    return forms.ValidationError("Email is not in correct Format")
                return email


            def clean_confirm_password(self):
                pas = self.cleaned_data['password']
                cpas = self.cleaned_data['confirm_password']
                MIN_LENGTH = 8
                if pas and cpas:
                    if pas != cpas:
                        raise forms.ValidationError("password and confirm password not matched")
                    else:
                        if len(pas) < MIN_LENGTH:
                            raise forms.ValidationError("Password should have atleast %d character" %MIN_LENGTH)
                if pas.isdigit():
                    raise forms.ValidationError("Password should not all numeric")
Esempio n. 5
0
class Responsable_Form(forms.Form):
    Numero_Dni = forms.CharField(
        label='Numero de Dni',
        required=True,
        widget=forms.TextInput(attrs={
            'class': 'form-control input-sm',
            'placeholder': 'Numero DNI'
        }))
    Nombre_Responsable = forms.CharField(
        label='Nombres',
        required=True,
        widget=forms.TextInput(attrs={
            'class': 'form-control input-sm',
            'placeholder': 'Nombre Completo'
        }))
    Apellido_Paterno_Responsable = forms.CharField(
        label='Apellido Paterno',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Apellido_Materno_Responsable = forms.CharField(
        label='Apellido Paterno',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Nombre_Usuario = forms.CharField(
        label='Nombre Usuario',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Email = forms.EmailField(
        label='Direccion Email',
        required=True,
        widget=forms.EmailInput(attrs={'class': 'form-control input-sm'}))
    Telefono = forms.CharField(
        label='Numero de telefono',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Region = forms.ChoiceField(label='Region encargada',
                               required=True,
                               widget=forms.Select,
                               choices=choices_regiones)
    contra1 = forms.CharField(
        label='Contraseña',
        required=True,
        widget=forms.PasswordInput(attrs={'class': 'form-control input-sm'}))
    contra2 = forms.CharField(
        label='Confirmar contraseña',
        required=True,
        widget=forms.PasswordInput(attrs={'class': 'form-control input-sm'}))
    clave = forms.CharField(
        label='Clave Unica',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
Esempio n. 6
0
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']
Esempio n. 7
0
    class Meta:
        model = models.hamyar
        fields = ['username', 'password', 'first_name', 'last_name', 'id_number', 'phone_number', 'email', 'address']
        widgets = {
            'password': forms.TextInput(attrs={'type': 'password'}),
            'email': forms.EmailInput()
        }

        error_messages = {
            'username': {
                'unique': _("این نام کاربری قبلا انتخاب شده است."),
            },
            'id_number': {
                'unique': _("این کد ملی در سیستم ثبت شده است."),
            },
        }
Esempio n. 8
0
class CustomerRegisterForm(UserCreationForm):
    email = forms.CharField(label='Email адрес:',
                            widget=forms.EmailInput(
                                attrs={
                                    'class': 'form-control form-control-lg',
                                    'placeholder': 'Введите ваш email'
                                }))

    password1 = forms.CharField(
        label='Пароль:',
        strip=False,
        widget=forms.PasswordInput(
            attrs={
                'class': 'form-control form-control-lg',
                'placeholder': 'Придумайте пароль'
            }))
    password2 = forms.CharField(
        label='Повторите пароль:',
        strip=False,
        widget=forms.PasswordInput(
            attrs={
                'class': 'form-control form-control-lg',
                'placeholder': 'Введите пароль еще раз'
            }))

    class Meta:
        model = User
        fields = ('email', )

    def clean_email(self):
        email = self.cleaned_data.get('email')

        if User.objects.filter(email=email).exists():
            raise forms.ValidationError(
                'Пользователь с таким email уже зарегистрирован')
        return email

    def save(self, commit=True):
        user = super().save(commit=False)
        user.username = self.cleaned_data['email']
        user.set_password(self.cleaned_data["password1"])

        if commit:
            user.save()
        return user
Esempio n. 9
0
class RegisterForm(forms.Form):
    gender = (
        ('male', "男"),
        ('female', "女"),
    )
    username = forms.CharField(
        label="用户名",
        max_length=128,
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    password1 = forms.CharField(
        label="密码",
        max_length=256,
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    password2 = forms.CharField(
        label="确认密码",
        max_length=256,
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    email = forms.EmailField(
        label="邮箱地址", widget=forms.EmailInput(attrs={'class': 'form-control'}))
    sex = forms.ChoiceField(label='性别', choices=gender)
Esempio n. 10
0
class CustomerLoginForm(forms.Form):
    email = forms.CharField(widget=forms.EmailInput(
        attrs={
            'class': 'form-control',
            'placeholder': 'Email адрес'
        }))

    password = forms.CharField(widget=forms.PasswordInput(
        attrs={
            'class': 'form-control',
            'placeholder': 'Пароль'
        }))

    def clean(self):
        email = self.cleaned_data.get('email')
        password = self.cleaned_data.get('password')

        if email and password:
            customer = User.objects.filter(email=email).first()

            if not customer:
                raise forms.ValidationError(
                    'Покупатель с таким адресом email не зарегистрирован')

            else:
                username = customer.username

                user = authenticate(
                    username=username,
                    password=password,
                )

                if not user:
                    raise forms.ValidationError(
                        'Неверный адрес email или пароль')

        return super().clean()