a
    ¤Q•hÓ  ã                   @   sž   d dl mZ ddlmZmZmZ d dlmZ d dlZe 	e¡G dd„ dej
ƒƒZG dd	„ d	ejƒZe 	e¡G d
d„ dej
ƒƒZe 	e¡G dd„ dej
ƒƒZdS )é    )Úadminé   )ÚSaidasÚCadastroSaidaÚSaidasEspecies)ÚHttpResponseNc                   @   sN   e Zd ZdZdZdZdgZddgZej	dd�d	d
„ ƒZ
ej	dd�dd„ ƒZdS )ÚSaidasAdmin)Ú	semeaduraÚdata_saidasÚquantidade_saidasÚ
finalizado)r   r
   )Úsemeadura__numero_mudaÚsemeadura__lote__numero_loter	   Úmarcar_como_finalizadoÚexportar_csvzMarcar como finalizado©Údescriptionc                 C   s"   |j dd�}|  ||› d�¡ d S )NT)r   z% registros marcados como finalizados.)ÚupdateÚmessage_user)ÚselfÚrequestÚquerysetÚupdated© r   ú)/var/www/sistema_ama/apps/saidas/admin.pyr      s    z"SaidasAdmin.marcar_como_finalizadoúExportar para CSVc                    s^   t dd�}d|d< t |¡}| dd„ tjjD ƒ¡ |D ] ‰ | ‡ fdd„tjjD ƒ¡ q8|S )Nútext/csv©Úcontent_typezattachment; filename=saidas.csvúContent-Dispositionc                 S   s   g | ]
}|j ‘qS r   ©Úname©Ú.0Úfieldr   r   r   Ú
<listcomp>   ó    z,SaidasAdmin.exportar_csv.<locals>.<listcomp>c                    s   g | ]}t ˆ |jƒ‘qS r   ©Úgetattrr!   r"   ©Úobjr   r   r%      r&   )r   ÚcsvÚwriterÚwriterowr   Ú_metaÚfields©r   r   r   Úresponser,   r   r)   r   r      s    

zSaidasAdmin.exportar_csvN)Ú__name__Ú
__module__Ú__qualname__Úlist_displayÚlist_filterÚsearch_fieldsÚautocomplete_fieldsÚactionsr   Úactionr   r   r   r   r   r   r      s   


r   c                   @   s   e Zd ZeZdZdZdS )ÚSaidasEspeciesInliner   ©Ú
data_vendaN)r2   r3   r4   r   ÚmodelÚextraÚreadonly_fieldsr   r   r   r   r;       s   r;   c                   @   sr   e Zd ZdZdZdZdZegZdddifddd	ifd
ddifdddifdddiffZ	dgZ
ejdd�dd„ ƒZdS )ÚCadastroSaidaAdmin)Únumero_protocoloÚclienteÚempresaÚcidadeÚtelÚdata_criacao)rB   rC   rD   rE   Úcpf_cnpj)rE   Útipo_pagamento)rG   u   InformaÃ§Ãµes do Clienter/   )	rB   Úreferente_nfrC   rD   rH   Úinscricao_estadualÚemailrF   Úcepu   EndereÃ§o e Destino)ÚendrE   Údestino_mudasÚplacaÚresponsavel_recebimentou   InformaÃ§Ãµes do Pedido)rI   Únumero_pedidou   ResponsÃ¡veis TÃ©cnicos)ÚprodutorÚrenasem_produtorÚresponsavel_tecnicoÚrenasem_tecnicoÚOutrosr   r   r   c                    s^   t dd�}d|d< t |¡}| dd„ tjjD ƒ¡ |D ] ‰ | ‡ fdd„tjjD ƒ¡ q8|S )Nr   r   z(attachment; filename=cadastro_saidas.csvr   c                 S   s   g | ]
}|j ‘qS r   r    r"   r   r   r   r%   N   r&   z3CadastroSaidaAdmin.exportar_csv.<locals>.<listcomp>c                    s   g | ]}t ˆ |jƒ‘qS r   r'   r"   r)   r   r   r%   P   r&   )r   r+   r,   r-   r   r.   r/   r0   r   r)   r   r   I   s    

zCadastroSaidaAdmin.exportar_csvN)r2   r3   r4   r5   r7   r6   r@   r;   ÚinlinesÚ	fieldsetsr9   r   r:   r   r   r   r   r   rA   &   s0   ÿÿÿÿÿð
rA   c                   @   s$   e Zd ZdZdZdZddgZdZdS )ÚSaidasEspeciesAdmin)	Úcadastrosaidar	   Únumero_loteÚnome_popularÚ	categoriaÚqtd_especieÚ	valor_uniÚvalor_totalr=   )r]   Únome_cientificor\   r^   )r^   r=   r[   r	   r<   N)r2   r3   r4   r5   r7   r6   r8   r@   r   r   r   r   rZ   T   s
   rZ   )Zdjango.contribr   Úmodelsr   r   r   Údjango.httpr   r+   ÚregisterÚ
ModelAdminr   ÚTabularInliner;   rA   rZ   r   r   r   r   Ú<module>   s   -