B
    GDbè#  ã               @   s”   d dl mZ d dlmZ d dlT eeƒdd„ ƒZeeƒdd„ ƒZee	ƒdd	„ ƒZ
eeƒd
d„ ƒZeeƒdd„ ƒZeeƒdd„ ƒZeeƒdd„ ƒZdS )é    )Úreceiver)ÚNotification)Ú*c             K   s„   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ i}t| |¡|jj|jtjjd ¡  d S )Nr   ÚWorkflowInstance)ÚcontentÚexception_idÚcontent_type_idÚevent)Újsonr   ÚContentKeysÚAPPLICANT_IDÚget_sender_idÚNOTIFIER_ROLES_IDÚ#get_previous_node_notifier_roles_idÚCURRENT_NOTIFIER_BY_OVERALLÚ#get_previous_node_notify_by_overallÚCURRENT_APPROVER_ROLES_IDÚ"get_current_node_approver_roles_idÚCURRENT_APPROVER_BY_OVERALLÚ%get_previous_node_approver_by_overallÚCURRENT_DEPARTMENTSÚget_previous_node_departmentsÚdumpsÚ	exceptionÚidÚcontent_typeÚWorkflowEventsZON_NEW_WORKFLOWÚsave)ÚsenderÚkwargsr
   Úworkflow_instanceÚ
dictionary© r"   úKG:\easytimepro\master/mysite/notifications\notification_center\receivers.pyÚ!send_notification_on_new_workflow   s    
r$   c             K   s´   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ tjj| ¡ tjj| ¡ tjj| ¡ tjj| ¡ i
}t| |¡|jj|jtjjd ¡  d S )Nr   r   )r   r   r   r	   )r
   r   r   r   r   r   r   r   r   r   r   r   r   Znext_APPROVER_BY_OVERALLZ!get_next_node_approver_by_overallZnext_notify_BY_OVERALLZget_next_node_notify_by_overallZNEXT_APPROVER_ROLES_IDÚget_next_approver_roles_idZNEXT_NOTIFIER_ROLES_IDZget_next_notifier_roles_idr   r   r   r   r   r   r   ÚON_WORKFLOW_NODE_APPROVALr   )r   r   r
   r    r!   r"   r"   r#   Ú"send_notification_on_node_approval   s     
r'   c             K   s’   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ jtjj| ¡ i}t| |¡|jj|jtjjd ¡  d S )Nr   r   )r   r   r   r	   )r
   r   r   r   r   r   r   r   r   r   r   r   r   ZIS_LAST_NODEZget_last_active_nodeZis_last_noder   r   r   r   r   r   r   r&   r   )r   r   r
   r    r!   r"   r"   r#   Ú3send_notification_on_approve_node_instance_by_admin0   s    
r(   c             K   s„   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ i}t| |¡|jj|jtjjd ¡  d S )Nr   r   )r   r   r   r	   )r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚON_WORKFLOW_NODE_REJECTr   )r   r   r
   r    r!   r"   r"   r#   Ú"send_notification_on_node_rejectedD   s    
r*   c             K   s„   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ i}t| |¡|jj|jtjjd ¡  d S )Nr   r   )r   r   r   r	   )r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r)   r   )r   r   r
   r    r!   r"   r"   r#   Ú+send_notification_on_node_rejected_by_adminV   s    
r+   c             K   s   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ tjj| ¡ i}t| |¡|jj|jtjjd ¡  d S )Nr   r   )r   r   r   r	   )r
   r   r   r   r   ÚALL_APPROVER_ROLES_IDÚ(get_all_previous_node_approvers_roles_idr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ZON_WORKFLOW_EXCEPTION_APPROVEDr   )r   r   r
   r    r!   r"   r"   r#   Ú0send_notification_on_workflow_exception_approvedi   s    
r.   c             K   s   dd l }|d }tjj| ¡ tjj| ¡ tjj| ¡ tjj	| 
¡ tjj| ¡ tjj| ¡ tjj| ¡ i}t| |¡|jj|jtjjd ¡  d S )Nr   r   )r   r   r   r	   )r
   r   r   r   r   r,   r-   r   r%   r   Zget_next_node_notifier_roles_idr   r   r   r   r   r   r   r   r   r   r   ZON_WORKFLOW_EXCEPTION_REJECTEDr   )r   r   r
   r    r!   r"   r"   r#   Ú0send_notification_on_workflow_exception_rejected}   s    
r/   N)Zdjango.dispatchr   Z0mysite.notifications.models.notifications_modelsr   Z0mysite.notifications.notification_center.signalsZon_new_workflow_instancer$   Zon_approve_node_instancer'   Z!on_approve_node_instance_by_adminr(   Zon_reject_node_instancer*   Z on_reject_node_instance_by_adminr+   Zon_approve_workflow_exceptionr.   Zon_reject_workflow_exceptionr/   r"   r"   r"   r#   Ú<module>   s   