o
    %j                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZmZ e Z	G dd de	j
ZG dd	 d	e	j
ZG d
d dee	j
ZG dd de	j
ZdS )z
Modelos SQLAlchemy de LicenciasMIG.

Mantiene los nombres de columnas que el cliente MIG espera (nit, razonsocial,
nombrecomercial, etc.) para que las consultas SOAP no requieran traduccion.
    )datetime)	UserMixin)
SQLAlchemy)check_password_hashgenerate_password_hashc                   @   s.  e Zd ZdZejejdddZejedddddZ	ejedddZ
ejedddZeedZeedZeedZejejddd	Zejejddd	Zeed
Zejejejdd	ZejejejejddZeejZeejZeejZeedZdd ZdS )EmpresaEmpresasTprimary_keyautoincrement2   F)nullableuniqueindex   r   defaultr      )r   onupdater      c                 C   s   i d| j d| jd| jd| jd| jd| jd| jdt| jd	t| j	d
| j
d| jr7| jdnd d| jrC| jdnd d| jd| jd| jd| jS )N	EmpresaIDnitrazonsocialnombrecomercial	direcciontelefonocelularmensualidad
regularizatipotpvfecharegistro%Y-%m-%d %H:%M:%Sfechaactualizacionclaveproductonombreequipo	osversionperiodopagado)r   r   r   r   r   r   r   boolr   r   r    r!   strftimer#   r$   r%   r&   r'   self r,   $/var/www/html/LicenciasMIG/models.pyto_dict(   sB   

	
zEmpresa.to_dictN)__name__
__module____qualname____tablename__dbColumnIntegerr   Stringr   r   r   r   r   r   Booleanr   r   r    DateTimer   utcnowr!   r#   UnicodeTextr$   r%   r&   r'   r.   r,   r,   r,   r-   r      s&    r   c                   @   sr  e Zd ZdZejejdddZejeddddZ	eedZ
eedZeedZeedZeedZeedZeedZejejddd	Zejejejdd	Zeed
Zeed
Zeed
Zeed
ZeejZeejZeejZejed
ddZejejddd	Z ejejddd	Z!dd Z"dS )LicenciaEmpresaLicenciasEmpresasTr	   r   Fr   r   r   
   r   i  r   c                 C   s   i d| j d| jd| jd| jd| jd| jd| jd| jd	| jd
t	| j
d| jr5| jdnd d| jd| jd| jd| jd| jd| j| j| jt	| jt	| jdS )N
LicenciaIDr   r   r   r   r   r   iddepartamentoidciudadlicenciatemporalr!   r"   responsablecorreoresponsabletelefonoponsablemotivolicenciar$   r%   )r&   clavemeslicenciaactivabloquearlicencia)r?   r   r   r   r   r   r   r@   rA   r(   rB   r!   r)   rC   rD   rE   rF   r$   r%   r&   rG   rH   rI   r*   r,   r,   r-   r.   V   sP   	

zLicenciaEmpresa.to_dictN)#r/   r0   r1   r2   r3   r4   r5   r?   r6   r   r   r   r   r   r   r@   rA   r7   rB   r8   r   r9   r!   rC   rD   rE   rF   r:   r$   r%   r&   rG   rH   rI   r.   r,   r,   r,   r-   r;   =   s0    r;   c                   @   s   e Zd ZdZejejdddZejeddddZ	ejedddZ
eed	Zeed
ZejeddddZejejdddZejejejddZeejZdeddfddZdedefddZdd Zdd ZdS )UsuarioUsuariosTr	   r   F)r   r      )r   r   d   Adminr   passwordreturnNc                 C   s   t || _d S N)r   PasswordHashr+   rO   r,   r,   r-   set_password}   s   zUsuario.set_passwordc                 C   s   t | j|S rQ   )r   rR   rS   r,   r,   r-   check_password   s   zUsuario.check_passwordc                 C   s
   t | jS rQ   )str	UsuarioIDr*   r,   r,   r-   get_id   s   
zUsuario.get_idc              
   C   sN   | j | j| j| j| jt| j| jr| jdnd | j	r#| j	ddS d dS )Nr"   )rW   UsernameNombreCompletoEmailRolActivoFechaCreacionUltimoAcceso)
rW   rY   rZ   r[   r\   r(   r]   r^   r)   r_   r*   r,   r,   r-   r.      s   zUsuario.to_dict)r/   r0   r1   r2   r3   r4   r5   rW   r6   rY   rR   rZ   r[   r\   r7   r]   r8   r   r9   r^   r_   rV   rT   r(   rU   rX   r.   r,   r,   r,   r-   rJ   p   s    rJ   c                   @   s   e Zd ZdZejejdddZejeje	j
dddZejeddddZejedddZeed	Zeed
ZeedZeejZeejZdd ZdS )WebServiceLogWebServiceLogsTr	   F)r   r   r   r   r=   r   -   r      c              
   C   s:   | j | jr| jdnd | j| j| j| j| j| j| j	d	S )Nr"   )	LogIDFechaMetodor   	IpClienter%   	ResultadoMensaje
DuracionMs)
rd   re   r)   rf   r   rg   r%   rh   ri   rj   r*   r,   r,   r-   r.      s   zWebServiceLog.to_dictN)r/   r0   r1   r2   r3   r4   
BigIntegerrd   r8   r   r9   re   r6   rf   r   rg   r%   rh   r:   ri   r5   rj   r.   r,   r,   r,   r-   r`      s    r`   N)__doc__r   flask_loginr   flask_sqlalchemyr   werkzeug.securityr   r   r3   Modelr   r;   rJ   r`   r,   r,   r,   r-   <module>   s    ,3#