
    ޸(i                         d dl mZ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mZ d dlZd dlZdd	lmZmZmZ d
 Zd Zd Zd ZdS )    )renderredirect)JsonResponseHttpResponse)settings)Prefetch)require_http_methods)IntegrityErrortransactionN   )UsuarioAreaEmpleadoc                 "    t          | d          S )Nzusuarios.html)r   )requests    ./var/www/html/Desarrollo/tic/usuarios/views.pyusuarios_viewr      s    '?+++    c                     t           j                                        }t          |                    dd                    }t          |d          S )uo   
    Obtiene la lista de Áreas y la retorna como JsonResponse.
    No requiere manejo de BigIntegerField.
    idnombreFsafe)r   objectsalllistvaluesr   )r   areasdatas      r   	get_areasr       sI    
 LE T8,,--D 5))))r   c                     t           j                                        }g }|D ][}|                    |j        |j        |j        |j        |j        |j	        |j
        |j        t          |j                  d	           \t          |d          S )u   
    Obtiene la lista de Empleados y la retorna como JsonResponse.
    Asegura la serialización de BigIntegerField (docNumber).
    )	r   emailr   areadocTypecargojefecorreo_jefe	docNumberFr   )r   r   r   appendr   r"   r   r#   r$   r%   r&   r'   strr(   r   )r   	empleadosr   empleados       r   get_empleadosr-   &   s    
  $$&&I D  +^oM'^M#/X/00
 
 	 	 	 	 5))))r   c                    t           j                            d                                          }g }|D ]}|                    |j        |j        |j        |j        t          |j
                  |j        |j        |j        rt          j         d|j         nt          j         d|j        |j        |j        r|j        j        nd|j        r|j        j        ndd           t'          |d          S )z
    Obtiene la lista de Usuarios y retorna la data como JsonResponse.
    Maneja correctamente campos NULL en area, BigIntegerField (cc) y la URL de la imagen.
    r#   zprofile/zprofile/default.pngN)r   correotipoestadoccr   tokenimgpaisciudadarea_idarea_nombreFr   )r   r   select_relatedr   r)   r   r/   r0   r1   r*   r2   r   r3   r4   r   	MEDIA_URLr5   r6   r#   r   )r   usuariosr   usuarios       r   get_usuariosr=   E   s    
 --f5599;;H D  *nLngj//n]CJ;~h(??'+???W_WiT~T~T~Ln*1,@w|D29,H7<..D
 
 	 	 	 	  5))))r   )django.shortcutsr   r   django.httpr   r   django.confr   django.db.modelsr   django.views.decorators.httpr	   	django.dbr
   r   jsonosmodelsr   r   r   r   r    r-   r=    r   r   <module>rH      s    - - - - - - - - 2 2 2 2 2 2 2 2             % % % % % % = = = = = = 1 1 1 1 1 1 1 1  				 + + + + + + + + + +, , ,* * *$* * *>* * * * *r   