U
    \ø.eÒ  ã                   @   s   d dl Z d dlmZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZmZmZ d d	lmZ d
d„ Zdd„ Zdd„ ZdS )é    N)Úmessages)ÚHttpResponseRedirectÚHttpResponse)Úrender)Úcsrf_exempt)ÚExtenos)ÚArchivos)ÚTipoDocumentoÚSiglasÚ	Documento)Úrender_to_pdfc                 C   s‚   | j rRt| j ƒ tjj| j| j  d¡| j  d¡| j  d¡d ¡  t 	| tj
d¡ tj ¡ tj ¡ tjj| jddœ}t| d|ƒS )	NÚ	documentoÚnomenclaturaÚ	secuencia)ÚusuarioÚtipo_idr   r   z(El registro se ha creado exitosamente..!©r   )Ú	consultasÚ
documentosÚsiglaszsec_documentos.html)ÚPOSTÚprintr
   ÚobjectsÚcreateÚuserÚgetÚsaver   Úadd_messageÚSUCCESSr   Úallr	   Úfilterr   )ÚrequestÚcontexto© r#   ú*/var/www/html/TransitoApp/Oficios/views.pyÚ
secuencias   s    



ü
ýr%   c                 C   sœ  d}d }| j  d¡r*tjj| j  d¡d}| j  d¡rTtjj| j| j  d¡d ¡ }| jrJ| j  d¡r€tjj| j  d¡d}ntƒ }t	j	 
¡  ¡ |_| j  d¡r¸tjj| j  d¡d}| j|_||_| j ¡ |_| j d¡|_| j d¡|_| j d¡|_| j d¡|_| j d	¡|_| ¡  t | tjd
¡ td| j  d¡|jf ƒS tj ¡ tjj| jd|tjj| j|d ¡ |j d |t j ¡ dœ}t!| d|ƒS )NÚ Únumero©Úidr)   )r   r   ÚparaÚasuntoÚcuerpoÚcargozRegistro creado exitosamente..!zdocs?id=%s&numero=%sr   )r   r   é   )r   r   Údocr   r   r   zdocumentos.html)"ÚGETr   r   r   r
   r    r   Úlastr   ÚdatetimeÚnowÚdateÚfechar   r   Úget_full_nameÚder*   r'   r+   r,   r-   r   r   r   r   r   r)   r	   r   Úcountr   r   r   )r!   r/   r   r"   r#   r#   r$   r   !   s@    úr   c                 C   sr   t jj| jd}| j d¡r@t jj| j d¡d}tdd|iƒS tj ¡ t	j ¡ t
jj| jd|dœ}t| d|ƒS )Nr   r'   r(   zd_impresion.htmlr   )r   r   r   Ú	documentsztodo_docs.html)r   r   r    r   r0   r   r   r   r   r	   r
   r   )r!   Údocumentr   r"   r#   r#   r$   Ú
_documentoE   s    ür;   )r2   Údjango.contribr   Údjango.httpr   r   Údjango.shortcutsr   Údjango.views.decorators.csrfr   ZConsultas.modelsr   ZIndex.modelsr   ZOficios.modelsr	   r
   r   ÚTransitoApp.snnipersr   r%   r   r;   r#   r#   r#   r$   Ú<module>   s   $