Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(AnticipoFilterForm, self).__init__(*args, **kwargs)
     self.fields[
         'empleado'].choices = EmpleadoBusiness.get_Todos_ForSelectCustom()
     self.fields[
         'unidad_negocio'].choices = CentroCostoBusiness.get_Todos_ForSelectCustom(
         )
     self.fields[
         'autorizador'].choices = EmpleadoBusiness.get_Todos_ForSelectCustom(
         )
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super(ViaticoFilterForm, self).__init__(*args, **kwargs)
        self.fields['empleado_clave'].required = False
        self.fields['un_clave'].required = False
        self.fields['autorizador_clave'].required = False

        self.fields[
            'empleado_clave'].choices = EmpleadoBusiness.get_Todos_ForSelectCustom(
            )
        self.fields[
            'un_clave'].choices = CentroCostoBusiness.get_Todos_ForSelectCustom(
            )
        self.fields[
            'autorizador_clave'].choices = EmpleadoBusiness.get_Todos_ForSelectCustom(
            )
Ejemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super(ViaticoCabeceraForm, self).__init__(*args, **kwargs)
     self.fields[
         'empleado_clave'].choices = EmpleadoBusiness.get_Activos_ForSelect(
         )
     self.fields[
         'un_clave'].choices = CentroCostoBusiness.get_Activos_ForSelect()
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     super(UserNuevoForm, self).__init__(*args, **kwargs)
     self.fields['username'].widget.attrs.pop("autofocus", None)
     self.fields['first_name'].required = True
     self.fields['last_name'].required = True
     self.fields['clave_jde'].required = False
     self.fields['fecha_nacimiento'].required = True
     self.fields['foto'].required = False
     self.fields[
         'clave_rh'].choices = EmpleadoBusiness.get_Activos_ForSelect()
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(UserRegistroForm, self).__init__(*args, **kwargs)
     self.fields['username'].required = False
     self.fields['first_name'].required = False
     self.fields['last_name'].required = False
     self.fields['email'].required = True
     self.fields['rfc'].required = True
     self.fields[
         'clave_rh'].choices = EmpleadoBusiness.get_SinUsuario_ForSelect()
     self.fields['clave_jde'].required = False
     self.fields['foto'].required = False
     self.fields['fecha_nacimiento'].required = False
     self.fields['accept_terms'].required = True
Ejemplo n.º 6
0
    def clean(self):
        cleaned_data = super(UserRegistroForm, self).clean()
        clave_rh = cleaned_data.get("clave_rh")
        rfc = cleaned_data.get("rfc")

        password1 = cleaned_data.get("password1")
        password2 = cleaned_data.get("password2")
        email = cleaned_data.get("email")
        accept_terms = cleaned_data.get("accept_terms")

        if clave_rh and rfc and email and password1 and password2 and accept_terms:

            try:

                datos = EmpleadoBusiness.get_ByNumero(clave_rh)
            except Exception as error:
                raise ValidationError(
                    str(error)
                )

            if datos.pers_empleado_numero:

                ebs_rfc = datos.pers_rfc.replace("-", "")
                rfc = rfc.replace("-", "").upper()

                if ebs_rfc != rfc:
                    raise ValidationError(
                        'No existe un usuario con el RFC proporcionado')

                username = datos.pers_empleado_numero
                first_name = "%s %s" % (
                    datos.pers_primer_nombre, datos.pers_segundo_nombre.replace("-", ""))
                last_name = "%s %s" % (
                    datos.pers_apellido_paterno, datos.pers_apellido_materno.replace("-", ""))

                self.cleaned_data["username"] = username
                self.cleaned_data["first_name"] = first_name
                self.cleaned_data["last_name"] = last_name

                fecha = parser.parse(datos.pers_fecha_nacimiento)
                self.cleaned_data["fecha_nacimiento"] = fecha.date()

                return self.cleaned_data

            else:
                raise ValidationError(
                    "El empleado no tiene un numero especificado"
                )
Ejemplo n.º 7
0
    def lista_fecha_cumpleanios(self):
        hoy = datetime.now()
        empleado = EmpleadoBusiness.get_Activos()
        e = []
        incluir = {}

        for dato in empleado:
            f = dato.pers_fecha_nacimiento.split(" ")
            if f[0] != "-":
                fecha_nacimiento = datetime.strptime(f[0], '%Y-%m-%d').date()
                if fecha_nacimiento.month == hoy.month:
                    if fecha_nacimiento.day >= hoy.day:
                        incluir = {}
                        incluir['dia'] = fecha_nacimiento.day
                        incluir['nombre'] = dato.pers_nombre_completo
                        e.append(incluir)
        return e