a
     ld	                     @   s   d dl mZ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mZ d d	lmZ e Zd
d Zdd Zdd ZdS )    )	timedeltadate)settings)get_user_model)EmailMultiAlternatives)render_to_string)RefreshToken)DEFAULT_FROM_EMAIL)SubscriptionCompany)
send_emailc                 C   s   t jj| d}t|j}|jtddd dt	j
t|}t	jrN|jg}nt	j}|j|d}td|d}td	jd
ddt|ddgd}||d |  d S )Nemail   )minutes)lifetimez{}?token={}r   urlzusers/email/email_confirm.htmlcontextzActive user on {title}zVerify Trusted)titlezActive Userzinfo@verifytrusted.comz#verifytrusted.support@sphinxjsc.combcc	text/html)Userobjectsgetr   for_useraccess_tokenset_expr   formatr   USER_ACTIVATION_URLstrIS_PRODUCTIONr   DEFAULT_SEND_TO_EMAILr   r   r	   attach_alternativesend)r   usertokenZ
active_urlsend_to_emailemail_contextrenderedmsg r-   =/var/www/html/Ranjet/backend/verify_trusted/utils/__init__.pysend_activation_email   s$    

r/   c                 C   s:   t d g d}tjj| dj|  }t|ddd d S )Nz
send email)namer   r0   r   zusers/email/day1_tpl.htmlzWelcome to VerifyTrusted!r0   )printr   r   filtervalues_listdistinctr   )r   fieldsZemail_1_daysr-   r-   r.   send_welcome_email*   s    r6   c                 C   s~   t jrdg}d}n
dg}d}| || d}td td||| f  td|d	}td
dt|g d}||d |  d S )Nzadmin@verifytrusted.comz&https://www.verifytrusted.com/reviews/zdoanthanh58863@gmail.comz'https://test.verifytrusted.net/reviews/r   zsend email cancelzNumber of emails: z'users/email/email_account_deactive.htmlr   zRequest cancel account r   r   )r   r#   r1   r   r   r	   r%   r&   )r   r   r)   Z
url_presetr*   r+   r,   r-   r-   r.   send_cancel_email1   s$    
r8   N)datetimer   r   django.confr   django.contrib.authr   django.core.mailr   django.template.loaderr   Zrest_framework_simplejwt.tokensr   Zconfig.settings.baser	   verify_trusted.companies.modelsr
   r   Zverify_trusted.users.tasksr   r   r/   r6   r8   r-   r-   r-   r.   <module>   s   