Пример #1
0
class ClassNotesUploadForm(forms.ModelForm):
    Notes = forms.FileField(required=True,
                            widget=forms.TextInput(attrs={'type': 'file'}))

    class Meta:
        model = ClassNotes
        exclude = ('Teacher', )
Пример #2
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
Пример #3
0
class HerramientaUpdateForm(ModelForm):
    pk_herramienta = None
    nombre = forms.CharField(label="Nombre", max_length=100)
    logo = forms.FileField(label="Logo", required=False)
    fichaTecnica = forms.CharField(label="Ficha Técnica",
                                   widget=forms.Textarea,
                                   max_length=2000)
    descripcion = forms.CharField(label="Descripción",
                                  widget=forms.Textarea,
                                  max_length=520)
    urlReferencia = forms.CharField(label="Url herramienta", max_length=500)

    SISTEMAS_OPERATIVOS = (
        ('No aplica', 'No aplica'),
        ('MAC OS', 'MAC OS'),
        ('Windows', 'Windows'),
        ('IOS', 'IOS'),
        ('Android', 'Android'),
        ('Linux ', 'Linux'),
    )
    sistemaOperativo = forms.MultipleChoiceField(
        required=True,
        widget=forms.CheckboxSelectMultiple,
        label="Sistema Operativo",
        choices=SISTEMAS_OPERATIVOS)

    ESTADO = ((6, 'Guardar en mis borradores'), (1, 'Enviar para revisión'))
    estado = forms.ChoiceField(required=True,
                               widget=forms.RadioSelect,
                               label="Seleccione una acción",
                               choices=ESTADO)

    PLATAFORMAS = (
        ('Moodle', 'Moodle'),
        ('Blackboard', 'Blackboard'),
        ('WordPress', 'WordPress'),
        ('Drupal', 'Drupal'),
        ('Joomla', 'Joomla'),
    )
    plataforma = forms.ChoiceField(label="Plataforma", choices=PLATAFORMAS)
    LICENCIA = (
        ('Apache License Version 2.0', 'Apache License Version 2.0'),
        ('GNU GENERAL PUBLIC ', 'GNU GENERAL PUBLIC '),
        ('MIT License', 'MIT License'),
        ('UnLicense', 'UnLicense'),
        ('GNU AFFERO GENERAL PUBLIC LICENSE',
         'GNU AFFERO GENERAL PUBLIC LICENSE'),
    )
    licencia = forms.ChoiceField(label="Licencia", choices=LICENCIA)

    class Meta:
        model = Herramienta
        fields = [
            'nombre', 'logo', 'urlReferencia', 'sistemaOperativo',
            'plataforma', 'licencia', 'fichaTecnica', 'descripcion', 'estado'
        ]
Пример #4
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
Пример #5
0
class createElectionForm(forms.ModelForm):
   

    elec_name = forms.CharField()
    elec_type= forms.CharField(label='ElectionType', widget=forms.Select(choices=FRUIT_CHOICES))
    cvc_file = forms.FileField() 
    class Meta:
        model = Election
        fields = [ 'elec_name',
                   'elec_type',
                   'cvc_file',
            ]
Пример #6
0
class EditInfoForm(forms.ModelForm):
    name = forms.CharField()
    father_name = forms.CharField()
    mother_name = forms.CharField()
    profile_picture = forms.FileField()
    dob = forms.DateField()

    class Meta:
        model = DummyCitizenInfo
        fields = [
            'name', 'father_name', 'mother_name', 'profile_picture', 'dob'
        ]
Пример #7
0
class HerramientaForm(ModelForm):
    nombre = forms.CharField(label="Nombre", max_length=100)
    logo = forms.FileField(label="Logo", required=False)
    fichaTecnica = forms.CharField(label="Ficha Técnica", widget=forms.Textarea, max_length=2000)
    descripcion = forms.CharField(label="Descripción", widget=forms.Textarea, max_length=520)
    urlReferencia = forms.CharField(label="Url herramienta", max_length=500)

    ESTADO = (
        (6, 'Guardar en mis borradores'),
        (1, 'Enviar para revisión')
    )
    estado = forms.ChoiceField(required=True, widget=forms.RadioSelect,
                               label="Seleccione una acción",
                               choices=ESTADO)
    SISTEMAS_OPERATIVOS = (
        ('No aplica', 'No aplica'),
        ('MAC OS', 'MAC OS'),
        ('Windows', 'Windows'),
        ('IOS', 'IOS'),
        ('Android', 'Android'),
        ('Linux ', 'Linux'),
    )
    sistemaOperativo = forms.MultipleChoiceField(required=True,
                                                 widget=forms.CheckboxSelectMultiple,
                                                 label="Sistema Operativo",
                                                 choices=SISTEMAS_OPERATIVOS)
    PLATAFORMAS = (
        ('Plataforma 1', 'Plataforma 1'),
        ('Plataforma 2', 'Plataforma 2'),
        ('Plataforma 3', 'Plataforma 3'),
        ('Plataforma 4', 'Plataforma 4'),
    )
    plataforma = forms.ChoiceField(label="Plataforma", choices=PLATAFORMAS)
    LICENCIA = (
        ('Licencia 1', 'Licencia 1'),
        ('Licencia 2', 'Licencia 2'),
        ('Licencia 3', 'Licencia 3'),
        ('Licencia 4', 'Licencia 4'),
    )
    licencia = forms.ChoiceField(label="Licencia", choices=LICENCIA)

    class Meta:
        model = Herramienta
        fields = ['nombre', 'logo', 'urlReferencia', 'sistemaOperativo', 'plataforma',
                  'licencia', 'fichaTecnica', 'descripcion', 'estado']
Пример #8
0
class HerramientaForm(ModelForm):
    nombre = forms.CharField(label="Nombre", max_length=20)
    logo = forms.FileField(label="Logo", required=False)
    sistemaOperativo = forms.CharField(label="Sistema Operativo",
                                       max_length=50)
    plataforma = forms.CharField(label="Plataforma", max_length=20)
    fichaTecnica = forms.CharField(label="Ficha Tecnica",
                                   widget=forms.Textarea)
    licencia = forms.CharField(label="Licencia", widget=forms.Textarea)
    descripcion = forms.CharField(label="Descripcion", widget=forms.Textarea)
    urlReferencia = forms.CharField(label="Url herramienta", max_length=50)

    class Meta:
        model = Herramienta
        fields = [
            'nombre', 'logo', 'urlReferencia', 'sistemaOperativo',
            'plataforma', 'fichaTecnica', 'licencia', 'descripcion'
        ]
Пример #9
0
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'
        ]
Пример #10
0
class RealUserProfileData(forms.ModelForm):

    gender = forms.CharField(widget=forms.Select(attrs={
        'class': 'utf-with-border',
        'readonly': True
    }))
    dob = forms.DateField(widget=forms.DateInput(format="%d/%m/%Y",
                                                 attrs={
                                                     'class':
                                                     'utf-with-border',
                                                     'type': 'date',
                                                     'readonly': True
                                                 }), )
    country = forms.CharField(widget=forms.TextInput(attrs={
        'class': 'utf-with-border',
        'readonly': True
    }))
    phone_number = PhoneNumberField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'readonly': True
        }))
    region = forms.CharField(widget=forms.TextInput(attrs={
        'class': 'utf-with-border',
        'readonly': True
    }))
    student_number = forms.IntegerField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'readonly': True
        }))
    school = forms.CharField(
        required=False,
        error_messages={'required': 'The school field is required'},
        widget=forms.TextInput(attrs={
            'class': 'form-control',
            'readonly': True
        }))
    start_program = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y",
        attrs={
            'class': 'utf-with-border',
            'type': 'date',
            'readonly': True
        }), )
    complete_program = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y",
        attrs={
            'class': 'utf-with-border',
            'type': 'date',
            'readonly': True
        }), )
    program = forms.CharField(widget=forms.TextInput(attrs={
        'class': 'utf-with-border',
        'readonly': True
    }))
    qualification = forms.CharField(widget=forms.Select(
        attrs={
            'class': 'utf-with-border',
            'readonly': True
        }))
    company_name = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'readonly': True
        }))
    company_location = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'readonly': True
        }))
    job_position = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'readonly': True
        }))
    job_position_period_from = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y",
        attrs={
            'class': 'utf-with-border',
            'type': 'date',
            'readonly': True
        },
    ))
    job_position_period_to = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y",
        attrs={
            'class': 'utf-with-border',
            'type': 'date',
            'readonly': True
        }), )
    resume = forms.FileField(widget=forms.FileInput(attrs={
        'class': 'utf-with-border',
        'type': 'file'
    }))
    profile_img = forms.FileField(widget=forms.FileInput(
        attrs={
            'type': 'file',
            'class': 'file-upload',
            'required': False
        }))

    # role = forms.BooleanField(widget=forms.RadioSelect(attrs={'class': 'radio'}, choices=ROLE))

    class Meta:
        model = UserProfile
        fields = [
            'dob', 'gender', 'country', 'phone_number', 'student_number',
            'school', 'program', 'start_program', 'complete_program',
            'qualification', 'company_name', 'company_location',
            'job_position', 'job_position_period_from',
            'job_position_period_to', 'resume', 'profile_img', 'region'
        ]
Пример #11
0
class UpdateProfileForm(forms.ModelForm):
    ROLE = (('student', 'Student'), ('staff', 'Staff'))
    GENDER = ((None, 'Select Gender'), ('Male', 'Male'), ('Female', 'Female'))

    DEGREE = ((None, 'Select your qualifications'),
              ('Undergraduate', 'Undergraduate'), ('Bachelor',
                                                   'Bachelor (BSc)'),
              ('Master', 'Master (Msc, MPHIL)'), ('PhD', 'PhD'))
    gender = forms.CharField(widget=forms.Select(
        attrs={'class': 'utf-with-border'}, choices=GENDER))
    dob = forms.DateField(widget=forms.DateInput(format="%d/%m/%Y",
                                                 attrs={
                                                     'class':
                                                     'utf-with-border',
                                                     'type': 'date'
                                                 }), )
    country = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'Eg. Ghana'
        }))
    phone_number = PhoneNumberField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'eg. +233 268971089'
        }))
    region = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'Eg. Accra',
        }))
    student_number = forms.IntegerField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'readonly': True,
            'value': random.randint(1000, 1000091)
        }))
    school = forms.CharField(
        required=False,
        error_messages={'required': 'The school field is required'},
        widget=forms.TextInput(
            attrs={
                'class':
                'form-control',
                'placeholder':
                'Eg. Kwame Nkrumah University Of Science and Techonlogy (KNUST)'
            }))
    start_program = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y", attrs={
            'class': 'utf-with-border',
            'type': 'date'
        }), )
    complete_program = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y",
        attrs={
            'class': 'utf-with-border',
            'type': 'date',
            'required': False
        }), )
    program = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'Eg. Computer Science'
        }))
    qualification = forms.CharField(widget=forms.Select(
        attrs={'class': 'utf-with-border'}, choices=DEGREE))
    company_name = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'Eg. MTN'
        }))
    company_location = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'Eg. Accra, Kumasi, Cape Coast etc..'
        }))
    job_position = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'utf-with-border',
            'placeholder': 'Eg. Intern Supervisor'
        }))
    job_position_period_from = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y", attrs={
            'class': 'utf-with-border',
            'type': 'date'
        }), )
    job_position_period_to = forms.DateField(widget=forms.DateInput(
        format="%d/%m/%Y", attrs={
            'class': 'utf-with-border',
            'type': 'date'
        }), )
    resume = forms.FileField(widget=forms.FileInput(attrs={
        'class': 'utf-with-border',
        'type': 'file'
    }))
    profile_img = forms.FileField(widget=forms.FileInput(
        attrs={
            'type': 'file',
            'class': 'file-upload',
            'required': False
        }))

    # role = forms.BooleanField(widget=forms.RadioSelect(attrs={'class': 'radio'}, choices=ROLE))

    class Meta:
        model = UserProfile
        fields = [
            'dob', 'gender', 'country', 'phone_number', 'student_number',
            'school', 'program', 'start_program', 'complete_program',
            'qualification', 'company_name', 'company_location',
            'job_position', 'job_position_period_from',
            'job_position_period_to', 'resume', 'profile_img', 'region'
        ]