a
    ;Xh                     @   s@   d dl mZ d dlmZ d dlmZ dd Zdd Zdd	 Zd
S )    )User)transactionNotificationc                    s6   t jjjd} fdd|D }tj| d S )N)idc              	      s   g | ]}t | d dqS )T)senderusermessagenotification_typesend_to_allr   ).0r   r	   r
   r    ?/var/www/viveiro_mudafortebrasil/apps/notifications/services.py
<listcomp>   s   z,send_notification_to_all.<locals>.<listcomp>)r   objectsexcluder   r   bulk_create)r   r	   r
   usersnotificationsr   r   r   send_notification_to_all   s
    r   c                 C   s   t jj| |||d d S )N)r   r   r	   r
   )r   r   create)r   	recipientr	   r
   r   r   r   send_notification_to_user   s    r   c                 C   s(   t jj| |d }|r$|  dS dS )N)r   r   TF)r   r   filterfirstdelete)notification_idr   notificationr   r   r   delete_sent_notification   s
    r   N)	django.contrib.auth.modelsr   	django.dbr   apps.notifications.modelsr   r   r   r   r   r   r   r   <module>   s
   