a
    U@d                     @   sX   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l	m
Z
 dd	 Zd
S )   )*    )date)	timedelta)timezone)	send_mail)Responsec               
   C   s   zt d tjjdt d} | D ]}d|_|  z$tjj	|j
jd}d|_|  W n tjyl   Y n0 tttttttg}|D ]}|jj|j
ddjdd qq"W n2 ty } zt d	|  W Y d }~n
d }~0 0 d S )
Nzcheck subscriptionT)	is_activeZsub_expiry_date__ltF)id)
customerIdZend_date__isnullr   )subscription_typez6An error occurred while checking subscription expiry: )printCustomersSubscriptionsobjectsfilterr   todayr	   saveCustomergetcustomerr
   has_subscriptionDoesNotExistBussinessForSaleHouseWantedForRentInvestmentMyProjectInvestmentMyCompanyPropertyProjectSalePropertyRentPropertyupdate	Exception)Zactive_plansplanZcustomer_objZ	ad_modelsZad_modele r#   5/var/www/html/Sam_Eipo/Eipo/subscription_api/utils.pycheck_subscription_expiry   s"    "r%   N)modelsZcustomer_api.modelsdatetimer   r   django.utilsr   django.core.mailr   Zrest_framework.responser   r%   r#   r#   r#   r$   <module>   s   	