a
    	4j6>                     @   s  d dl mZ d dlmZ d dlZd dlmZ d dlmZm	Z	m
Z
mZmZmZ G dd dejZG dd	 d	ejZG d
d dejZG dd dejZG dd dejZG dd dejZG dd dejeZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG dd dejZG d d! d!ejZG d"d# d#ejZG d$d% d%ejZG d&d' d'ejZG d(d) d)ejZ dS )*    )db)	UserMixinN)ARRAY)ADMIN_ROLE_IDGERENTE_ROLE_IDSUPERVISOR_ROLE_IDEVALUADO_ROLE_IDTALENTO_HUMANO_ROLE_IDDIRECTOR_ROLE_IDc                   @   s>   e Zd ZdZejejddZejeddddZ	dd Z
d	S )
RolrolTprimary_key2   Funiquenullablec                 C   s   d| j  dS )Nz<Rol >descripcionself r   "/var/www/html/evaluacion/models.py__repr__   s    zRol.__repr__N)__name__
__module____qualname____tablename__r   ColumnIntegerid_rolStringr   r   r   r   r   r   r   
   s   r   c                   @   sP   e Zd ZdZddiZejejddZee	dZ
ejejddZdd Zd	S )
Localizacionlocalizacionextend_existingTr      defaultc                 C   s   d| j  dS )Nz<Localizacion r   nombrer   r   r   r   r      s    zLocalizacion.__repr__N)r   r   r   r   __table_args__r   r   r    id_localizacionr"   r*   Booleanvalidor   r   r   r   r   r#      s   r#   c                   @   s\   e Zd ZdZddiZejejddZee	dZ
ejejddZeejZdd Zd	S )
DivisionesGeneralesZdivisiones_generalesr%   Tr      r'   c                 C   s   d| j  dS )Nz<DivisionesGenerales r   r)   r   r   r   r   r   &   s    zDivisionesGenerales.__repr__N)r   r   r   r   r+   r   r   r    id_divisiones_generalesr"   r*   r-   r.   Zseder   r   r   r   r   r/      s   r/   c                   @   sv   e Zd ZdZddiZejejddZee	dZ
ejejedddZejejddZejd	dd
Zdd ZdS )UnidadesZunidadesr%   Tr   r0   ,divisiones_generales.id_divisiones_generalesr   r'   r/   backrefc                 C   s   d| j  dS )Nz
<Unidades r   r)   r   r   r   r   r   4   s    zUnidades.__repr__N)r   r   r   r   r+   r   r   r    id_unidadesr"   r*   
ForeignKeyr1   r-   r.   relationshipdivisionr   r   r   r   r   r2   *   s   r2   c                   @   s   e Zd ZdZddiZejejddZee	dZ
ejejedddZejejedddZejejdd	ZejejddZejd
ddZejdddZdd ZdS )GerenciasGeneralesZgerencias_generalesr%   Tr   r0   unidades.id_unidadesr4   r3   r'   r2   r5   r/   c                 C   s   d| j  dS )Nz<GerenciasGenerales r   r)   r   r   r   r   r   E   s    zGerenciasGenerales.__repr__N)r   r   r   r   r+   r   r   r    id_gerencias_generalesr"   r*   r8   r7   r1   r-   r.   Z	id_estador9   unidadr:   r   r   r   r   r   r;   8   s   r;   c                   @   s   e Zd ZdZddiZejejddZee	dZ
ejejedddZejejedddZejejed	ddZejejdd
ZejdddZejdddZejdddZdd ZdS )CoordinacionesZcoordinacionesr%   Tr   r0   r3   r4   r<   *gerencias_generales.id_gerencias_generalesr'   r;   r5   r2   r/   c                 C   s   d| j  dS )Nz<Coordinaciones r   r)   r   r   r   r   r   W   s    zCoordinaciones.__repr__N)r   r   r   r   r+   r   r   r    id_coordinacionesr"   r*   r8   r1   r7   r=   r-   r.   r9   gerencia_generalr>   r:   r   r   r   r   r   r?   I   s   r?   c                   @   sf  e Zd ZdZddiZejejddZejejddZ	ee
dZee
dZee
dZeejZeejed	Zee
d
Zeje
ddddZejdddddZejdddZedd Zedd Zedd Zdd Zdd Zdd Zedd  Zed!d" Zed#d$ Z ed%d& Z!ed'd( Z"ed)d* Z#ed+d, Z$d-d. Z%d/S )0Userpersonalr%   Tr   Fr4   d      z
rol.id_rol   
   r   UbicacionPersonaluser_details_in_ubicacionZback_populatesZuselistlazyr   Zusersr5   c                 C   s   | j S Nusuarior   r   r   r   usernamen   s    zUser.usernamec                 C   s   | j pd d| jpd  S )N  )r*   apellidostripr   r   r   r   	full_namer   s    zUser.full_namec                 C   s   | j S rM   )estatur   r   r   r   activev   s    zUser.activec                 C   s   t |d | _d S Nutf-8)hashlibsha256encode	hexdigestpassword_hashr   passwordr   r   r   set_passwordz   s    zUser.set_passwordc                 C   s   | j t|d kS rX   )r^   rZ   r[   r\   r]   r_   r   r   r   check_password}   s    zUser.check_passwordc                 C   s
   t | jS rM   )strid_personalr   r   r   r   get_id   s    zUser.get_idc                 C   s,   | j r| jsdS | jt| j d kS )NFrY   )rO   r^   rZ   r[   r\   r]   r   r   r   r   is_default_password   s    zUser.is_default_passwordc                 C   s
   | j tkS rM   )r!   r   r   r   r   r   is_admin   s    zUser.is_adminc                 C   s   | j ttfv S rM   )r!   r   r
   r   r   r   r   
is_gerente   s    zUser.is_gerentec                 C   s
   | j tkS rM   )r!   r
   r   r   r   r   is_director   s    zUser.is_directorc                 C   s
   | j tkS rM   )r!   r   r   r   r   r   is_supervisor   s    zUser.is_supervisorc                 C   s
   | j tkS rM   )r!   r   r   r   r   r   is_evaluado   s    zUser.is_evaluadoc                 C   s
   | j tkS rM   )r!   r	   r   r   r   r   is_talento_humano   s    zUser.is_talento_humanoc                 C   s   d| j  dS )Nz<User r   rN   r   r   r   r   r      s    zUser.__repr__N)&r   r   r   r   r+   r   r   r    rd   cedular"   r*   rS   nacionalidadr-   rV   r8   r!   r^   rO   r9   	ubicacionr   propertyrP   rU   rW   ra   rb   re   rf   rg   rh   ri   rj   rk   rl   r   r   r   r   r   rC   [   sJ   









rC   c                   @   sF   e Zd ZdZddiZejejddZeje	ddddZ
dd	 Zd
S )Anoanor%   Tr   r   Fr   r   c                 C   s   d| j  dS )Nz<Ano r   r   r   r   r   r   r      s    zAno.__repr__N)r   r   r   r   r+   r   r   r    id_anor"   r   r   r   r   r   r   rq      s
   rq   c                   @   sF   e Zd ZdZddiZejejddZeje	ddddZ
dd	 Zd
S )	Trimestre	trimestrer%   Tr   r   Frs   c                 C   s   d| j  dS )Nz<Trimestre r   r   r   r   r   r   r      s    zTrimestre.__repr__N)r   r   r   r   r+   r   r   r    id_trimestrer"   r   r   r   r   r   r   ru      s
   ru   c                   @   sF   e Zd ZdZddiZejejddZeje	ddddZ
dd	 Zd
S )Rangorangor%   Tr   r   Frs   c                 C   s   d| j  dS )Nz<Rango r   r   r   r   r   r   r      s    zRango.__repr__N)r   r   r   r   r+   r   r   r    id_rangor"   r   r   r   r   r   r   rx      s
   rx   c                   @   s^   e Zd ZdZejejddZeedZ	eejZ
eejedZejdddZd	S )
OdiodiTr     personal.id_personalrC   Zmy_odisr5   N)r   r   r   r   r   r   r    id_odir"   r   pesor8   rd   r9   creatorr   r   r   r   r{      s   r{   c                   @   s   e Zd ZdZejejddZeejedZ	eejedZ
ejejedddZejejed	ddZejejed
ddZejdddZejdddZejdddZejdddZejdddZdd ZdS )OdiPersonalZodi_personalTr   r~   z
odi.id_odi
ano.id_anoFr4   trimestre.id_trimestrerango.id_rangorC   odi_assignmentsr5   r{   personal_assignmentsrq   ru   rx   c              	   C   s&   d| j  d| j d| j d| j d	S )Nz<OdiPersonal - (/)>)rd   r   rt   rw   r   r   r   r   r      s    zOdiPersonal.__repr__N)r   r   r   r   r   r   r    id_odi_personalr8   rd   r   rt   rw   rz   r9   rD   r|   rr   rv   ry   r   r   r   r   r   r      s   r   c                   @   s$  e Zd ZdZddiZejejddZejeje	ddddZ
ejeje	ddd	Zejeje	d
dd	Zejeje	ddd	Zejeje	ddd	Zejeje	ddd	ZejdddddZejddddZejddddZejddddZejddddZejddddZdd ZdS )rI   Zubicacion_personalr%   Tr   r~   Fr   zlocalizacion.id_localizacionr4   r3   r<   r@   z coordinaciones.id_coordinacionesrC   ro   rK   r#   Zubicacionesr6   rL   r/   r2   r;   r?   c                 C   s6   d| j  d| j d| j d| j d| j d| j dS )Nz<UbicacionPersonal Personal:z Loc:z Div:z Uni:z Ger:z Coord:r   )rd   r,   r1   r7   r=   rA   r   r   r   r   r      s    zUbicacionPersonal.__repr__N)r   r   r   r   r+   r   r   r    Zid_ubicacion_personalr8   rd   r,   r1   r7   r=   rA   r9   rJ   r$   Zdivision_generalr>   rB   Zcoordinacionr   r   r   r   r   rI      s    rI   c                   @   sV   e Zd ZdZddiZejejddZeje	ddddZ
ejejddZd	d
 ZdS )Competenciacompetenciar%   Tr   r}   Frs   r4   c                 C   s   d| j  d| j dS )Nz<Competencia z (Peso: r   )r   r   r   r   r   r   r   
  s    zCompetencia.__repr__N)r   r   r   r   r+   r   r   r    id_competenciar"   r   r   r   r   r   r   r   r     s   r   c                   @   s  e Zd ZdZejdddddddd	ifZejejd	d
Z	ejeje
dddZejeje
dddZejeje
dddZejeje
dddZejeje
dddZejdddZejdddZejdddZejdddZejdddZdd ZdS )CompetenciaPersonalZcompetencia_personalrd   r   rt   rw   Z"uq_competencia_personal_assignmentnamer%   Tr   zcompetencia.id_competenciaFr4   r~   r   r   r   r   r   r5   rC   competencia_assignmentsrx   rq   ru   c              	   C   s&   d| j  d| j d| j d| j d	S )Nz<CompetenciaPersonal r   r   r   r   )rd   r   rt   rw   r   r   r   r   r   "  s    zCompetenciaPersonal.__repr__N)r   r   r   r   r   UniqueConstraintr+   r   r    id_competencia_personalr8   r   rd   rz   rt   rw   r9   r   rD   ry   rr   rv   r   r   r   r   r   r     s    r   c                   @   sd   e Zd ZdZejejddZejejddZeejZ	eje
dddZeejZdd Zd	S )
EscalaZescalaTr   Fr4   r0   c                 C   s   d| j  d| j d| j dS )Nz<Escala z (Min: z, Max: r   )r   minimomaximor   r   r   r   r   .  s    zEscala.__repr__N)r   r   r   r   r   r   r    Z	id_escalar   r   r"   r   r-   requiere_cursor   r   r   r   r   r   &  s   r   c                   @   sJ  e Zd ZdZejejddZejejedddZ	ejejedddZ
ejejedddZeeejZeeejZeejZeejZeejZejd	e	gejd
dddZejdejd
dddZejdejd
dddZeejedZejd	egddZeejZejdddddfZdd ZdS )
Evaluacion
evaluacionTr   r~   Fr4   r   r   rC   Zevaluaciones)rL   )foreign_keysr6   rq   r5   ru   Zevaluaciones_realizadasrd   rt   rw   Zunique_evaluacion_groupr   c                 C   s   d| j  d| j d| j dS )Nz<Evaluacion Personal_ID: z, Ano: z, Trimestre: r   )rd   rt   rw   r   r   r   r   r   R  s    zEvaluacion.__repr__N)r   r   r   r   r   r   r    id_evaluacionr8   rd   rt   rw   r   ids_odi_personalids_competencia_personalr-   
aprobacionTextobservacion	ids_cursor9   r6   rD   rr   rv   id_evaluador	evaluadorobservacion_thr   r+   r   r   r   r   r   r   2  s&   r   c                   @   s   e Zd ZdZejejdddZeedZ	eej
ZeejedZeejedZeejedZejdd	dd
Zejdd	dd
Zejdd	dd
Zdd ZdS )CursoPersonalZcurso_personalT)r   autoincrementr0   r~   r   r   rC   r   r   rq   ru   c              	   C   s&   d| j  d| j d| j d| j d	S )Nz<CursoPersonal z for Personal z in r   r   )r   rd   rt   rw   r   r   r   r   r   c  s    zCursoPersonal.__repr__N)r   r   r   r   r   r   r    id_cursor"   r   r   path_to_filer8   rd   rt   rw   r9   rD   Zano_objZtrimestre_objr   r   r   r   r   r   U  s   r   )!
extensionsr   flask_loginr   rZ   Zsqlalchemy.dialects.postgresqlr   configr   r   r   r   r	   r
   Modelr   r#   r/   r2   r;   r?   rC   rq   ru   rx   r{   r   rI   r   r   r   r   r   r   r   r   r   <module>   s,    	P


#