
    3"h3                         S SK JrJr  S SKJr  S SKJr  S SKJr  \S 5       r	S SK
r
S SKrS SKrS SKJr  S SKJr  S	S
KJr  S SK
r
S SKrS SKJr  S SKJr  S	S
KJr  Sr\S 5       rg)    )renderget_object_or_404)
connection)Projeto)login_requiredc                 &   U R                   R                  (       al  U R                   R                  (       aQ  [        R                  " U R                   R                  R
                  5        [        [        US9n[        U SSU05      $ [        U SSS9$ )N)idzcadgraph/editor.htmlprojetozcadgraph/erro_permissao.htmli  status)	useris_authenticatedtenantr   
set_schemaschema_namer   r   r   )request
projeto_idr
   s      0/var/www/html/cagpublico_m/cag/cadgraph/views.pyeditor_layoutr      ss    ||$$)<)<gll11==>#G
;g5w8
  	 g=cJJ    N)HttpResponse)csrf_exempt   )dxf_to_svg_stringz?/var/www/html/cagpublico_m/cag/cadgraph/arquivo_teste_conversaoc                 @   U R                   S:X  a  SU R                  ;   a   U R                  S   nUR                  n[        R                  " [
        SS9  [        R                  R                  [
        U5      n[        US5       nUR                  5        H  nUR                  U5        M     S S S 5        [        U5      n[        USS9$ [        SSS9$ ! , (       d  f       N-= f! [         a,  n[        S[        R                  " 5        S	3S
SS9s S nA$ S nAff = f)NPOSTdxfT)exist_okzwb+zimage/svg+xml)content_typez<pre>Erro ao converter: z</pre>z	text/htmli  )r   r   u   Requisição inválidai  r   )methodFILESnameosmakedirs
UPLOAD_DIRpathjoinopenchunkswriter   r   	Exception	traceback
format_exc)r   uploaded_filefilenamedxf_pathfchunk
svg_outputes           r   converter_dxfr5   $   s    ~~EW]]$:	#MM%0M$))H KK
T2 ww||J9H h&!*113EGGEN 4 '
 +84J
II 0== '&  	*9+?+?+A*B&I( 	s6   A$C' )C/C' 
C$ C' '
D1!DDD)django.shortcutsr   r   	django.dbr   projeto.modelsr   django.contrib.auth.decoratorsr   r   r#   tempfiler,   django.httpr   django.views.decorators.csrfr   utils.conversor_svgr   r%   r5    r   r   <module>r?      sa    6   " 9 K K 
   $ 4 2 	  $ 4 2N
> >r   