
    2fh%                     n    d dl mZ d dlmZ d dlmZ d dlmZ d dlZ ej                  e
      Zd ZddZy)	    )EmailMultiAlternatives)render_to_string)settings)
strip_tagsNc           	      D   	 d| j                   sdn| j                   j                   }| j                  j                         xs | j                  j                  | j                  j
                  | j                   r| j                   j                  nd| j                         | j                  t        j                   d| j                   | j                  | j                  d}t        d|      }t        |      }t        ||t        j                   | j
                  g      }|j#                  |d       |j%                          t&        j)                  d	| j
                          y
# t*        $ r/}t&        j-                  d| j
                   d|        Y d}~yd}~ww xY w)zSend invitation email to userzYou're invited to join AimantisNz/accept-invitation/)inviter_nameinviter_emailstructure_namerolemessageinvitation_url
expires_atdays_until_expiryzemails/invitation.htmlsubjectbody
from_emailto	text/htmlzInvitation email sent to Tz#Failed to send invitation email to : F)	structurename
invited_byget_full_nameusernameemailget_role_displayr   r   FRONTEND_URLidr   r   r   r   r   DEFAULT_FROM_EMAILattach_alternativesendloggerinfo	Exceptionerror)
invitationr   contexthtml_contenttext_contentr   es          /backend/structures/utils.pysend_invitation_emailr.   	   sn   "+j>R>RJXbXlXlXqXq+rs '11??AcZEZEZEcEc'2288;E;O;Oj2277UY//1!))!)!6!6 77J:==/Z$//!+!=!=	
 ((@'J!,/ '22  !	
 	  {;

/
0@0@/ABC ::;K;K:LBqcRSs   E$E' '	F0%FFc                    	 d}| j                         xs | j                  | j                  | j                  |r|j                  nd|d}t	        d|      }t        |      }t        ||t        j                  | j                  g      }|j                  |d       |j                          t        j                  d| j                          y# t        $ r/}t        j                  d	| j                   d
|        Y d}~yd}~ww xY w)zSend welcome email to new userz,Welcome to Aimantis - Your Account is Ready!N)	user_name
user_emailr   r   r   zemails/welcome.htmlr   r   zWelcome email sent to Tz Failed to send welcome email to r   F)r   r   r   r   r   r   r   r   r!   r"   r#   r$   r%   r&   r'   )	userr   r   r   r)   r*   r+   r   r,   s	            r-   send_welcome_emailr3   /   s    @ ++->**09innt
 ((=wG!,/&22

|	
 	  {;

,TZZL9: 7

|2aSIJs   CC 	D%DD)NN)django.core.mailr   django.template.loaderr   django.confr   django.utils.htmlr   logging	getLogger__name__r$   r.   r3        r-   <module>r=      s1    3 3   ( 			8	$$Lr<   