o
    IPf                     @   sj   d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ edd Ze d	d
 ZdS )    )shared_task)timezone)	timedelta)	send_mail)User_ProfileNotification)settingsc                  C   s   t   } | tdd }tjj|j|jd}g }d}|rX|D ]:}|j	
d}tjj|jd}|j d| d}|D ]}||j q:d	}	|}tj}
|}t|	||
| td
 qd S d S )N   )days)date_of_birth__monthdate_of_birth__day z%d-%m)organisationz birthday is on z, dont't forget to wishzBirthday reminderz
mails sent)r   nowdater   r   objectsfiltermonthdaydate_of_birthstrftimer   	full_nameappendemailr   EMAIL_HOST_USERr   print)todaytarget_dateupcoming_birthdaysemailsmessagebirthday_personbdate	employeesempsubject
from_emailrecipient_list r(   #/var/www/html/humari/myapp/tasks.py send_birthday_notifications_task	   s(   
r*   c                  C   sv   t   } tjj| d}d}|r7|D ]%}d|j d}d|j }|}tj	}|j
g}t|||| td qd S d S )N)r   r   zBOn behalf of the entire company, I wish you a very happy birthday a   and send you my best wishes for much happiness             in your life. The warmest wishes to a great member of our team. May your special day be full of happiness, fun and cheer! The whole team wishes you the             happiest of birthdays and a great yearzBirthday wish from zwish mail sent)r   r   r   r   r   r   r   r   r   r   r   r   r   )r   	birthdaysr    r!   r%   r&   r'   r(   r(   r)   send_birthday_wish_mail!   s   
r,   N)celeryr   django.utilsr   datetimer   django.core.mailr   myapp.modelsr   r   django.confr   r*   r,   r(   r(   r(   r)   <module>   s    
