o
    ÎY&jâ  ã                   @   s€   d dl mZ d dlZd dl mZ ddlmZ d dlZd dlmZ d dlmZ d dl	m
Z
 d dlmZ eeƒd	d
„ ƒZdd„ ZdS )é    )ÚreceiverNé   )Úorder_confirmed)Úget_channel_layer)Úasync_to_sync)ÚOrders)ÚShopc           
   
   K   sÞ   zS|  d¡}|  d¡}g }t |› d�¡ tjj|d� ¡ }|r9z|j ¡ }|D ]
}| 	t
|jƒ¡ q(W n   Y tjjd|d� ¡ }td|||dœƒ t d	¡ W d S  tyn }	 zt d
|	› �¡ W Y d }	~	d S d }	~	ww )NÚorder_idÚstore_idz( confirmed and started via custom signal)ÚuuidÚ	Confirmed)Úorder_statusÚstore_uuid__uuidÚnotification)r	   ÚcountÚuser_idszSignal Execution CompletedzSignal Calling Issue: )ÚgetÚloggingÚinfor   ÚobjectsÚfilterÚfirstÚunit_admin_userÚallÚappendÚstrr   r   r   Úsend_db_update_notificationÚ	Exception)
ÚsenderÚkwargsr	   r
   r   ÚshopÚshop_adminsÚiÚorder_countÚe© r%   úB/var/www/html/Testing_prj/Navya-Bakers/orders/signals/receivers.pyÚorder_notification   s*   


ÿ€ÿr'   c                 C   s"   t ƒ }t|jƒdd|| dœƒ d S )NÚnotificationsÚsend_notification)ÚtypeÚmessageÚmsg_type)r   r   Ú
group_send)Úmessage_typeÚmsgÚchannel_layerr%   r%   r&   r   (   s   ýþr   )Údjango.dispatchr   r   Úcustom_signalsr   Úchannels.layersr   Úasgiref.syncr   Úorders.modelsr   Úshops.modelsr   r'   r   r%   r%   r%   r&   Ú<module>   s    
