예제 #1
0
class UserUpdateGTIForm(ModelForm):
    pk_user = None
    username = forms.CharField(label="Usuario", max_length=20)
    first_name = forms.CharField(label="Nombres", max_length=20)
    last_name = forms.CharField(label="Apellidos", max_length=20)
    email = forms.EmailField(label="Correo electrónico")
    foto = forms.FileField(required=False)
    USER_GTI = 2
    ROLE_CHOICES = (
        (USER_GTI, 'Miembro GTI'),
    )
    roles = forms.ChoiceField(choices=ROLE_CHOICES)

    class Meta:
        model = User
        fields = ['username', 'first_name', 'last_name', 'email', 'roles', 'foto']

    # verificacion correo unico
    def clean_email(self):
        email = self.cleaned_data['email']
        busqueda = User.objects.filter(email=email)
        if busqueda:
            user = len(busqueda)
            if user > 1:
                raise forms.ValidationError('Correo ya ha sido registrado')
            else:
                return email
        return email

    def clean_username(self):
        username = self.cleaned_data['username']
        if User.objects.exclude(pk=self.instance.id).filter(username=username).exists():
            raise forms.ValidationError(u'Usuario "%s" ya esta en uso.' % username)
        return username
예제 #2
0
파일: forms.py 프로젝트: therealak12/Paskal
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
예제 #3
0
class UserForm(ModelForm):
    username = forms.CharField(max_length=50)
    first_name = forms.CharField(max_length=20)
    last_name = forms.CharField(max_length=20)
    email = forms.EmailField()
    password = forms.CharField(widget=forms.PasswordInput())
    password2 = forms.CharField(widget=forms.PasswordInput())

    class Meta:
        model = Usuario
        fields = ('picture', 'country', 'city')

    def clean_username(self):
        """Comprueba que no exista un username igual en la Base de Datos"""
        username = self.cleaned_data['username']
        if User.objects.filter(username=username):
            raise forms.ValidationError('Nombre de usuario ya registrado.')
        return username

    def clean_email(self):
        """Comprueba que no exista un email igual en la Base de Datos"""
        email = self.cleaned_data['email']
        if User.objects.filter(email=email):
            raise forms.ValidationError('Ya existe un email igual registado.')
        return email

    def clean_password2(self):
        """Comprueba que password y password2 segan iguales"""
        password = self.cleaned_data['password']
        password2 = self.cleaned_data['password2']
        if password != password2:
            raise forms.ValidationError('Las Claves no coinciden.')
        return password2
예제 #4
0
class RequireEmailForm(forms.Form):
    email = forms.EmailField(label='电子邮箱', required=True)
    oauthid = forms.IntegerField(widget=forms.HiddenInput, required=False)

    def __init__(self, *args, **kwargs):
        super(RequireEmailForm, self).__init__(*args, **kwargs)
        self.fields['email'].widget = widgets.EmailInput(attrs={'placeholder': "email", "class": "form-control"})
예제 #5
0
파일: forms.py 프로젝트: monikas123/django
class Subscribe(forms.Form):
    Name = forms.CharField()
    Email = forms.EmailField()
    Message = forms.CharField()

    def __str__(self):
        return self.Email
예제 #6
0
class registerForm(forms.Form):
    username = forms.CharField(max_length=30)
    email = forms.EmailField(widget=forms.EmailInput, label='Email-Id')
    password1 = forms.CharField(
        widget=forms.PasswordInput, label='New Password')
    password2 = forms.CharField(
        widget=forms.PasswordInput, label='Confirm Password')
    CHOICES=[('M','Male'),
         ('F','Female')]
    Gender = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect)


    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            'username',
            'email',
            'Gender',
            Row(
                Column('password1', css_class='form-group col-md-6 mb-0'),
                Column('password2', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'
            ),
            Submit('submit', 'Register')
        )
예제 #7
0
파일: forms.py 프로젝트: pooyak143/Paskal
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')
예제 #8
0
파일: forms.py 프로젝트: therealak12/Paskal
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')
예제 #9
0
 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'}),
     }
예제 #10
0
class UserUpdateForm(forms.ModelForm):
    email = forms.EmailField()
    first_name = forms.CharField(max_length=20)
    last_name = forms.CharField(max_length=20)

    class Meta:
        model = User
        fields = ['first_name', 'last_name', 'email', 'username']
예제 #11
0
class UpdateArtistForm(ModelForm):

    error_messages = {
        'same_email': "Email already taken.",
        'same_username': "******"
    }

    username = forms.RegexField(
        label=("username"),
        max_length=100,
        regex=r'^[a-zA-Z0-9 _]+$',
        error_messages={
            'invalid': "This field must contain only letters or numbers."
        }
    )

    email = forms.EmailField()

    class Meta:
        model = Artists
        exclude = ['user']

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

        if User.objects.filter(email=email).count() > 0:
            raise forms.ValidationError(
                self.error_messages['same_email'],
                code='same_email'
            )

        return email

    def check_username(self):
        username = self.cleaned_data.get('username')

        if User.objects.filter(username=username).count() > 0:
            raise forms.ValidationError(
                self.error_messages['same_username'],
                code='same_username'
            )

        return username

    def save(self):
        artist = super(UpdateArtistForm, self).save(commit=False)
        user = User.objects.get(username=artist.user.username)

        if artist.user.username != self.cleaned_data.get('username'):
            user.username = self.check_username()

        if artist.user.email != self.cleaned_data.get('email'):
            user.email = self.check_email()

        user.save()
        artist.save()

        return artist
예제 #12
0
파일: forms.py 프로젝트: therealak12/Paskal
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')
예제 #13
0
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])
예제 #14
0
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']
예제 #15
0
class UserForm(ModelForm):
    username = forms.CharField(label="Usuario", max_length=20)
    first_name = forms.CharField(label="Nombres", max_length=20)
    last_name = forms.CharField(label="Apellidos", max_length=20)
    foto = forms.FileField(required=False)
    email = forms.EmailField(label="Correo electrónico")
    password = forms.CharField(label="Contraseña", widget=forms.PasswordInput())
    password2 = forms.CharField(label="Confirmación Contraseña", widget=forms.PasswordInput())
    ADMINISTRADOR = 1
    USER_GTI = 2
    ROLE_CHOICES = (
        (USER_GTI, 'Miembro GTI'),
        (ADMINISTRADOR, 'Administrador'),
    )
    roles = forms.ChoiceField(choices=ROLE_CHOICES)

    class Meta:
        model = User
        fields = ['username', 'first_name', 'last_name', 'email', 'password', 'password2', 'roles', 'foto']

    # Verificacion usuario unico
    def clean_username(self):
        username = self.cleaned_data['username']
        if User.objects.filter(username=username):
            raise forms.ValidationError('Nombre de usuario ya ha sido tomado')
        return username

    # verificacion correo unico
    def clean_email(self):
        email = self.cleaned_data['email']
        if User.objects.filter(email=email):
            raise forms.ValidationError('Correo ya ha sido registrado')
        return email

    # 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
예제 #16
0
class UserRegisterForm(UserCreationForm):
    email = forms.EmailField()
    first_name = forms.CharField(max_length=20)
    last_name = forms.CharField(max_length=20)

    class Meta:
        model = User
        fields = [
            'first_name', 'last_name', 'email', 'username', 'password1',
            'password2'
        ]
예제 #17
0
class EditProfileForm(forms.ModelForm):
    email = forms.EmailField()

    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'}),
        }
예제 #18
0
class AdminRegistrationForm(UserCreationForm):
    email = forms.EmailField()

    class Meta:
        model = User
        fields = [
            'username',
            'email',
            'password1',
            'password2',

        ]
예제 #19
0
class EditUserForm(forms.ModelForm):
    first_name = forms.CharField(max_length=16)
    last_name = forms.CharField(max_length=16)
    email = forms.EmailField()

    class Meta:
        model = User
        fields = [
            'first_name',
            'last_name',
            'email',
        ]
class StudentForm(forms.ModelForm):
    student_id = forms.CharField(max_length=8)
    student_name = forms.CharField(max_length=25)
    email = forms.EmailField(max_length=19)
    section = forms.CharField(max_length=2)
    class Meta:
        model = StudentInfo
        fields = [
            'student_id',
            'student_name',
            'email',
            'section',
        ]
예제 #21
0
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
예제 #22
0
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 UserRegistrationForm(UserCreationForm):
    email = forms.EmailField()
    first_name = forms.CharField()
    last_name = forms.CharField()

    class Meta:
        model = User
        fields = [
            'username',
            'first_name',
            'last_name',
            'email',
            'password1',
            'password2',
        ]
예제 #24
0
class SignUpForm(UserCreationForm):
    firstName = forms.CharField(max_length=40, required=True)
    lastName = forms.CharField(max_length=40, required=False)
    email = forms.EmailField(max_length=100)
    phone = forms.CharField(max_length=18)

    class Meta:
        model = User
        fields = ('username', 'firstName', 'lastName', 'email', 'phone',
                  'password1', 'password2')
        help_texts = {
            'username': None,
            'password1': None,
            'password2': None,
        }
예제 #25
0
class UserCreateForm(UserCreationForm):
    email = forms.EmailField(required=True)
    teamname = forms.CharField(required=True)

    class Meta:
        model = User
        fields = ( "username", "email", "teamname" )
    
    def save(self, commit=True):
        if not commit:
            raise NotImplementedError("Can't create User and FFLPlayer without database save")
        user = super(UserCreateForm, self).save(commit=True)
        newplayer = FFLPlayer(user=user,league=0, email=self.cleaned_data['email'], teamname=self.cleaned_data['teamname'])
        newplayer.save()
        return user, newplayer
예제 #26
0
class EditUserForm(ModelForm):
    username = forms.CharField(max_length=50, disabled=True)
    first_name = forms.CharField(max_length=20)
    last_name = forms.CharField(max_length=20)
    email = forms.EmailField()

    class Meta:
        model = User
        fields = ['username', 'first_name', 'last_name', 'email']

    def clean_username(self):
        username = self.cleaned_data['username']
        if not User.objects.filter(username=username):
            raise forms.ValidationError('Nombre de usuario no existe.')
        return username
예제 #27
0
class UserRegistraionForm(UserCreationForm):
    email = forms.EmailField()
    first_name = forms.CharField(max_length=10)
    last_name = forms.CharField(max_length=10)

    class Meta:
        model = User
        email = models.EmailField(unique=True)
        fields = [
            'username',
            'email',
            'first_name',
            'last_name',
            'password1',
            'password2',
        ]
예제 #28
0
class UserRegistraionForm(UserCreationForm):
    email = forms.EmailField()
    nid = forms.CharField()
    phone = forms.CharField()

    class Meta:
        model = User
        nid = models.CharField(unique=True)
        fields = [
            'username',
            'email',
            'nid',
            'phone',
            'password1',
            'password2',
        ]
예제 #29
0
class UserRegisterForm(UserCreationForm):
    email = forms.EmailField()
    full_name = forms.CharField(max_length=30)
    contact_number = forms.IntegerField()

    # lname = forms.CharField(max_length=10)

    class Meta:
        model = User
        fields = [
            'username',
            'full_name',
            'email',
            'contact_number',
            'password1',
            'password2',
        ]
예제 #30
0
class ClientForm(ModelForm):
    nombre = forms.CharField(
        max_length=User._meta.get_field('first_name').max_length,
        label='Nombres')
    apellido = forms.CharField(
        max_length=User._meta.get_field('last_name').max_length,
        label='Apellidos')
    departamento = forms.ChoiceField(
        choices=Cliente._meta.get_field('departamento').choices,
        label='Departamento')
    ciudad = forms.ChoiceField(
        choices=Cliente._meta.get_field('ciudad').choices, label='Ciudad')
    numero_identificacion = forms.CharField(max_length=20)
    tipo_identificacion = forms.ChoiceField(
        choices=Cliente._meta.get_field('tipo_identificacion').choices)
    telefono_contacto = forms.CharField(max_length=15,
                                        label='Telefono de Contacto')
    correo = forms.EmailField(max_length=50, label='Correo electrónico')
    direccion = forms.CharField(max_length=150, label='Direcció de Residencia')
    contrasena = forms.CharField(widget=forms.PasswordInput(),
                                 label='Contraseña')
    contrasena2 = forms.CharField(widget=forms.PasswordInput(),
                                  label='Confirma tu contraseña')

    class Meta:
        model = User
        fields = [
            'nombre', 'apellido', 'departamento', 'ciudad',
            'numero_identificacion', 'tipo_identificacion',
            'telefono_contacto', 'correo', 'direccion', 'contrasena',
            'contrasena2'
        ]

    def clean_contrasena2(self):
        password = self.cleaned_data['contrasena']
        password2 = self.cleaned_data['contrasena2']
        if password != password2:
            raise forms.ValidationError('Las claves no coinciden.')
        return password2

    def clean_correo(self):
        email = self.cleaned_data['correo']
        if User.objects.filter(email=email):
            raise forms.ValidationError('Ya existe un email igual registrado.')
        return email