
    czi	                         d dl Z 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
 d dlmZ d dlmZ d d	lmZ  e       Z e j$                  e      Z G d
 d      Zy)    N)get_user_model)AppointmentNotificationContext)booking_email_context)Company)CompanyContextService)send_email_task)UserProfile)ProfileServicesc                   2    e Zd Ze	 	 dd       Zed        Zy)EmailServiceNc                     |xs i }|j                  t        j                                t        j                  | ||||       y )Nsubjecthtml_contentrecipient_listkeyfiles)updater   get_contextr   delayr   s        J/var/www/html/dp2/backend_v2.1/server/apps/calls/services/email_service.py
send_emailzEmailService.send_email   s@     iR

(4467%)	
    c           	      V   t         j                  j                  |       j                         }|sy t        j                  j                  |       j                         }|st
        j                  d|         y |j                  j                  |      }|s&t
        j                  d|j                   d|         y t        j                  | ||||d|      }|j                  j                  }	t        j                  |      }
t        j!                  d	d
|	gt#        ||
             y )N)
bdc_number)phone_numberz#recipient not found for BDC Number zrecipient not belongs to z against BDC Number F)r   customer_namebooking_datetimeservicecustomer_phonedt_to_pacificcompany)profilezNew Appointment Bookingz$appointment/appointment_booking.html)r   r   r   r   )r   objectsfilterfirstr	   loggerwarninguserbelongs_to_companynamer   buildemailr
   resolve_display_namer   r   r   )r   r   r   r   r    r"   recipient_profilebelongsctxr-   	full_names              r   send_booking_emailzEmailService.send_booking_email&   s#    //((J(?EEG'//66# 7 

%' 	 !NN@MN#((;;GDNN+<<. 4ZLBC ,22!'-)
 "&&,,#88ARS	-?!7%c95	 	  	
r   )NN)__name__
__module____qualname__staticmethodr   r3    r   r   r   r      s0    
 
 
$ .
 .
r   r   )loggingdjango.contrib.authr   /apps.appointments.services.notification_contextr   2apps.appointments.templates.notification_templatesr   apps.companies.modelsr   apps.companies.servicesr   apps.calls.tasks.email_taskr   apps.userprofile.modelsr	   apps.userprofile.servicesr
   User	getLoggerr4   r'   r   r8   r   r   <module>rD      sH     . Z T ) 9 7 / 5 			8	$D
 D
r   