
    ee!                       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
 ddl d dlZ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 d dlmZ d dl Z d dlZd dl!Z!d dl"Z"d dl#m$Z$ ddl%m&Z& d dl' d dl(Z(ddl)m*Z* ddl+ d dl,m-Z- d dl.Z.d dl/ d dl0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6m7Z7 d dl8m9Z9 d dl:m;Z; d dl<Z<d dlm=Z= d dl>m?Z? ej                  ZAej                  ZC e?eAeC      ZDej                  ZFd ZGd ZHd ZId  ZJdyd!ZK G d" d#e      ZL G d$ d%e      ZM G d& d'e      ZN G d( d)e      ZO G d* d+e      ZP G d, d-e      ZQ G d. d/e      ZR G d0 d1e      ZS G d2 d3e      ZT G d4 d5e      ZU G d6 d7e      ZV G d8 d9e      ZW G d: d;e      ZXd< ZY G d= d>e      ZZ G d? d@e      Z[ G dA dBe      Z\ G dC dDe      Z] G dE dFe      Z^ G dG dHe      Z_ G dI dJe      Z` G dK dLe      Za G dM dNe      Zb G dO dPe      Zc G dQ dRe      Zd G dS dTe      Ze G dU dVe      Zf G dW dXe      Zg G dY dZe      Zh G d[ d\e      Zi G d] d^e      Zj G d_ d`e      Zk G da dbe      Zl G dc dde      Zm G de dfe      Zn G dg dhe      Zo G di dje      Zp G dk dle      Zq G dm dne      Zr	  G do dpe      Zs G dq dre      Zt	  G ds dte      Zu G du dve      Zv G dw dxe=j                        Zxy)z    )message)render)APIView)Responsestatus   )*N)datetime	timedelta)settings)authenticate)User)RefreshToken)django_pbkdf2_sha256)render_to_string)mail)EmailMultiAlternatives)messages)forms)authenticated)FileSystemStorage)TransferToConnectedAccount)SeerUserSerializerFortunerTellerReviewSerializer)ContentSerializerFAQSerializer)FCMNotification)TemplateView)generics)Clientc                    d}t        |      }d}t        j                  j                  | j                        d   }t               }t        |      t        |      z   }|j                  ||       }t        |      dz   |z   S )Nzmedia/fortuneteller_profile)locationz/media/fortuneteller_profiler	   /)r   ospathsplitextnamerandomStringFunctionForImagestrsave)imagefullPathfs	fullPath2filetypetheNametheImageNamefilenames           4/var/www/html/Ryun_Seer/seer/fortune_teller/views.pyuploadTheProfiler5   ,   sq    
'*)GGUZZ(+	%	''l3x=(GGL%(Is8##    c                     t         j                  j                         j                         } | rV| j                  sy| j                  }|dd  }t        |      dz   }t        |      }|j                  d      }dt        |      z   S yNTRANS000001   r	   TRANS)FortuneTellerTranscationsobjectsalllasttranscation_idintr*   zfilllastObjtheIds     r4   generateTranscationsIdFortunerF   9   sy    
#
+
+
/
/
1
6
6
8			
%ab	%E
1%E
%A%	U		r6   c                     t         j                  j                         j                         } | rV| j                  sy| j                  }|dd  }t        |      dz   }t        |      }|j                  d      }dt        |      z   S yr8   )SeerUserTranscationr=   r>   r?   r@   rA   r*   rB   rC   s     r4   generateTranscationsIdrI   H   sy    

%
%
)
)
+
0
0
2			
%ab	%E
1%E
%A%	U		r6   c                     t         j                  j                         j                         } | rV| j                  sy| j                  }|dd  }t        |      dz   }t        |      }|j                  d      }dt        |      z   S y)NPAYOUT000001   r	   PAYOUT)FortunePayoutTranscationr=   r>   r?   r@   rA   r*   rB   rC   s     r4   generatePayoutTranscationsIdrO   W   sy    
"
*
*
.
.
0
5
5
7			
%ab	%E
1%E
%A%	#e*		r6   c                     t         j                  t         j                  z   t         j                  z   dj	                  fdt        |       D              }d|z   S )N c              3   H   K   | ]  }t        j                          y w)N)randomchoice).0_
characterss     r4   	<genexpr>z)generate_referral_code.<locals>.<genexpr>h   s     JMqz2Ms   "FORTUNE)stringascii_uppercaseascii_lowercasedigitsjoinrange)lengthreferral_coderW   s     @r4   generate_referral_coderb   f   sE    $$v'='==MJE&MJJ-r6   c                       e Zd Zd Zy)Registerc           	         	 |j                   }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|st        ddit        j                  	      S |st        dd
it        j                  	      S |st        ddit        j                  	      S |st        ddit        j                  	      S |st        ddit        j                  	      S t        j                  |      }	t        j                  j                  |      j                         }
|
rt        ddit        j                  	      S |rMt        j                  j                  |      j                         }|st        ddit        j                  	      S t        j                  j                  |||||	t                     }
|rHt        j                  j                  |      j                         }|rt        j                  j                         j                         }t         j                  j                  |
|j"                         t         j                  j                  |      j                         }|rCt%        |j&                        t%        |j"                        z   }||_        |j)                          n+t         j                  j                  ||j"                         t*        j                  j                  dd|
       t-        j.                  |
      }|j0                  }dt3        |      z   }t4        j6                  |z   }||
_        |
j)                          d}t;        dd|i      }|}t4        j<                  }|}t?        j@                  ||||g|       tB        j                  j                  |dz   |z   dz   d        t        dd!i      S # tD        $ r0}t        dt3        |      it        jF                  	      cY d }~S d }~ww xY w)"N
first_name	last_nameemailpassworddate_of_birthget_referal_coder   email is requiredr   first_name is requiredlast_name is requiredpassword is requireddate_of_birth is requiredrh   The email is already registered)referal_codezInvalid referal code)rf   rg   rh   rj   ri   rs   fortune_telleramountru   z1You have received your referal bonus successfullyreferal_bonusr   notification_typeru   z#/fortune_teller/email-verify?token=zVerify Accountzemail_verifcation.htmllinkhtml_message z8 fortune teller has been succesfully registered with us.fortune_teller_registerr   typezGYou have been successfully registered with us.Please verify your email.)$datagetr   r   HTTP_400_BAD_REQUESThandlerhashFortuneTellerr=   filterfirstHTTP_409_CONFLICTcreaterb   GeneralSettingsr>   FotuneTellerWalletrefer_friend_offrA   rv   r+   FortuneTellerNotificationsr   for_useraccess_tokenr*   r   BASE_URLemail_verification_linkr   EMAIL_HOST_USERr   	send_mailAdminNotifications	ExceptionHTTP_500_INTERNAL_SERVER_ERROR)selfrequestr   rf   rg   rh   ri   rj   rk   new_passwordfortune_teller_obj
check_coderx   check_wallet
new_amountverify_tokentokenverify_linkcomplete_linksubjectr}   plain_message
from_emailtoes                            r4   postzRegister.postl   s   LT
,,4&:xx$988G5hhz"888O,=hh12
Y236;V;VWW
Y78@[@[\\
Y67v?Z?Z[[
Y56f>Y>YZZ
Y:;6C^C^__,,x(<%--4454AGGIY@AIaIabb''..<L.MSSUZy!78@X@XYY&..55V_fk  {H  R^  lB  lD5  E''..<L.MSSUZ%--11399;m  ''7IQ^QoQo'p'//66
6SYY[l	++,s=3Q3Q/RRz'|!!((
-JhJh(i ((//8k  N  ^p/  q(();<L%%E7#e*DK%%k1M16.& G#$<v}>UVL M))J	BNN7M:t,W%%jnY.F  HB  /B  Ha%  b
Igh
ii	 T
Ic!f%V-R-R
SSTsK   BP P 2P P 0P A!P 1AP  IP 	Q %P;5Q ;Q N__name__
__module____qualname__r    r6   r4   rd   rd   k   s	    MTr6   rd   c                       e Zd Zd Zy)SocialLoginc                    	 |j                   }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }	|r|st        dd	it        j                  
      S |st        ddit        j                  
      S |st        ddit        j                  
      S |st        ddit        j                  
      S |st        ddit        j                  
      S |st        ddit        j                  
      S |	st        ddit        j                  
      S t
        j                  j                  |      j                         }
|
j                  dk(  rt        ddit        j                  
      S |
s/t
        j                  j                  |||||||	t                     }
t        j                  |
      }t        j                         |
_        |
j#                          |
j$                  |
j&                  |
j(                  |
j*                  |
j,                  |
j.                  |
j0                  |
j2                  t5        |      t5        |j6                        d
}t        d|d      S # t8        $ r0}t        dt5        |      it        j:                  
      cY d }~S d }~ww xY w)Nprovider_idrh   rf   rg   	social_iddevice_type	fcm_tokenr   z$Provider and social_id are required.r   rm   rn   rl   zdevice_type is requiredzfcm_token is required)r   r	   AThis account has been deleted.For more information contact admin.)rf   rg   r   r   rh   r   r   rs   
idrf   rg   rh   rj   is_profile_completedis_stripe_account_connectis_stripe_verifiedrefreshaccessSuccessr   r   )r   r   r   r   r   r   r=   r   r   account_deletedr   rb   r   r   r   nowlast_activityr+   r   rf   rg   rh   rj   r   r   r   r*   r   r   r   )r   r   r   r   rh   rf   rg   r   r   r   r   refresh_tokenallDatar   s                 r4   r   zSocialLogin.post   s   EV
,,4-(;88G5&:xx$9xx$9-(;xx$9
YY FGPVPkPkll
Y 89&B]B]^^
Y 78A\A\]]
Y 34V=X=XYY
Y 34V=X=XYY
Y 9:6C^C^__
Y 78A\A\]]
 &--44y4IOOQ((A-Y cdms  nI  nI  J  J
&..55W`luU{Ydzd| 6 ~$  (();<=&.lln##&&$//#--%%'55.CC!3!M!M,??M"=--.
	7 y':
;;	 V
Is1v&v/T/T
UUVsP   B#J0 &J0 J0 $J0 J0 "J0 J0  AJ0 :C5J0 0	K)9%K$K)$K)Nr   r   r6   r4   r   r      s	    FVr6   r   c                       e Zd Zd Zy)LoginMobilec                    	 |j                   }|j                  d      }|j                  d      }|j                  d      }|j                  d      }t        j                  ddd      }|st	        dd	it
        j                  
      S |st	        ddit
        j                  
      S ||z   }t        j                  j                  |      j                         }	|	r,|	j                  dk(  rt	        ddit
        j                  
      S |	s)t        j                  j                  |t                     }	||	_        ||	_        ||	_        t#        j$                         |	_        |	j)                          d|	j                  i}
t	        d|
d      S # t*        $ r0}t	        dt-        |      it
        j.                  
      cY d }~S d }~ww xY w)Ncountry_codephone_numberr   r   i  i'  r:   r   country_code is requiredr   phone_number is required)r   r	   r   )r   rs   otpr   r   )r   r   rS   	randranger   r   r   r   r=   r   r   r   r   rb   r   r   r   r   r   r   r+   r   r*   r   )r   r   r   r   r   r   r   the_otpmobile_numberr   userDatar   s               r4   r   zLoginMobile.post  s   $T
,,4((>*<((>*<xx$9-(;D$*7
Y9:&B]B]^^
Y9:&B]B]^^,.=%--44-4PVVX))Q.i!dent  oJ  oJ  K  K &..55=^t^v5w#"+$/!&.lln# 


 
 8 ix8
99	 T
Ic!f%V-R-R
SSTs2   BF F 'A F BF 	G%G;GGNr   r   r6   r4   r   r     s    %Tr6   r   c                       e Zd Zd Zy)emailVerificationc                     	 |j                   j                  d      }t        j                  j	                  |      j                         }d|_        |j                          t        |d      S # t        $ r}t        |d      cY d }~S d }~ww xY w)Nr   )r   Tzemail_verification_success.htmlzemail_verfication_failed.html)
GETr   r   r=   r   r   email_verifiedr+   r   r   )r   r   r   fortune_Objr   s        r4   r   zemailVerification.get0  s{    :;;??7#5&&---NTTV; $;
:
;;
 :
8
99:s   A+A. .	B7BBBNr   r   r   r   r   r6   r4   r   r   /  s    :r6   r   c                       e Zd Zd Zy)OtpVerificationc                    	 |j                   }|j                  d      }|j                  d      }|j                  d      }|st        ddit        j                        S |st        ddit        j                        S |st        ddit        j                        S ||z   }	 t
        j                  j                  ||	      }t        j                  |      }	|j                  |j                  |j                  |j                  |j                  |j                  |j                   |j"                  t%        |	      t%        |	j&                        d
}
t        d|
d      S # t        $ r(}t        d
i dt        j                        cY d }~S d }~ww xY w# t        $ r0}t        dt%        |      it        j(                        cY d }~S d }~ww xY w)Nr   r   r   r   r   r   r   zotp is required)r   r   zInvalid otpr   r   r   )r   r   r   r   r   r   r=   r   r   r   r   rf   rg   rh   rj   r   r   r   r*   r   r   )r   r   r   r   r   r   r   r   r   r   r   s              r4   r   zOtpVerification.post<  s   T4((>*<((>*<	%3
Y9:&B]B]^^
Y9:&B]B]^^
Y019T9TUU,.=\&..22RU2V  (();<=#&&#..",,$$&44-BB 2 L L+>>=!-,,-
7 iw7
88  \}B7v?Z?Z[[\ 
 T
Ic!f%V-R-R
SSTsa   AF  F ?F F $!E! BF !	F*FFF FF 	G%G	G	GNr   r   r6   r4   r   r   ;  s    Tr6   r   c                       e Zd Zd Zy)	LoginUserc                    	 |j                   }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|st        ddit        j                        S |st        ddit        j                        S t
        j                  j                  |	      j                         }|d
k(  rt        ddit        j                        S t
        j                  j                  |dd      j                         }|j                  dk(  rt        ddit        j                        S |st        ddit        j                        S |j                  }	t        j                  ||	      }
|j                   dk(  rt        ddit        j                        S |
r||_        ||_        t'        j(                         |_        |j-                          t/        j0                  |      }|j2                  |j4                  |j6                  |j8                  |j:                  |j<                  |j>                  |j@                  tC        |      tC        |jD                        d
}t        d|d      S t        ddit        j                        S # tF        $ r0}t        dtC        |      it        jH                        cY d }~S d }~ww xY w)Nrh   ri   r   r   r   rl   r   ro   rq   r   z:This email does not exist in our database, please registerT)rh   r   end_date__isnullr	   r   z=Your account has not been activated, Please contact to admin.FzPlease verify your email firstr   zLogin Successfullyr   zInvalid password)%r   r   r   r   r   r   r=   r   countHTTP_404_NOT_FOUNDr   r   HTTP_401_UNAUTHORIZEDri   r   verifyr   r   r   r   r   r   r+   r   r   r   rf   rg   rh   rj   r   r   r   r*   r   r   r   )r   r   r   rh   ri   r   r   user
fortuneObjcheck_passwordcheckr   r   r   s                 r4   r   zLoginUser.post_  s   -T
,,488G5hhz"8xx$9-(;
Y236;V;VWW
Y56f>Y>YZZ  ''e'4::<4
aiY[\djd}d}~~&&--EW[-\bbd:  A%Y cdms  nI  nI  J  J Y^_gm  hD  hD  E  E''>>>(>255(Y?@HcHcdd$J(J'||~JOO ))*5M--''%%--&;;!+!E!E$77M"=--.
	G 37CDDY12&:V:VWW	 T
Ic!f%V-R-R
SSTsL   A.J 1J AJ  AJ <J AJ )CJ >J 	K$%K	KKNr   r   r6   r4   r   r   ^  s    .Tr6   r   c                       e Zd Zd Zy)FortuneTellerForgetPasswordc           	         	 |j                   }|j                  d      }|st        ddi      S t        j                  j                  |      j                         }|dk(  rt        ddit        j                        S t        j                  j                  |      j                         }|rdj                  t        d	      D cg c]6  }t        j                  t        j                  t        j                   z         8 c}      }d
t#        |j$                        z   dz   |z   }t#        t&        j(                        |z   }	||_        |j-                          d}
t/        dd|	i      }|}t&        j0                  }|}t3        j4                  |
|||g|       t        ddi      S t        ddi      S c c}w # t6        $ r;}t9        |       t        dt#        |      it        j:                        cY d }~S d }~ww xY w)Nrh   r   zEmail is requiredrq   r   zPThis email does not exist in our database, please enter the valid email address.r   rQ      z/fortune_teller/forgot/r$   zForgot Passwordzforget_password_email.htmlr{   r|   z8Reset password link has been sent to this email address.zEmail not exists)r   r   r   r   r=   r   r   r   r   r   r^   r_   rS   rT   rZ   ascii_lettersr]   r*   rh   r   r   forgot_password_linkr+   r   r   r   r   r   printr   )r   r   r   rh   r   r   nran_numbaselinkcompletelinkr   r}   r   r   r   r   s                   r4   r   z FortuneTellerForgetPassword.post  s   U<<DHHWEi 3455!!((u(5;;=Dqyi rs  |B  |U  |U  V  V''..U.;AACJwwUZ[]U^_U^PQf&:&:V]]&JKU^_`W*S1A1A-BBSH7RX))*X5\'/Z$__ W$%AFLCYZ\!]**Z
R	^^G]J<Xi Z[\\i 2344 `  U	!HYs1v&f.S.STTUsC   +F7 AF7 >AF7 ;F2B#F7 %F7 2F7 7	G; 0G60G;6G;Nr   r   r6   r4   r   r     s    Ur6   r   c                       e Zd Zd Zd Zy)forgetPasswordVerificationc                    t        | j                  j                        }|j                  d      d   }t        j
                  j                  |      j                         }|j                  dk(  rt        |d      S t        j
                  j                  ||      j                         }|rd}nd}t        |d	d
|i      S )Nr$   rq   
LinkExpirylink-expire.html)rh   r   TFforgot.htmlvalid)
r*   r   r&   splitr   r=   r   r   r   r   )r   r   r{   
user_emaillink_expiryfortune_objr   s          r4   r   zforgetPasswordVerification.get  s    	T\\	$zz#r"*%%,,Z,@FFH+%%5
+
,,%%,,ZX\,]cce+55	wuo	66r6   c                 \   t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }t        | j                  j                        }|j                  d      d   }t        j                  |      }t        j                  j                  |      j                         }|r@||_        d|_        |j%                          t'        j(                  |d       t+        |d      S y t+        |d	d
|i      S )Nr   confirm_new_passwordr$   rq   r   zChanged successfullyzpassword_success.htmlr   form)r   forgetverificationPOSTis_validcleaned_datar   r*   r   r&   r   r   r   r   r=   r   r   ri   r   r+   r   successr   )	r   r   r  r   r   r{   r   encrypt_passwordr   s	            r4   r   zforgetPasswordVerification.post  s    		!	!',,	/$	]]_##''7<++//0FG
dll
 4

3#:ll<0&&--j-AGGI;+K'3K$W45'122  -&$
88r6   Nr   r   r   r   r   r   r6   r4   r   r     s    79r6   r   c                       e Zd Zd Zy)
getProfilec                 \   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        |      j                  }t        j                  j                  |      }t        |d      j                  }t        d||d	      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)
Nr   r   r   user not foundrw   Tmanyr   )r   r   reviews)r   r   r   r*   r   r   r   r=   r   r   r   FortuneTellerSerializerr   FortunetellerRatingReviewsr   r   )r   r   uidr   r   r   
review_objreview_datas           r4   r   zgetProfile.get  s   TL

 C $$++s+399;;
Y 01&:S:STT";/447*22999U:/
EJJ;
iwM
NN  LYs1v&f.J.JKKL 
 T
Ic!f%V-R-R
SSTN   B6 AC2 AC2 6	C/?%C*$C/%C2 *C//C2 2	D+;%D& D+&D+Nr   r   r6   r4   r
  r
        Tr6   r
  c                       e Zd Zd Zy)getServicesc                    	 t         j                  j                  dd      }t        |d      j                  }t        d|d      S # t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY wNT)r   r   r  r   r   r   r   )
Servicer=   r   ServiceSerializerr   r   r   r*   r   r   )r   r   servicesserialized_servicesr   s        r4   r   zgetServices.get  ss    Voo$$D4$H8*8$?DD
y2EF
GG	 V
Is1v&v/T/T
UUV   AA 	B%A<6B<BNr   r   r6   r4   r  r        Vr6   r  c                       e Zd Zd Zy)	getSkillsc                    	 t         j                  j                  dd      }t        |d      j                  }t        d|d      S # t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY wr  )
Skillr=   r   SkillSerializerr   r   r   r*   r   r   )r   r   skillsserialized_skillsr   s        r4   r   zgetSkills.get  ss    VMM  t D6&vD9>>
y2CD
EE	 V
Is1v&v/T/T
UUVr   Nr   r   r6   r4   r#  r#    r!  r6   r#  c                       e Zd Zd Zy)FortuneTellerCompleteProfilec                 	   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }|j                  d      }|j                  d      }|j                  d      }	|j                  d	      }
|j                  d
      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }t        j                  j                  |
      j                  |j                        j                         }|rt        ddit        j                        S |st        ddit        j                         S |st        ddit        j                         S |
st        ddit        j                         S |st        ddit        j                         S |st        ddit        j                         S |	st        ddit        j                         S |st        ddit        j                         S |st        ddit        j                         S |st        ddit        j                         S |st        ddit        j                         S |st        ddit        j                         S t#        t$        |j'                  d            \  }}}t)        ||      }t+        |      }t-        |      }t.        j                  j                  |       j                         }t0        j                  j                  |!      j                         }t2        j                  j                  |"      j                         }t4        j                  j7                  ||||#      }||_        |	|_        ||_        |
|_        ||_         ||_!        ||_"        ||_#        ||_$        ||_%        d$|_&        ||_'        ||_(        |rtS        |      }t        |      |_*        |jW                          t        dd%i      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        jX                        cY d }~S d }~ww xY w)&Nr   r   r  Fortune teller not foundr  r'  rf   rg   rh   genderrj   total_experiencebio	languagesr,   bank_detailstimezonerq   rr   services is requiredskills is requiredrl   zgender is requiredrm   rn   rp   total_experience is requiredbio is requiredlanguages is requiredztimezone is required-)	horoscope)chinese_zodiac)element_name)ru   r9  r:  five_elementTr   )-r   r   r   r*   r   r   r   r=   r   r   r   r   r   excluder   r   r   maprA   r   get_astrological_signget_chinese_zodiacget_five_element	HoroscopeChineseZodiacFiveElementsFortuneTellerSignDetailr   rf   rg   rj   rh   r-  r  r'  r.  r/  r0  r   r1  r2  r5   r,   r+   r   )r   r   r  r   ru   r   r  r'  rf   rg   rh   r-  rj   r.  r/  r0  r,   r1  r2  r   yearmonthdayr9  zodiacelementhoroscope_objchinese_objelements_objsign_detailfileUrls                                  r4   r   z!FortuneTellerCompleteProfile.post  sk   ]VN

 C "))00C08>>@>
Y :;FD]D]^^
,,4hhz"8HHX6&:xx$988G5HHX688O,=hh12	%3xx$988G5((>*<hhz"8%--4454AII^M^M^I_eegY@AIaIabb
Y 67@[@[\\
Y 45f>Y>YZZ
Y 34V=X=XYY
Y 45f>Y>YZZ
Y 89&B]B]^^
Y 78A\A\]]
Y ;<VE`E`aa
Y >?HcHcdd
Y 126;V;VWW
Y 78A\A\]] Y 67@[@[\\ #}223784$S%09t$6d#7$$++i+@FFH=''..f.EKKM;&&--7-CIIK<(0077~`m l 8 <;)>'>"/>>!>%>!>%5>">'>)->&!->%>U#GWN
Iy)
**q  NYA'0L0LMMNr 
 V
Is1v&v/T/T
UUVs   R AS ES +S 
S )S S 'S S %S S #S S !S  FS 	S %R;5S 6S ;S  S 	S<%S71S<7S<Nr   r   r6   r4   r*  r*    s	    ^Vr6   r*  c                       e Zd Zd Zy)FortuneTellerEditProfilec                 v   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }|j                  d      }|j                  d      }|j                  d      }	|j                  d	      }
|j                  d
      }|j                  d      }|j                  d      }|j                  d      }t        d|       |st        ddit        j                        S |st        ddit        j                        S |st        ddit        j                        S |	st        ddit        j                        S |
st        ddit        j                        S |st        ddit        j                        S |st        ddit        j                        S ||_        |	|_        ||_        ||_        |
|_        ||_        ||_        ||_        |r||_        |j1                          t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j2                        cY d }~S d }~ww xY w)Nr   r   r  r,  r  r'  rf   rg   r.  r/  r0  r,   r1  zimage============r3  r4  rm   rn   r5  r6  r7  r   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   r   rf   rg   r  r'  r.  r/  r0  r1  r,   r+   r   )r   r   r  r   ru   r   r  r'  rf   rg   r.  r/  r0  r,   r1  s                  r4   r   zFortuneTellerEditProfile.postZ  sy   =VN

 C "))00C08>>@>
Y :;FD]D]^^
,,4hhz"8HHX6&:xx$9hh12	%3xx$988G5((>*<	U#
Y 67@[@[\\
Y 45f>Y>YZZ
Y 89&B]B]^^
Y 78A\A\]]
Y >?HcHcdd
Y 126;V;VWW
Y 78A\A\]]  *>'>%>!>%5>">'>!->N
Iy)
**q  NYA'0L0LMMNr 
 V
Is1v&v/T/T
UUVsy   I AI? CI? +I? 
I? )I? I? 'I? I? %AI? 	I<%I71I<2I? 7I<<I? ?	J8%J3-J83J8Nr   r   r6   r4   rQ  rQ  Y  s    >Vr6   rQ  c                 B    t        t        |       | j                        S )N)key)maxsetr   )lsts    r4   most_commonrX    s    CH#))$$r6   c                       e Zd Zd Zy)AddMbtic                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        |j                  j                  d            }t        d|       |st        ddit        j                        S t        t!        |            }t        |j                  j                  d            }t        d|       |st        ddit        j                        S t        t!        |            }t        |j                  j                  d	            }	t        d	|	       |	st        dd
it        j                        S t        t!        |	            }
t        |j                  j                  d            }t        d|       |st        ddit        j                        S t        t!        |            }||z   |
z   |z   }t"        j                  j                  |d      j                         }t$        j                  j                  |      j'                  |       t        dd|j(                   d| dd      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j*                        cY d }~S d }~ww xY w)Nr   r   r  r,  extraversion_introversionz%extraversion_introversion is requiredsensing_intuitionzsensing_intuition is requiredthinking_feelingzthinking_feeling is requiredjudging_perceivingzfourth array is requiredT)	mbti_namer   rw   )mbtir   zYou are (z) type!r   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   r   rX  evalMBTIrE  updatetagliner   )r   r   r  r   ru   r\  first_pair_mbtir]  second_pair_mbtir^  third_pair_mbtir_  fourth_pair_mbticreated_mbti
fetch_mbtis                  r4   r   zAddMbti.post  s   +VN

 C "))00C08>>@>
Y :;FD]D]^^"7<<#3#34O#PQ	$%>?
#Y GHQWQlQlmm &?!@A?7<<++,?@A	./
Y ?@IdIdee!$'8"9:',,**+=>?	,-
Y >?HcHcdd &6!78?GLL,,-ABC	01
Y :;FD_D_``!$'9":;!$44FIYY<##PT#U[[]:""))>)JQQYcQe
y(:;M;M:NaP\~]d0ef
ggK  NYA'0L0LMMNN 
 V
Is1v&v/T/T
UUVsj   I0 AJ, AJ, *A"J, A"J, 0A"J, BJ, 0	J)9%J$J)J, $J))J, ,	K%5%K K% K%Nr   r   r6   r4   rZ  rZ    s    ,Vr6   rZ  c                       e Zd Zd Zy)UploadImagesc                 F   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }g }|D ]  }t        |      }	|j                  |	         t        d|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r   r  r,  imagesr   r   )r   r   r   r*   r   r   r   r=   r   r   r   r   getlistr5   appendr   )
r   r   r  r   ru   r   rp  
image_urlsr,   
image_paths
             r4   r   zUploadImages.post  s   VN

 C "))00C08>>@>
Y :;FD]D]^^
,,4LL"6:u!%(Jj!  y
;
<<+  NYA'0L0LMMN, 
 V
Is1v&v/T/T
UUVsN   B+ AC' AC' +	C$4%CC$C' C$$C' '	D 0%DD D Nr   r   r6   r4   rn  rn    s    Vr6   rn  c                       e Zd Zd Zy)FortuneTellerDeleteAccountc                 \   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                          t        j                  j                  |j                  dz   |j                  z   dz   d       t        dd	i      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                         cY d }~S d }~ww xY w)
Nr   r   r  r,  r~   z* fortune teller has deleted their account.fortune_teller_delete_accountr   zAccount deleted successfully)r   r   r   r*   r   r   r   r=   r   r   r   deleter   r   rf   rg   r   )r   r   r  r   ru   s        r4   r   zFortuneTellerDeleteAccount.get  s   VN

 C "))00C08>>@>
Y :;FD]D]^^$$^-F-Fs-J>KcKc-c  eQ  .Q  Wv$  w
I=>
??  NYA'0L0LMMN 
 V
Is1v&v/T/T
UUVr  Nr   r   r6   r4   rv  rv    s    Vr6   rv  c                       e Zd Zd Zy)GetFortunetellerFaqc                 &   	 t         j                  j                  dd      j                  d      }t	        |d      j
                  }t        d|d      S # t        $ r0}t        dt        |      it        j                  	      cY d }~S d }~ww xY w)
NTFortuneteller)r   r   -idr  r   r   r   r   )Faqr=   r   order_byr   r   r   r   r*   r   r   )r   r   faq_objall_datar   s        r4   r   zGetFortunetellerFaq.get  s}    T[[$OLUUV[\7G.338
ix8
99	 T
Ic!f%V-R-R
SSTs   AA 	B %BBBNr   r   r6   r4   r{  r{        Tr6   r{  c                       e Zd Zd Zy)GetFortunetellerBlogc                    	 t         j                  j                  d      j                         }t	        |      j
                  }t        d|d      S # t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)NBlog)	page_typer   r   r   r   ContentManagementr=   r   r   r   r   r   r   r*   r   r   r   r   content_objr   r   s        r4   r   zGetFortunetellerBlog.get  sx    T#++22V2DJJL;[)..7
iw7
88	 T
Ic!f%V-R-R
SSTs   AA 	B%BBBNr   r   r6   r4   r  r    r  r6   r  c                       e Zd Zd Zy)GetFortunetellerPrivacyPolicyc                     	 t         j                  j                  dd      j                         }t	        |      j
                  }t        d|d      S # t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)NzPrivacy Policyfortunetellerr  	user_typer   r   r   r   r  r  s        r4   r   z!GetFortunetellerPrivacyPolicy.get  s|    T#++22=MXg2hnnp;[)..7
iw7
88	 T
Ic!f%V-R-R
SST   AA 	B%BBBNr   r   r6   r4   r  r    r  r6   r  c                       e Zd Zd Zy)GetFortunetellerTermsc                     	 t         j                  j                  dd      j                         }t	        |      j
                  }t        d|d      S # t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)NzTerms & conditionsr  r  r   r   r   r   r  r  s        r4   r   zGetFortunetellerTerms.get!  s|    T#++22=Q\k2lrrt;[)..7
iw7
88	 T
Ic!f%V-R-R
SSTr  Nr   r   r6   r4   r  r     r  r6   r  c                       e Zd Zd Zy)ResetPasswordc                 r   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }|j                  d      }|st        ddit        j                        S |st        ddit        j                        S |j                  }t        j                   ||      }	t        j"                  |      }|	r$||_        |j%                          t        dd	i      S t        dd
it        j&                        S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j(                        cY d }~S d }~ww xY w)Nr   r   r  r,  old_passwordr   zold_password is requiredznew_password is requiredr   zThe old password is incorrect)r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   ri   r   r   r   r+   HTTP_403_FORBIDDENr   )
r   r   r  r   ru   r   r  r   r   r   s
             r4   r   zResetPassword.post+  s}   VN

 C "))00C08>>@>
Y :;FD]D]^^
,,4((>*<((>*<
Y :;FD_D_``
Y :;FD_D_``"++>>>,~65,,|,<*NY	*++Y ?@IbIbcc+  NYA'0L0LMMN. 
 V
Is1v&v/T/T
UUVsa   E AE= AE= (E= AE= $E= 	E:
%E5/E:0E= 5E::E= =	F6%F1+F61F6Nr   r   r6   r4   r  r  *  s    Vr6   r  c                       e Zd Zd Zy)NotificationSettingsc                 f   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }|st        ddit        j                        S ||_        |j                          t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                         cY d }~S d }~ww xY w)Nr   r   r  r  notification_statusznotification_status is requiredr   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   r  r+   r   )r   r   r  r   ru   r   r  s          r4   r   zNotificationSettings.postK  s   TN

 C "))00C08>>@>
Y 01&:S:STT
,,4"78
Y@AIdIdee(;>%
Ii(
))  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTS   B; AC7 ;C7 #C7 ;	C4%C/)C4*C7 /C44C7 7	D0 %D+%D0+D0Nr   r   r6   r4   r  r  J  s    Tr6   r  c                       e Zd Zd Zy)FortunetellerHelpSupportc                 X   	 	 t        |      }t        j                  j                  |      j                         }|j                  }|j                  d      }|j                  d      }|st        ddit        j                        S |st        ddit        j                        S |st        ddit        j                        S t        j                  j                  |||       t         j                  j                  |j"                  d	z   |j$                  z   d
z   d       t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j&                        cY d }~S d }~ww xY w)Nr   r   r  titler  ztitle is requiredzmessage is required)r  r   ru   r~   z, fortune teller requested a help & support .fortune_teller_help_supportr   zMYour request has been submitted successfully. We will revert you back sortly.)r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   HelpSupportr   r   rf   rg   r   )r   r   r  r   ru   r   r  r   s           r4   r   zFortunetellerHelpSupport.postb  s   VN

 C "))00C08>>@>
,,488G5XXi 7
Y 01&:S:STT
Y236;V;VWW
Y45V=X=XYYE'X$$^-F-Fs-J>KcKc-c  eS  .S  Yv$  w
Imn
oo#  NYA'0L0LMMN$ 
 ViA'v/T/TUUVsZ   D4 A:E0 	E0 (E0 A,E0 4	E-=%E("E-#E0 (E--E0 0	F)9%F$F)$F)Nr   r   r6   r4   r  r  a  s    Vr6   r  c                       e Zd Zd Zy)GetFortunetellerNotificationsc                 P   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                  |d      j                  d      }t        |d      j                  }t        d	|d
      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r   r  r  T)ru   r   r~  r  r   r   )r   r   r   r*   r   r   r   r=   r   r   r   r   r  FortuneNotificationSerializerr   r   )r   r   r  r   ru   notification_objr  s          r4   r   z!GetFortunetellerNotifications.get|  s   TN

 C "))00C08>>@>
Y 01&:S:STT088??Q_sw?x  B  B  CH  I+,<$GLL8
ix8
99  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTsN   B0 AC, AC, 0	C)9%C$C)C, $C))C, ,	D%5%D D% D%Nr   r   r6   r4   r  r  {  s    Tr6   r  c                       e Zd Zd Zy)DeleteFortuneNotificationsc                 z   	 	 t        |      }t        j                  j                  |      j                         }|j                  j                  d      }|st        ddit        j                        S t        j                  j                  |      j                  t        j                                 t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j"                        cY d }~S d }~ww xY w)Nr   r   r  r   zid is required)end_dater   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   re  r   r   r   )r   r   r  r   ru   notification_ids         r4   r   zDeleteFortuneNotifications.post  s
   TN

 C "))00C08>>@>\\%%d+?
Y/08S8STT%%,,,@GGQYQ]Q]Q_G`
Ii(
))  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTsN   C A'D 6AD 	C>%C93C>4D 9C>>D 	D:
%D5/D:5D:Nr   r   r6   r4   r  r    r  r6   r  c                       e Zd Zd Zd Zy)FortunetellerTimeSlotsc                 
   	 	 t        |      }t        j                  j                  |      j                         }t        j                  j                  |      j                         }t        |      j                  }t        d|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r   r  rw   r   r   )r   r   r   r*   r   r   r   r=   r   r   FortuneTellerTimingFortuneTimingSerializerr   r   )r   r   r  r   ru   fortune_teller_timeserialize_times          r4   r   zFortunetellerTimeSlots.get  s    TN

 C "))00C08>>@>,44;;>;Z``b+,?@EE>
y.A
BB  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTsG   B A>C	 	C%C;C<C	 CC	 		D%C=7D=Dc                    	 	 t        |      }t        j                  j                  |      j                         }|j                  }|j                  d      }|st        ddit        j                        S t        j                  j                  |      j                         }|s t        j                  j                  |      }||_        |j!                          t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j"                        cY d }~S d }~ww xY w)Nr   r   r  slotszslots is requiredrw   r   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r  r   r  r+   r   )r   r   r  r   ru   r   r  r  s           r4   r   zFortunetellerTimeSlots.post  s3   TN

 C "))00C08>>@>
,,488G5
Y236;V;VWW,44;;>;Z``b
-55<<N<["
Ii(
))  NYA'0L0LMMN  
 T
Ic!f%V-R-R
SSTsN   C, A)D( 8A3D( ,	D%5%D D%D(  D%%D( (	E!1%EE!E!Nr  r   r6   r4   r  r    s    TTr6   r  c                       e Zd Zd Zy)AppointmentRequestListc                 R   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                  |dd      j                  d      }t        |d	      j                  }t        d
|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r   r  r,  PendingT)ru   appointment_statusis_paidr~  r  r   r   )r   r   r   r*   r   r   r   r=   r   r   r   FortuneAppointmentBookr   AppointmentRequestListSerializerr   r   )r   r   r  r   ru   appoint_objserialize_datas          r4   r   zAppointmentRequestList.get  s   TN

 C "))00C08>>@>
Y :;FD]D]^^'//66nhqz~6  I  I  JO  P;4[dKPP>
y.A
BB  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTsN   B1 AC- AC- 1	C*:%C%C* C- %C**C- -	D&6%D!D&!D&Nr   r   r6   r4   r  r    r  r6   r  c                       e Zd Zd Zy)AppointmentDetailsc                    	 	 t        |      }t        j                  j                  |      j                         }|j                  }|j                  d      }|st        ddit        j                        S t        j                  j                  ||d      j                         }|st        ddit        j                        S t        |      j                   }t"        j                  j                  |j$                  j&                        j                         }	|	st        dd	it        j                        S t)        |	      j                   }
|
|d
}t        d|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j*                        cY d }~S d }~ww xY w)Nr   r   r  appointment_idappointment id is requiredr  )ru   r   r  Appointment not foundr  )	user_dataappointment_datar   r   )r   r   r   r*   r   r   r   r=   r   r   query_paramsr   r   r  r   r  r   SeerUser	seer_userr   r   r   )r   r   r  r   ru   r   r  r  r  seer_user_objr  combined_datas               r4   r   zAppointmentDetails.get  s    VN

 C "))00C08>>@>


4HH-.>
Y <=fFaFabb'//66nYg  }F6  G  M  M  O;
Y 78AZAZ[[6{CHH##**k.C.C.F.F*GMMO=
Y 01&:S:STT!-0559 (= y-@
AA7  NYA'0L0LMMN8 
 V
Is1v&v/T/T
UUVs[   E% A)F! 8AF! A5F! ='F! %	F.%FFF! FF! !	G*%GGGNr   r   r6   r4   r  r    s    !Vr6   r  c                       e Zd Zd Zy)AcceptOrDeclineAppointmentc           	         	 	 t        |      }t        j                  j                  |      j                         }|j                  }|j                  d      }|j                  d      }|st        ddit        j                        S |st        ddit        j                        S |dk(  s|d	k(  r|dk(  r$t        j                  j                  ||
      j                         }|st        ddit        j                        S ||_        |j!                          t"        j                  j                  |      j                         }	|	j$                  rBt&        j(                  t*        _        t*        j.                  j1                  |	j$                         t2        j                  j                  |j4                  j6                        j                         }
t8        j                  j;                  d|j<                  z   dz   d|
       |
j>                  r"|
j@                  }t        t&        jB                        }|
jD                  dk(  r3ddd|j<                  z   dz   d}tG        |      jI                  ||      }|
jD                  dk(  rd}d|j<                  z   dz   }ddd|j<                  z   dz   d}tG        |      jI                  ||||      }n`|j                  j                  d      }|st        ddit        j                        S t        j                  j                  ||
      j                         }|st        ddit        j                        S t2        j                  j                  |j4                  j6                        j                         }
||_        ||_%        d|_&        |j!                          t"        j                  j                  |      j                         }	|	j$                  s,tN        j                  j;                  ||jP                  d       t8        j                  j;                  d|j<                  z   dz   d|
       |
j>                  r|
j@                  }t        t&        jB                        }|
jD                  dk(  r3ddd|j<                  z   dz   d}tG        |      jI                  ||      }|
jD                  dk(  rId}d|j<                  z   dz   }ddd|j<                  z   dz   d}tG        |      jI                  ||||      }d }tS        d!|j<                  |jT                  jV                  d"z   |jT                  jX                  z   |jZ                  j\                  |jP                  |d#      }|}t&        j^                  }|j4                  j`                  }tc        jd                  ||||g|$       t        j                  j                  ||
      j                         }t8        j                  j;                  d|j<                  z   dz   d|
       t        dd%i      S t        dd&i      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        jf                        cY d }~S d }~ww xY w)'Nr   r   r  r   status_typer  zstatus_type is requiredAcceptedDeclined)r   ru   r  bookingzYour appointment z  has been accepted successfully.appointment_bookingr   rz   r  Androidr  APPOINTMENT STATUSr   r  r   api_keyregistration_iddata_messageIos)r  r  message_titlemessage_bodyr  cancellation_reasonzCancellation reason is requiredFortuner   appointmentrefund_amountcancellation_chargesz has been declined.zAppointement Cancelledzappointment_cancelled.htmlr~   )
appoint_idfortune_teller_nameservice_namepricecancel_reasonr|   r   z&Status type must be Accepted/Declined )4r   r   r   r*   r   r   r   r=   r   r   r   r   r   r  r   r  r+   rH   	charge_idr   STRIPE_SECRET_KEYstriper  Chargecapturer  r  r   SeerUserNotificationsr   r  r  r   FIREBASE_SERVER_KEYr   r   notify_single_devicer  cancelled_byAdminRefundRequestr  r   ru   rf   rg   servicer  r   rh   r   r   r   )r   r   r  r   ru   r   r  r  appointment_objtransaction_objseer_objr  
server_keyr  resultr  r  r  r   r}   r   r   r   s                          r4   r   zAcceptOrDeclineAppointment.post  s   ATL

 C "))00C08>>@>
,,4HHTN>-(;
Y;<FD_D_``
Y89A\A\]]Z;*#<j -55<<^l<mssu_y"9:6C\C\]]*5_'*2299/9RXXZ_!!11fnmmO556 !!((O,E,E,H,H(IOOQX""))2EoFdFd2d  fH  3H  [p  |D)  E$$ **ox334j				*!5+,_-K-KKLnn|
  
3HHYh  yEH  Fv				&,}*?+I+IIJll|!5+,_-K-KKLnn|  
3HHYh  yF | I =v #<<++,ABy"CDVMfMfgg-55<<^l<mssu_y"9:6C\C\]]!!((O,E,E,H,H(IOOQX( +6_'+>_($-_!*2299/9RXXZ_%%  ''ORaRgRg}~'""))2EoFdFd2dez2z  Nc  ow)  x$$ **ox334j				*!5+,_-K-KKLaa|
  
3HHYh  yEH  Fv				&,}*?+I+IIJ__|!5+,_-K-KKLaa|  
3HHYh  yF | I =v'W$%ARaRpRp  HW  Hf  Hf  Hq  Hq  ru  Hu  vE  vT  vT  v^  v^  H^  n}  nE  nE  nR  nR  [j  [p  [p  AT  DU  V\!]**Z

#
#
)
)R	^^G]J<X-55<<^l<mssu_""))2EoFdFd2dez2z  Nc  ow)  xYy)**YGHIIy  LYs1v&f.J.JKKLz 
 T
Ic!f%V-R-R
SSTso   Y A:Z 	Z (AZ HZ AZ %K$Z 
Z 	Z %ZZZ ZZ 	[%[[[Nr   r   r6   r4   r  r    s	    BTr6   r  c                       e Zd Zd Zy)PastUpcomingAppointmentsc                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  j                  d      }|st        ddit        j                        S |dk(  rHt        j                  j                  |d	      j                  d
      }t!        |d      j"                  }nXt        j                  j                  |      j%                  ddg      j                  d
      }t!        |d      j"                  }t        d|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j&                        cY d }~S d }~ww xY w)Nr   r   r  r,  appoint_typezappointment_type is requiredacceptedr  )ru   r  r~  Tr  rw   r  appointment_status__inr   r   )r   r   r   r*   r   r   r   r=   r   r   r   r  r   r   r  r  r  r   r=  r   )r   r   r  r   ru   r  r  r  s           r4   r   zPastUpcomingAppointments.get  s   TN

 C "))00C08>>@>
Y :;FD]D]^^&&**>:<
Y=>fFaFabbj (0077~is7t}}  D  EK5ktLQQN(0077~7V^^  xA  CM  wN^  O  X  X  Y^  _K5ktLQQN
y.A
BB  NYA'0L0LMMN  
 T
Ic!f%V-R-R
SSTsT   E AF 9F B2F 	F%E<6F7F <FF 	F=%F82F=8F=Nr   r   r6   r4   r  r        Tr6   r  c                       e Zd Zd Zy)AddMoneyFortuneWalletc                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }|st        ddit        j                        S |j                  d      }|st        ddit        j                        S t        j                  t         _        t         j$                  j'                  t)        |      d	z  d
|d      }|j*                  j                         }	|	r/|	xj,                  t)        |      z  c_        |	j/                          n!t0        j                  j'                  ||       t2        j                  j'                  |j4                  dz   |j6                  z   dz   d       t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t         j8                  j:                  $ r0}t        dt        |      it        j                        cY d }~S d }~wt        $ r0}t        dt        |      it        j<                        cY d }~S d }~ww xY w)Nr   r   r  r,  payment_tokenzpayment_token is requiredrv   zamount is requiredd   usdzAdding money to wallet)rv   currencysourcedescriptionrt   r~   z, fortune teller added money to their wallet.fortuneteller_walletr   z"Money added to wallet successfully)r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   r   r  r  r  r  r   rA   walletrv   r+   r   r   rf   rg   error	CardErrorr   )
r   r   r  r   ru   r   r  rv   chargefortune_teller_wallets
             r4   r   zAddMoneyFortuneWallet.post  s2   )TN

 C "))00C08>>@>
Y :;FD]D]^^
,,488O,=
Y:;6C^C^__HHX6
Y34F<W<WXX--6>MM  v;(	 ! 6 *00668  CK/  %%" &  $$^-F-Fs-J>KcKc-c  eS  .S  Yo$  p
ICD
EEA  NYA'0L0LMMND 
		 L
Is1v&v/J/J
KK	 T
Ic!f%V-R-R
SSTsl   G AH ;H /H C>H 	G?%G:4G?5H :G??H J%I
J
J%J;JJNr   r   r6   r4   r  r    s    *Tr6   r  c                       e Zd Zd Zy)GetFortuneWalletDetailsc                 H   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                  |      j                         }t        |      j                  }t        d|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r   r  r,  rw   r   r   )r   r   r   r*   r   r   r   r=   r   r   r   r   ForutuneTellerWalletSerializerr   r   )r   r   r  r   ru   wallet_detail
serializers          r4   r   zGetFortuneWalletDetails.get  s    TN

 C "))00C08>>@>
Y :;FD]D]^^%--44N4SYY[=.}=BB:
 y*=
>>  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTsN   B, AC( AC( ,	C%5%C C%C(  C%%C( (	D!1%DD!D!Nr   r   r6   r4   r  r    s    Tr6   r  c                       e Zd Zd Zy)GetFortuneWalletAllTranscationc                 2   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                  |d      }t        |d      j                  }t        d	|d
      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r   r  r,  r  )ru   payment_modeTr  r   r   )r   r   r   r*   r   r   r   r=   r   r   r   r<   WalletTranscationSerializerr   r   )r   r   r  r   ru   wallet_transcationtranscation_serializers          r4   r   z"GetFortuneWalletAllTranscation.get  s    TN

 C "))00C08>>@>
Y :;FD]D]^^199@@R`ow@x78JPTUZZ
y0FG
HH  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTsN   B! AC AC !	C*%CCC CC 	D&%DDDNr   r   r6   r4   r   r     r  r6   r   c                       e Zd Zd Zy)MarkBookingCompletedc                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  j                  d      }|st        ddit        j                        S t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                         j                         }|r@|j                   }|j"                  |dz  z  }	t%        |j"                        t%        |	      z
  }
nt%        d	      }
t        j                  j                  |j&                  d
      j                         }t(        j                  j                  |j&                        j                         }|r&|xj*                  |
z  c_        |j-                          n!t(        j                  j/                  ||
       t0        j                  j                  |j2                        j                         }t4        j                  j/                  t7               |||
dd       d
|_        |j-                          t:        j                  j/                  d|j<                  z   dz   d|       t>        j                  j/                  dt        |
      z   dz   |j<                  z   dz   d|       t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j@                        cY d }~S d }~ww xY w)Nr   r   r  r,  r  zappointment_id not foundr  r  r   T)r   r   rw   rt   r  r  )r@   r  ru   rv   r"  transcation_typezYou appointment :z! has been completed successfully.appointment_completedr  zAmount of $z for the appointment z, has been added to your wallet successfully.appointment_earningry   r   )!r   r   r   r*   r   r   r   r=   r   r   r   r   r   r  r   r>   commission_percentager  rA   fortune_teller_idr   rv   r+   r   r  seer_user_idr<   rF   r*  r  r  r   r   )r   r   r  r   ru   r  r  general_objcommision_percentr  commision_amountr   
wallet_objr  s                 r4   r   zMarkBookingCompleted.post  sH   %TN

 C "))00C08>>@>
Y :;FD]D]^^LL$$%56>
Y :;FD]D]^^+33::n:MSSU?
Y 78AZAZ[[''++-335;#99+115F5LM?001C8M4NN!f&&--1R1Rdh-iooq;"**11AbAb1ciik:))OO%%[HX%Y##**o.J.J*KQQS=$$++;X;Zer  CN  Vf  t|  N[+  \+/?(  ''0CODbDb0b  eH  1H  [r  }J'  K%%,,]3GWCX5XZq5q  sB  sQ  sQ  6Q  R@  6@  Sh  xC,  D
Iy)
**A  NYA'0L0LMMNB 
 T
Ic!f%V-R-R
SSTs[   L AM 9M AM "H.M 	M
%M?M
 M M

M 	N%N;NNNr   r   r6   r4   r'  r'    s    &Tr6   r'  c                       e Zd Zd Zy)PayoutMoneyc                 R   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  j                  d      }|st        ddit        j                        S t        j                  j                  |j                        j                         }t        |j                         t        |      k  rt        ddit        j                        S |xj                   t        |      z  c_        |j#                          t$        j                  j'                  t)               ||	       t*        j                  j'                  |j,                  d
z   |j.                  z   dz   |z   d       t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j0                        cY d }~S d }~ww xY w)Nr   r   r  r,  payout_amountzPayout amount is requiredrw   z/You do not have sufficent amount in you wallet.)r@   ru   rv   r~   z6 fortune teller has send a request for the payout of $fortuneteller_payoutr   r   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   r   rA   rv   r+   rN   r   rO   r   rf   rg   r   )r   r   r  r   ru   r6  r2  s          r4   r   zPayoutMoney.post$  s   TN

 C "))00C08>>@>
Y :;FD]D]^^LL$$_5=
Y ;<VE^E^__"**11>CTCT1U[[]:	*

s=11Y QR[a[t[tuuM**??##**<X<Zjx  BO*  P$$^-F-Fs-J>KcKc-c  e]  .]  _l  .l  rH$  I
Iy)
**  NYA'0L0LMMN  
 T
Ic!f%V-R-R
SSTs[   F1 AG- 9G- A5G- B%G- 1	G*:%G%G* G- %G**G- -	H&6%H!H&!H&Nr   r   r6   r4   r4  r4  #  r	  r6   r4  c                       e Zd Zd Zy)AllPayoutTranscationsc                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                  |      j                  d      }|j                  j                  d      }|st        ddit        j                        S |d	k(  r9t        j                  j                  |d	
      }t!        |d      j"                  }n|dk(  r9t        j                  j                  |d
      }t!        |d      j"                  }nFt        j                  j                  |      j                  d      }t!        |d      j"                  }t        d|d      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j$                        cY d }~S d }~ww xY w)Nr   r   r  r,  rw   r~  r)  ztranscation_type is requiredpending)ru   transcation_statusTr  approvedr   r   )r   r   r   r*   r   r   r   r=   r   r   r   rN   r  r  r   r   PayoutTranscationSerializerr   r   )r   r   r  r   ru   
payout_objr)  r%  s           r4   r   zAllPayoutTranscations.get=  s   TN

 C "))00C08>>@>
Y :;FD]D]^^(0077~7V__`ef:**../AB
Y=>fFaFabb)#)1188js8tJ8NSSJ&)1188jt8uJ8NSS)11888W``afgJ8NSS
y0FG
HH)  NYA'0L0LMMN, 
 T
Ic!f%V-R-R
SSTsU   F AG A(G CG 	G%GGG GG 	H	%H>H	H	Nr   r   r6   r4   r9  r9  <  s    Tr6   r9  c                       e Zd Zd Zy)dummyNotificationc                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S t        j                  j                  d      j                         }|j                  r|j                  }t        t        j                        }|j                   dk(  rOddd	|j"                  z   d
z   |j$                  z   dz   |j&                  dd}t)        |      j+                  ||      }	|j                   dk(  rcd}
|j"                  d
z   |j$                  z   dz   }dd|j"                  d
z   |j$                  z   dz   d}t)        |      j+                  ||
||      }	t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j,                        cY d }~S d }~ww xY w)Nr   r   r  r,  >   r  conversation_startzCHAT STARTED FROM FORTUNE SIDEzYour Chat have started withr~   z, Please Join!"CHf934bfe890d049339346dd180726c48b)r   r  r   r,   twilio_channel_sidr  r  r  )REQUEST ACCEPTEDz sent you a friend request.friend_request_acceptedrG  z accepted your friend request.r  r  r   )r   r   r   r*   r   r   r   r=   r   r   r   r  r  r   r   r  r   rf   rg   r,   r   r  r   )r   r   r  r   ru   r  r  r   r  r  r  r  s               r4   r   zdummyNotification.post\  s   "TN

 C "))00C08>>@>
Y :;FD]D]^^&&"&-3359##))OX112J	)354n6O6OOPSSTbTlTllm}}"(( D	\ j1FFWf  wCF  DV%(]#..s2>3K3KKLii\8'&11#5n6N6NNOoo\ j1FFWf  wD\ G ;V
Iy)
**;  NYA'0L0LMMN< 
 T
Ic!f%V-R-R
SSTsN   F AG D;G 	G %GGG GG 	H%HHHNr   r   r6   r4   rA  rA  [  s    #Tr6   rA  c                       e Zd Zd Zy)OnlineStatusc                 f   	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  d      }|st        ddit        j                        S ||_        |j                          t        ddi      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j                         cY d }~S d }~ww xY w)Nr   r   r  r  online_statuszonline_status is requiredr   )r   r   r   r*   r   r   r   r=   r   r   r   r   r   r   	is_onliner+   r   )r   r   r  r   ru   r   rL  s          r4   r   zOnlineStatus.post  s   TN

 C "))00C08>>@>
Y 01&:S:STT
,,488O,=
Y:;6C^C^__+>
Ii(
))  NYA'0L0LMMN 
 T
Ic!f%V-R-R
SSTr  Nr   r   r6   r4   rJ  rJ    s    Tr6   rJ  c                       e Zd Zd Zy)ExpireAppointmentsc                    	 t         j                  j                  ddg      }|D ]  }|j                  }|j                  }t        t        j                  |j                  d            \  }}t        j                  |dz   |z   d      }t        j                  |dz   |z   d      }	t        j                  |j                        }
|
j                  |      }|
j                  |	      }|j                  |
      }|j                  |
      }t        j                  t        j                  |j                              }||k\  s|j                   dk(  r|j"                  s|j$                  rd|_        d|_        |j)                          t*        j                  j-                         j/                         }|r@|j0                  }|j2                  |d	z  z  }t5        |j2                        t5        |      z
  }n|j2                  }d
}	 t6        j                  j                  |j8                  j:                        j/                         }|j<                  r t?        |j@                  ||jB                        }	 	 tD        j                  j                  |j8                        j/                         }|r&|xjF                  |z  c_#        |j)                          n+tD        j                  jI                  |j8                  |       nQtJ        j                  jI                  ||j2                  d
       d|_        d|_&        d|_'        |j)                          	 |j                   dk(  rtP        j                  j                  |      j/                         }|jR                  s,tJ        j                  jI                  ||j2                  d
       d|_        d|_&        d|_'        |j)                           tU        dditV        jX                        S # tZ        $ r0}tU        dt        |      itV        j\                        cY d }~S d }~ww xY w)Nr  r  r  r8  r~   z%d %B %Y %I:%M %p	CompletedTr  r   r  rw   rt   r  Expiredr  r   z)Expired appointments updated successfullyr   )/r  r=   r   appointment_timeappointment_dater>  r*   stripr   r   strptimepytzr2  localize
astimezoner   r  rF  twilio_room_namer*  r+   r   r>   r   r,  r  rA   r   ru   r   r   r   stripe_connect_account_idr  r   rv   r   r  r  r  rH   r  r   r   HTTP_200_OKr   r   )r   r   appointments_to_expirer  rS  rT  booked_start
booked_endappointment_datetime_startappointment_datetime_endappointment_timezonestart_time_appointment_timezoneend_time_appointment_timezonestart_time_appointmentend_time_appointmentcurrent_timer/  r0  total_amountr1  r   tranfer_amountr2  r  r   s                            r4   r   zExpireAppointments.get  s   TV 3::AA%z2 B  -{"33"33"399.>.D.DS.IJL*!)!2!23Cc3IL3XZm!n'001AC1G*1TVij==)=)=>&:&C&CD^&_#$8$A$ABZ$[!<GGH\]8CCDXY <<{/C/C DEL++&&*4		'	';+G+G(3{%+/{(#++//1779{
'=="((,=,CD{001C4EE%++j"**11[5O5O5R5R1SYY[{

/
/3K4Y4YZjkv  lF  lF  G.b'//66kF`F`6aggi
			.	.					#	#	*	*+:T:T\l	*	m.!!(([{O`O`vw(x(1{%)2{&"+{ d&&)3+33::;:OUUWo&&!!(([{O`O`vw(x'0k$(1k%!*k*G -J IJKTZTfTf
gg	 V
Is1v&v/T/T
UUVs%   D>P KP 	Q	%Q>Q	Q	Nr   r   r6   r4   rO  rO    s	    UVr6   rO  c                       e Zd Zd Zy)UpdateOnlineStatusc                 R   	 t         j                  j                  dt        j                         t        d      z
        }|D ]  }d|_        |j                           t        ddi      S # t        $ r0}t        dt        |      it        j                        cY d }~S d }~ww xY w)	NTr   )hours)rM  last_activity__ltFr   r   r   )r   r=   r   r   r   r   rM  r+   r   r   r*   r   r   )r   r   inactive_fortune_tellersru   r   s        r4   r   zUpdateOnlineStatus.get  s    T+33::llnyr':: ; 
 2~$N 2 Yy)
**	 T
Ic!f%V-R-R
SSTs   A*A- -	B&6%B!B&!B&Nr   r   r6   r4   rk  rk    s    Tr6   rk  c                       e Zd Zd Zy)SuccessPageUrlc                    	 |j                   j                  d      }t        j                  j	                  |      j                         }|j                  }t        j                  j                  |      }t        d|       d|_        |d   r#d|_        |j                          t        |d      S |j                          t        |d      S # t        $ r}t        |d      cY d }~S d }~ww xY w)Nfortuner  zaccount===========Tcharges_enabledzsuccess.htmlr   )r   r   r   r=   r   r   r[  r  Accountretriever   r   r   r+   r   r   )r   r   
fortune_idr   
account_idaccountr   s          r4   r   zSuccessPageUrl.getJ  s    -	*:&&--:->DDF;55:^^$$Z07	g&+/;( %)K"'.))',--
 -
+
,,-s$   B.C 1C 	C,C'!C,'C,Nr   r   r6   r4   rq  rq  I  s    -r6   rq  c                       e Zd Zd Zy)StripeConnectAccountc                    	 	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |j                  }|j                  }|j                  r7t        d|j                         t        |j                  |j                         }n:t#        |      }|r-||_        t        ||j                         }|j%                          t        ddt        j&                        S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# t        $ r0}t        dt        |      it        j(                        cY d }~S d }~ww xY w)Nr   r   r  r  iffr   r   )r   r   r   r*   r   r   r   r=   r   r   r   r   rh   r[  r   create_account_urlr   create_stripe_connectAccountr+   r\  r   )	r   r   r  r   ru   r   fortune_emailstripe_connect_urlconnect_account_ids	            r4   r   zStripeConnectAccount.post`  sM   VN

 C "))00C08>>@>
Y 01&:S:STT
,,4!''=..	%889+N,T,TUcUfUfg4]C0B^-,-?@Q@QR
y0BCFL^L^
__%  NYA'0L0LMMN( 
 V
Is1v&v/T/T
UUVsN   D AE
 B2E
 	E%E<E=E
 EE
 
	F%E>8F>FNr   r   r6   r4   r{  r{  _  s    Vr6   r{  c                       e Zd Zd Zy)DeleteFortuneAccountViewc                 `   	 t        |      }t        j                  j                  |      j                         }|st        ddit        j                        S |}|t        ddit        j                        S 	 t        j                  j                  |      }d|_        |j                          t        ddid	      S # t        $ r0}t        dt        |      it        j
                        cY d }~S d }~ww xY w# j                  $ r  t        ddit        j                        cY S w xY w)
Nr   r   r  r  zfortune_id is requiredr,  Tz#Fortune teller deleted successfully   )r   r   r   r*   r   r   r   r=   r   r   r   r   DoesNotExistr   r+   )r   r   r  r   ru   rw  r   s          r4   destroyz DeleteFortuneAccountView.destroy}  s   M	w	3 !((//3/7==?.	
I/09R9R
SS* 
I78AZAZ
[[^



#
#z
#
24 $))+	9CDS	QQ# 
 M
Is1v&v/K/K
LLM 
		 ^
I9:6C\C\
]]^s/   C < C> 	C;%C60C;6C;>,D-,D-N)r   r   r   r  r   r6   r4   r  r  |  s    Rr6   r  )   )yrh   r   django.shortcutsr   rest_framework.viewsr   rest_framework.responser   rest_frameworkr   models	functionsrS   r   r   django.confr   django.contrib.authr   django.contrib.auth.modelsr   rest_framework_simplejwt.tokensr   passlib.hashr   r   django.template.loaderr   django.corer   django.core.mailr   mathrW  rZ   django.contribr   rQ   r   admin_panel.modelsjsonauthenticationr   serializersdjango.core.files.storager   r%   admin_panel.common_functionsadmin_panel.functionsr   seer_user.serializersr   r   admin_panel.serializersr   r   pyfcmr   django.views.genericr   r  r    twilio.restr!   TWILIO_ACCOUNT_SIDaccount_sidTWILIO_AUTH_TOKEN
auth_tokenclientTWILIO_MOBILE_NUMBERfrom_mobile_numberr5   rF   rI   rO   rb   rd   r   r   r   r   r   r   r   r
  r  r#  r*  rQ  rX  rZ  rn  rv  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r'  r4  r9  rA  rJ  rO  rk  rq  r{  DestroyAPIViewr  r   r6   r4   <module>r     sB    # ( , !    (   , + 8 8 3  3 ! ! #     )  7 	 * < T D ! -  #  ((''
	Z	(22 	$ 
NTw NTbGV' GVT&T' &TR	: 	: Tg  TF/T /TdU' U@9 9BT T&V' VV V_V7 _VD?Vw ?VB%
-Vg -V`V7 V>V V(T' TT7 TTG TTG TVG V@T7 T.Vw V4TG T&T T$$TW $TNTW T""V "VLCT CTNTw T4+TG +T`Tg T0TW T$'T7 'TTT' T2TG T>$T $TLT7 T, ]VV VVvT T" aJ-W -,V7 V:Rx66 Rr6   