3
`                 @   s\   d dl T d dlT d dlT d dlmZ d dlmZ d dlmZ d dl	m
Z
 dd Zdd	 Zd
S )    )*)sendfcmnotification)get_template)EmailMultiAlternatives)settingsc          @   C   s  t d y~|}| }tjj|dj }tjj|dj }|o>|rtjj||d}|ry"tjj|j	j
|jddddd W n* tk
r } zt | W Y d d }~X nX yt|j	jd	d
dd W n* tk
r } zt | W Y d d }~X nX y"tjj|j
j|jddddd W n, tk
r8 } zt | W Y d d }~X nX yt|jdd
dd W n, tk
r| } zt | W Y d d }~X nX dS dS W n* tk
r } zt | dS d }~X nX d S )Nz5adminfunctions.py - in assigndriverforparcel function)id)drivercustomerjobTzDriver Assignedz1Driver has been assigned for your parcel request.unread)usercustomerjobidforcustomernotificationtypenotificationtextstatuscustomerZstatuschangeKwickDeliveryz0Driver has been assigned for your parcel requestzParcel Pickup RequestzYou have one pickup request.)user_idr   	fordriverr   r   r   r   zYou have one pickup requestFi  zInternal Server Error.)status_codestatus_message)printDriverModelobjectsfilterfirstCustomerJob	DriverJobcreateNotificationsr   r   r   	Exceptionr   fcmtokenJsonResponse)r   driverid	driver_idcustomerjob_id
driver_objcustomerjob_objdriverjob_obje r*   >/var/www/html/Stanley/GoodsDelivery/AdminApp/adminfunctions.pyassigndriverforparcel	   s>    
""r,   c             C   s   yd| d t tj d | d | d | d | d }t| || |  }}}	|}
t|d||	g}|j|
d	 |j }t| |d
krdS dS W n( tk
r } zt| dS d }~X nX d S )Nad  
				<html>
				   <head>
				      <title>email-template</title>
				      <link href="https://fonts.googleapis.com/css2?family=Roboto+Slab:wght@700&display=swap" rel="stylesheet">
				      <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600&family=Roboto+Slab:wght@700&display=swap" rel="stylesheet">
				   </head>
				   <body style="background: #f5f5f5;">
				      <table border="0" cellpadding="0" cellspacing="0" style="width: 100%;margin:0 auto;padding: 35px;">
				         <tr>
				            <td>
				               <table cellpadding="0" cellspacing="0" align="center" style="background: #fff;border-collapse:collapse;text-align: center;border-top: 4px solid #9a55ff; padding: 10px;background: #fff;width: 550px;">
				                 
				                  <tr>
				                     <td align="center" height="30"></td>
				                  </tr>
				                  <tr>
				                     <td align="center" height="40">
				                        <span style="font-size:20px;font-weight:700;margin-bottom: 22px;font-family: 'Open Sans',sans-serif;color:#000;">Hello a  </span>
				                     </td>
				                  </tr>
				                  <tr>
				                     <td style="text-align: center;">
				                        <span  style="display:block;margin-bottom:25px;font-family: 'Open Sans', sans-serif;font-size:18px;color:#000;">   Your Account has been Approved by Admin.   </span>
				                     </td>
				                  </tr>
				                  <tr>
				                     <td align="center" height="100">
				                        <img src='a  /static/images/logo1.png' style="width:100px;">
				                     </td>
				                  </tr>
				                  <tr>
				                     <td style="text-align: center;">
				                       
				                        <span  style="color:#000; display:block;margin-bottom:10px;margin-top:20px; font-family: 'Open Sans', sans-serif;font-size:16px;">   Email :  <a href="" target="_blank" style="color:#000;text-decoration:none;font-weight: 600;
				                           ">  a5    </a>   </span>
				                        <span  style="color:#000; display:block;margin-bottom:10px;margin-top:10px; font-family: 'Open Sans', sans-serif;font-size:16px;">   Password :  <a href="" target="_blank" style="color:#000;text-decoration:none;font-weight: 600;
				                           ">  z </a>   </span>
				                        <span  style="color:#000;display:block;margin-bottom:50px;margin-top:10px; font-family: 'Open Sans', sans-serif;font-size:16px;">   Link :  <a href='zq' target="_blank" style="color:#9a55ff;text-decoration:none;font-weight: 600;
				                           ">  z  </a>   </span>
				                     </td>
				                  </tr>
				               </table>
				            </td>
				         </tr>
				      </table>
				   </body>
				</html>

		Ztext_contentz	text/html   TF)strr   WEB_BASE_URLr   r   attach_alternativesendr    )senderemailZrecipientemailsubjectusernameZ	useremailZuserpasswordZloginurlhtml
from_emailtoZhtml_contentmsgresr)   r*   r*   r+   sendnewusermail2   s     (4
r:   N)Customer.modelsDriver.modelsAdminApp.modelsCustomer.commonfunctionsr   django.template.loaderr   django.core.mailr   django.confr   r,   r:   r*   r*   r*   r+   <module>   s   )