Sindbad~EG File Manager
B
���e* � @ s� d dl mZ d dlmZ d dlZd dlmZ d dlmZ d dlZd dlmZ d dl Z d dl m
Z
mZm Z d dlZd dl
Zd dlmZ d d
lmZ G dd� d�ZdS )
� )�Response)�listdirN)�StringIO)�BytesIO)�Workbook)� timedelta�date�datetime)�defaultdict� )�Helperc @ s( e Zd Zddd�Zdd� Zd dd�ZdS )
� XLSEXPORTNc C s( t �� }|�d�}t�� }t�� }|�d�} d}
d}|�r$|rXt|� � �}t|�
� �}nt|d � � �}|}x"|D ]}
| �d||
� |d7 }qrW d}xD|D ]<}
x*|D ]"}| �|
d ||
| � |d7 }q�W d}|
d7 }
q�W |�|� |�
d� t|dddt|� d t|� d t|� d
id�S d S )Nz%Y-%m-%d %H:%MZsheet1r � zapplication/ms-excelzContent-Dispositionzattachment;filename=�_delegates_�_report_z.xls)�mimetype�headers)r �now�strftime�ior �xlwtr � add_sheet�list�keys�values�write�save�seekr �str)�self�conf_key�row_data� file_name�headerr r �outputr �sh�idx�a�row_keys�row�b�i� r, �|C:\Users\Admin\Dropbox\Dev Team\Ramya Works\GITHUB\Common Delegate Registration\common_delegate_v1\core\library\Xlsexport.py�export_singlesheet_xlsD s6
6z XLSEXPORT.export_singlesheet_xlsc # C s� t t�}t t�}t t�}g } x8|D ]0}
||
d �|
� |
d | kr"| �|
d � q"W x|D ]}
||
d �|
� q\W x|D ]}
||
d �|
� q|W t�� }t�� }�x�| D �]�}
g }x"||
D ]}
|
d }|�|� q�W |dk�rHt|�d }ddddd d
ddd
ddg| ddddg }dddddddddddg| dd d!d"g }n`t|�d }dddd#d$d
ddd
dd%g| ddddg }dddd&dddddddg| dd d!d"g }t t�}x$||
D ]}
||
d' �|
� �q�W |
�d(d)�� � }|d d*� d+t|�d*k }|�
|�}d,}d,}x(|D ] }|�d,||� d,}|d-7 }�qW t|�d }t|�}t�d.�}�x>||
D �]0}d,}d,}d,} �x|D �]}!t
|�t
|�k�r~|d/k�r>t
|�t
|�k �r&x�||! D ]`}"|d0 |"d0 k�r�|d1 |"d2 k�r |j|d- |d3|d4� n|�|d- ||"d5 � | d-7 } �q�W n|�|d- |||! � n|�|d- |||! � |d-7 }t
|�| k�rtd,}d,} n|d-7 }nd,}d,} �q�W d,}|d-7 }�qhW q�W |�|� |�d,� t|d6d7d8| d9 id:�S );NZcat_name� full_nameZIC� ZAbs_noZTitleZSynopsiszChief instrutorz
Date of Birth�Agez
Membership NoZEmailZMobilezPresentation typez
Co-InstructorzAssigned EvaluatorszCompleted EvaluatorsZTotalZAverageZabs_no�titleZsynopsisZpresenting_authorZdob�ageZpresenting_membershipnoZpresenting_emailZpresenting_mobileZpresenting_typeZ co_author� total_evaZ evaluatedZtotal_marksZ
percentagezChief authorzpresenting authorz Co-AuthorZchief_authorZe_full_name�/� � z..r r z�pattern: pattern solid, fore_colour yellow;font: colour black, bold True, name Calibri, height 180; align: vert centre, horiz centre;border: left thin,right thin,top thin,bottom thin�
Zabs_idZ
pa_user_idZeva_user_idzN/A)�styleZmarks_totalzapplication/ms-excelzContent-Dispositionzattachment;filename=z.xls)r r )r
r �appendr r r r �len�replace�stripr r Zeasyxf�intr r r )#r Z
abstract_dataZ
marks_dataZ evaluatorZabs_typer"