
    8e<                       d dl mZ d dlmZ d dlmZ d dl mZmZmZ d dlm	Z	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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 d dl d dl m!Z!m"Z" d dl#m$Z$ d dl%Z%ddl& d dl'm'Z' d dl(Z(d dl)m*Z* d dl+m,Z, d dl-Z-d dl%Z%d dl.m/Z/ d dl m0Z0 d dl1Z1d dl2m3Z3 d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 ddl: d dl;Z;d Z<d Z=d Z>d Z? G d d e      Z@ G d! d"e      ZA G d# d$e      ZB G d% d&e      ZC G d' d(e      ZD G d) d*e      ZE G d+ d,e      ZF G d- d.e      ZGd/ ZH G d0 d1e      ZI G d2 d3e      ZJ G d4 d5e      ZK G d6 d7e      ZLd8 ZM G d9 d:e      ZN G d; d<e      ZO G d= d>e      ZP G d? d@e      ZQ G dA dBe      ZR G dC dDe      ZS G dE dFe      ZT G dG dHe      ZU G dI dJe      ZV G dK dLe      ZW G dM dNe      ZX G dO dPe      ZY G dQ dRe      ZZ G dS dTe      Z[ G dU dVe      Z\ G dW dXe      Z]dY Z^ G dZ d[e      Z_ G d\ d]e      Z`d^ Za G d_ d`e      Zb G da dbe      Zcdc Zd G dd dee      Ze G df dge      Zfdh Zg G di dje      Zh G dk dle      Zi G dm dne      Zj G do dpe      Zk G dq dre      Zlds Zm G dt due      Zn G dv dwe      Zo G dx dye      Zp G dz d{e      Zq G d| d}e      Zr G d~ de      Zs G d de      Zt G d de      Zu G d de      Zvd Zw G d de      Zx G d de      Zy G d de      Zzd Z{ G d de      Z| G d de      Z} G d de      Z~ G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z	 	  G d de5      Z G d de5      Z G d de5      Zd Zd Zy)    )render)TemplateView)View)r   HttpResponseredirect)authenticateloginlogout)messages   )forms)User)JsonResponse)mailN)settings)render_to_string)*)QCount)	Paginator)datetime)login_required)method_decorator)
make_aware)Sum)FCMNotification)APIView)Responsestatusc                     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)SeerUserTranscationobjectsalllasttranscation_idintstrzfill)lastObjtheIds     1/var/www/html/Ryun_Seer/seer/admin_panel/views.pygenerateTranscationsIdr0   (   sy    

%
%
)
)
+
0
0
2			
%ab	%E
1%E
%A%	U		    c                     | j                   j                  d      }t        j                  j	                  |      j                         }|rt        d      S d}t        |d      S )Nemailusernametruez)This email does not exist in our databaseFsafe)GETgetr   r&   filterfirstr   r   )requesttextpostmessages       r/   
checkEmailrA   7   sT     T*002	v	7'	g5	))r1   c                    | j                   j                  dd      }| j                   j                  d      }t        j                  j                  |      }|j	                  |      dk(  rd}t        |d      S t        d      S )	Nr3    passwordr4   Fz!Please enter the correct passwordr7   r6   )r9   r:   r   r&   check_passwordr   r   )r=   r>   rD   userr@   s        r/   checkLoginPasswordrG   @   so    #KKOOJ'  $ /!U*/'	g5	))	v	r1   c                     | j                   j                  d      }t        j                  j                  | j                  j
                        }|j                  |      dk(  rd}t        |d      S t        d      S )Nold_passwordr3   Fz%Does not match with the old password.r7   r6   )	r9   r:   r   r&   rF   r3   rE   r   r   )r=   rI   rF   r@   s       r/   adminCheckPasswordrK   J   se    /  w||'9'9 :%.3'	g5	))	v	r1   c                       e Zd ZdZd Zd Zy)
adminLoginz
login.htmlc                 .    t        || j                        S Nr   template_nameselfr=   s     r/   r:   zadminLogin.getV       	**	++r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }t        ||      }|r8t        d       t        ||       t        j                  |d       t        d      S t        j                  |d       t        || j                        S t        |dd	|i      S )
Nr3   rD   )r5   rD   yeszLogin successfullyz
/dashboardzInvalid email and password.r	   form)r   adminLoginFormPOSTis_validcleaned_datar:   r   printr	   r   successr   r   rQ   )rS   r=   rW   r3   rD   rF   s         r/   r?   zadminLogin.postX   s    			gll	+$	]]_##G,5##J/8

94

5\
7Dg34\"" W;<'4--..
'FD>
22r1   N__name__
__module____qualname__rQ   r:   r?    r1   r/   rM   rM   T   s    ,3r1   rM   c                       e Zd ZdZd Zd Zy)adminForgetPasswordzforgot-password.htmlc                 .    t        || j                        S rO   rP   rR   s     r/   r:   zadminForgetPassword.getn   rT   r1   c           	      F   t        j                  |j                        }|j                         rT|j                  j                  d      }t        j                  j                  |      j                         }d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|

       t7        j8                  |d       t;        d      S t=        || j>                  d|i      S c c}w )Nr3   rJ   rC      z/forgot-admin//zForgot Passwordz forget_admin_password_email.htmllinkhtml_messagez/A link has been successfully sent to your mail.z/admin-forget-passwordrW   ) r   adminforgetpasswordrY   rZ   r[   r:   
SuperAdminr&   r;   r<   joinrangerandomchoicestringascii_lettersdigitsr+   r3   r   BASE_URLforgotPasswordLinksaver   EMAIL_HOST_USERr   	send_mailr   r]   r   r   rQ   )rS   r=   rW   r3   	admin_objnran_numbaselinkcompletelinksubjectrk   plain_message
from_emailtos                 r/   r?   zadminForgetPassword.postq   sX   		"	"7<<	0$	]]_!!'*5!!(((7==?9WWSXY[S\]S\afmmF$8$86==$HIS\]^7#ioo"66<wF8h''(83<"*9>>7"#EP\G]^<=((:2>>'=*rdVGNO
+
,,
$,,vtn
== ^s   ;FNr^   rb   r1   r/   rd   rd   l   s    ',>r1   rd   c                       e Zd ZdZd Zd Zy)forgetPasswordVerificationzreset-password.htmlc                    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        || j                  t                     S )	Nrh   rJ   
LinkExpiryzlink-expire.html)r3   rv   TF)r+   r=   pathsplitrm   r&   r;   r<   rv   r   rQ   locals)rS   r=   ri   
user_emaillink_expiryrz   valids          r/   r:   zforgetPasswordVerification.get   s    	T\\	$zz#r"*""))*)=CCE+##|3
+
,,  ''
QU'V\\^)55	**68	44r1   c                 V   t        j                  |j                        }|j                         ra|j                  j                  d      }|j                  j                  d      }t        | j                  j                        }|j                  d      d   }t        d|       t        j                  j                  |      j                         }t        j                  j                  |j                   j"                        j                         }|rY|j%                  |       |j'                          d|_        |j'                          t+        j,                  |d	       t/        d      S t+        j0                  |d
       t/        d      S t3        || j4                  d|i      S )Nnew_passwordconfirm_new_passwordrh   r   rJ   idr   zPassword changed successfullySomething went wrongrW   )r   forgetverificationrY   rZ   r[   r:   r+   r=   r   r   r\   rm   r&   r;   r<   r   rF   r   set_passwordrw   rv   r   r]   r   errorr   rQ   )	rS   r=   rW   r   r   ri   r   rz   user_objs	            r/   r?   zforgetPasswordVerification.post   sB   		!	!',,	/$	]]_##''7<++//0FG
dll
 4

3#:j!!!(((<BBD9ll!!Y^^%6%6!7==?8,'MMO#/I NNW=>C=NN723C=
$,,vtn
==r1   Nr^   rb   r1   r/   r   r      s    &5>r1   r   c                   :    e Zd ZdZ e ed            d        Zy)	dashboardzdashboard.htmlrh   	login_urlc           
         t         j                  j                  |j                  j                        j                         }t        j                  j                         j                         }t        j                  j                         j                         }t        j                  j                  d      j                  d      d d }t        j                  j                  d      j                  d      d d }t        j                  j                         j                         }t        j                  j                  t        d            d   }t        t         j"                        }	t        j                  j                         d d }
g d	}g }d
d l}|j&                  j)                         }|j*                  }|D ]C  }t        j                  j                  ||d      j                         }|j-                  |       E t/        dd      D cg c]3  }t1        d t        j                  j                  ||      D              5 }}t3        || j4                  t7                     S c c}w )NrF   Tend_date__isnull-idr#   amount)total_amountr   010203040506070809101112r   )created_at__yearcreated_at__monthr   r      c              3   F   K   | ]  }t        |j                          y wrO   )floatr   ).0transcations     r/   	<genexpr>z dashboard.get.<locals>.<genexpr>   s'       M  ?L{{))*  ?Ls   !)r   r   )rm   r&   r;   rF   r   r<   SeerUserr'   countFortuneTellerorder_byFortuneAppointmentBookr%   	aggregater   r+   r   ru   r   datetodayyearappendro   sumr   rQ   r   )rS   r=   rz   r   fortune_objfive_user_objfive_fortune_objtotal_bookingstotal_earningbase_urlbooking_data
month_listbookingsr   r   r   mnthall_bookingiearnings                       r/   r:   zdashboard.get   s     ''W\\__'=CCE)!!#))+(%%))+113+""))T)BKKERSUTUV-"**11T1JSSTYZ[]\]^)11557==?.%--77S]7STbc-""#('//335bq9,a*(
--


%	$d'//66`dw{6|  C  C  E;??;  !BKq   M>Q>Y>Y>`>`rv  JK>`  ?L  M  M 
 	**68	44s   8I0Nr_   r`   ra   rQ   r   r   r:   rb   r1   r/   r   r      s#    !>C015 25r1   r   c                   :    e Zd ZdZ e ed            d        Zy)userListzusers_list.htmlrh   r   c                 `   	 t         j                  j                  |j                  j                        j                         }t        t        j                        }t        j                  j                  d      j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }d}t               }	|rQ|	j                  t        |	      t        |
      z  t        |      z  t        |      z  t        j                         |r4|r2|	j                  t        ||dz   |z   g      t        j                         t        j                  j                  |	d      j                  d      }t!        |d      }
|j                  j                  d      }|
j#                  |      }t%        || j&                  t)                     S # t*        $ r+}t-        j.                  |d       t1        d      cY d }~S d }~ww xY wNr   Tr   r   search
start_fromstart_to11:59:59)first_name__icontains)last_name__icontains)email__icontains)phone_number__icontains )created_at__range
   page&Something went wrong.Please try again.r   )rm   r&   r;   rF   r   r<   r+   r   ru   r   r   r9   r:   r   addANDr   get_pager   rQ   r   	Exceptionr   warningr   )rS   r=   rz   r   r   search_postr   r   timelookups	paginatorpage_number	user_dataes                 r/   r:   zuserList.get   s    !!((glloo(>DDF9(##$8%%%>GGN8*;-:kkooj)8
4S7KK4QK5XXYZlwYxxyz  T_  z`  `  bc  bg  bg  hXKKZC1E$FGO%%g%FOOPUV82&9(;!!+.9
++FH
55	  GEF
;
 s   G6G9 9	H- H("H-(H-Nr   rb   r1   r/   r   r      s#    ">C01  2 r1   r   c                   6    e Zd Z e ed            d        Zy)changeUserStatusrh   r   c                    	 t         j                  j                  |j                  d         }|j                  d   |_        |j                          |j                  dk(  r:t        j                  |d       t        |j                  j                  d            S t        j                  |d       t        |j                  j                  d            S # t        $ r+}t        j                  |d       t        d	      cY d }~S d }~ww xY w)
Nmain_idr   r    1zUser status is activatedHTTP_REFERERzUser status is deactivatedr   admin-dashboard)r   r&   r:   rY   r    rw   r   r]   r   METAr   r   r   r   rS   r=   pubr   s       r/   r?   zchangeUserStatus.post   s    &  $$',,y*A$B3X&3:88:	jjCW89((899NN789((899	 &GEF
$
%%&$   BC 9C 	D
 D?D
D
Nr_   r`   ra   r   r   r?   rb   r1   r/   r   r          >C01& 2&r1   r   c                   :    e Zd ZdZ e ed            d        Zy)viewUserzview_user_detail.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }|j                  r#t        j                  |j                        d   }nd}t        t        j                        }t        j                  j                  t        d      t        d      z  |	      }t        j                  j                  |	      j                  ddg
      j!                  d      }t#        || j$                  t'                     S )Nr   Tr   r   r   rC   Pendingappointment_statusAccepted	seer_userappointment_status__inr   )rm   r&   r;   rF   r   r<   r   imagesastliteral_evalr+   r   ru   r   r   excluder   r   rQ   r   )	rS   r=   r   rz   r   user_imagesr   upcoming_bookingpast_bookings	            r/   r:   zviewUser.get   s     ''W\\__'=CCE)$$D$AGGI(__""8??3A6;;""#(+33::1PY;Z[\pz[{;{  IK:  L'//6626FNNgpr|f}N~  H  H  IN  O,	**68	44r1   Nr   rb   r1   r/   r   r      s#    (>C01
5 2
5r1   r   c                   @    e Zd ZdZ e ed            d        Zd Zy)EditUserzedit_user.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        || j                  t                     S Nr   Tr   )
rm   r&   r;   rF   r   r<   r   r   rQ   r   )rS   r=   r   rz   r   s        r/   r:   zEditUser.get  sg      ''W\\__'=CCE)$$D$AGGI(	**68	44r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      j                  ||       t        j                  |d       t        d      S t        || j                        S )	N
first_name	last_namer3   phone_numberr   r  r  Updated Succesfullyz	user-list)r   editfortunetellerrY   rZ   r[   r:   r   r&   r;   updater   r]   r   r   rQ   rS   r=   r   rW   r  r  r3   r  s           r/   r?   zEditUser.post  s    		 	 	.$	]]_!!%%l3:  $$[19  )5##''7<b!((jY(WG23
;

++
,,r1   Nr_   r`   ra   rQ   r   r   r:   r?   rb   r1   r/   r  r    s(    !>C015 25-r1   r  c                 "   | j                   j                  d      }| j                   j                  d      }t        j                  j	                  |      j                  |      j                         }|rd}t        |d      S t        d      S 	Ncustomer_idr  )r  r   z This phone number already exist.Fr7   r6   )	r9   r:   r   r&   r;   r  r<   r   r   r=   r  r  r?   r@   s        r/   checkphoneedituserr!    sv    {{}-/\:BBkBRXXZ.'	g5	))	v	r1   c                   :    e Zd ZdZ e ed            d        Zy)FortunetellerListzfortuneteller_list.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }d}t               }|rQ|j                  t        |	      t        |
      z  t        |      z  t        |      z  t        j                         |r4|r2|j                  t        ||dz   |z   g      t        j                         t        j                  j                  |d      j                  d      }t        |d      }	|j                  j                  d      }
|	j                  |
      }t        t         j"                        }t%        || j&                  t)                     S # t*        $ r+}t-        j.                  |d       t1        d      cY d }~S d }~ww xY wr   )rm   r&   r;   rF   r   r<   r   r   r9   r:   r   r   r   r   r   r+   r   ru   r   rQ   r   r   r   r   r   )rS   r=   rz   r   r   r   r   r   r   r   r   fortune_datar   r   s                 r/   r:   zFortunetellerList.get&  s    !!((glloo(>DDF9&&---FOOPUV;*;*;-:kkooj)8
4S7KK4QK5XXYZlwYxxyz  T_  z`  `  bc  bg  bg  hXKKZC1E$FGO&&--g-NWWX]^;b)9(;$$[1<(##$8
++FH
55	  GEF
;
 s   HH 	I I=IINr   rb   r1   r/   r#  r#  $  s#    *>C01  2 r1   r#  c                   :    e Zd ZdZ e ed            d        Zy)ViewFortunetellerzview_fortuneteller_detail.htmlrh   r   c                 F   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        t        j                        }t        j                  j                  t        d      t        d      z  |      }t        j                  j                  |      j                  ddg      j                  d	      }t        || j                  t!                     S )
Nr   Tr   r   r  r  fortune_tellerr  r   )rm   r&   r;   rF   r   r<   r   r+   r   ru   r   r   r  r   r   rQ   r   )rS   r=   r   rz   r   r   r  r  s           r/   r:   zViewFortuneteller.getA  s      ''W\\__'=CCE)%%,,D,IOOQ+""#(+33::1PY;Z[\pz[{;{  NP:  Q'//666KSSlu  xB  lCS  D  M  M  NS  T,	**68	44r1   Nr   rb   r1   r/   r'  r'  ?  s#    1>C015 25r1   r'  c                   6    e Zd Z e ed            d        Zy)ChangeFortuneTellerStatusrh   r   c                    	 t         j                  j                  |j                  d         }|j                  d   |_        |j                          |j                  dk(  r:t        j                  |d       t        |j                  j                  d            S t        j                  |d       t        |j                  j                  d            S # t        $ r+}t        j                  |d       t        d	      cY d }~S d }~ww xY w)
Nr   r   r    r   zStatus is activatedr   zStatus is deactivatedr   r   )r   r&   r:   rY   r    rw   r   r]   r   r   r   r   r   r   r   s       r/   r?   zChangeFortuneTellerStatus.postL  s    &%%))w||I/F)G3X&3:88:	jjCW34((899NN734((899	 &GEF
$
%%&r   Nr   rb   r1   r/   r,  r,  K  r   r1   r,  c                   @    e Zd ZdZ e ed            d        Zd Zy)EditFortuneTellerzedit_fortunetelller.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        || j                  t                     S r  )
rm   r&   r;   rF   r   r<   r   r   rQ   r   )rS   r=   r   rz   r   s        r/   r:   zEditFortuneTeller.get_  sg      ''W\\__'=CCE)%%,,D,IOOQ+	**68	44r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      j                  ||       t        j                  |d       t        d      S t        || j                        S )	Nr  r  r3   r  r   r  r  zfortuneteller-list)r   r  rY   rZ   r[   r:   r   r&   r;   r  r   r]   r   r   rQ   r  s           r/   r?   zEditFortuneTeller.postd  s    		 	 	.$	]]_!!%%l3:  $$[19  )5##''7<2&--:R[-\G23
'
((
++
,,r1   Nr  rb   r1   r/   r/  r/  ]  s(    +>C015 25-r1   r/  c                 "   | j                   j                  d      }| j                   j                  d      }t        j                  j	                  |      j                  |      j                         }|rd}t        |d      S t        d      S r  )	r9   r:   r   r&   r;   r  r<   r   r   r   s        r/   CheckPhoneFortuneEditr3  q  sv    {{}-/$$,$?GG;GW]]_.'	g5	))	v	r1   c                   :    e Zd ZdZ e ed            d        Zy)HobbiesListzhobbies_list.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }|j                  j                  d      }|r:t        j                  j                  t        |      d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S # t         $ r+}t#        j$                  |d	       t'        d
      cY d }~S d }~ww xY w)Nr   Tr   r   r   )hobby__icontainsr   r   r   r   )rm   r&   r;   rF   r   r<   Hobbiesr   r9   r:   r   r   r   r   rQ   r   r   r   r   r   )	rS   r=   rz   data_objr   r   r   hobbies_objr   s	            r/   r:   zHobbiesList.get~  s    !!((glloo(>DDF9oo$$$=FFuM8*;%%a&EY]%^gghmnH2&9(;##K0;
++FH
55	  GEF
;
    DD! !	E* E
EENr   rb   r1   r/   r5  r5  |  s#    $>C01  2 r1   r5  c                   @    e Zd ZdZ e ed            d        Zd Zy)
AddHobbieszadd_hobbies.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        || j                  t                     S Nr   	rm   r&   r;   rF   r   r<   r   rQ   r   rS   r=   rz   s      r/   r:   zAddHobbies.get  C      ''W\\__'=CCE)	**68	44r1   c                    	 t        j                  |j                        }|j                         r\|j                  j                  d      }t        j                  j                  |       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                  |d       t        d      cY d }~S d }~ww xY w)N
hobby_namehobbyCreated Succesfullyhobbies-listr   r   )r   hobbies_formrY   rZ   r[   r:   r8  r&   creater   r]   r   r   rQ   r   r   )rS   r=   rW   rD  r   s        r/   r?   zAddHobbies.post  s     


W\\
*4
mmo""&&|4JOO,W34N##'$,,--	  GEF
;
 s$   B
B# B# #	C, CCCNr  rb   r1   r/   r=  r=    s(    #>C015 25 r1   r=  c                   @    e Zd ZdZ e ed            d        Zd Zy)EditHobbieszedit_hobbies.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        || j                  t                     S r  )
rm   r&   r;   rF   r   r<   r8  r   rQ   r   )rS   r=   r   rz   r:  s        r/   r:   zEditHobbies.get  e      ''W\\__'=CCE)&&"d&CIIK+	**68	44r1   c                    	 t        j                  |j                        }|j                         rl|j                  j                  d      }t        j                  j                  |      j                  |       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                   |d       t        d      cY d }~S d }~ww xY w)NrD  r   rE  r  rH  r   r   )r   rI  rY   rZ   r[   r:   r8  r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   rW   rD  r   s         r/   r?   zEditHobbies.post  s     


W\\
*4
mmo""&&|4JOOb!((z(:W34N##'$,,--	  GEF
;
 $   BB3 B3 3	C'< C"C'"C'Nr  rb   r1   r/   rL  rL    s(    $>C015 25
 r1   rL  c                   6    e Zd Z e ed            d        Zy)changeHobbiesStatusrh   r   c                    	 t         j                  j                  |j                  d         }|j                  d   |_        |j                          |j                  dk(  r:t        j                  |d       t        |j                  j                  d            S t        j                  |d       t        |j                  j                  d            S # t        $ r+}t        j                  |d       t        d	      cY d }~S d }~ww xY w)
Nr   r   r    r   zHobbies status is activatedr   zHobbies status is deactivatedr   r   )r8  r&   r:   rY   r    rw   r   r]   r   r   r   r   r   r   r   s       r/   r?   zchangeHobbiesStatus.post      &##i)@#A3X&3:88:	jjCW;<((899NN7;<((899	 &GEF
$
%%&r   Nr   rb   r1   r/   rR  rR    r   r1   rR  c                   :    e Zd ZdZ e ed            d        Zy)ServiceListzservice_list.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }|j                  j                  d      }|r:t        j                  j                  t        |      d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S # t         $ r+}t#        j$                  |d	       t'        d
      cY d }~S d }~ww xY w)Nr   Tr   r   r   )service_name__icontainsr   r   r   r   )rm   r&   r;   rF   r   r<   Servicer   r9   r:   r   r   r   r   rQ   r   r   r   r   r   	rS   r=   rz   r9  r   r   r   service_objr   s	            r/   r:   zServiceList.get  s    !!((glloo(>DDF9oo$$$=FFuM8*;%%a&L`d%ennotuH2&9(;##K0;
++FH
55	  GEF
;
 r;  Nr   rb   r1   r/   rV  rV    s#    $>C01  2 r1   rV  c                   @    e Zd ZdZ e ed            d        Zd Zy)
AddServicezadd_service.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        || j                  t                     S r?  r@  rA  s      r/   r:   zAddService.get  rB  r1   c                    	 t        j                  |j                        }|j                         r_|j                  j                  d      }d}t        j                  j                  ||       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                  |d       t        d      cY d }~S d }~ww xY w)Nservice_namer   r`  r    rG  service-listr   r   )r   service_formrY   rZ   r[   r:   rY  r&   rJ  r   r]   r   r   rQ   r   r   )rS   r=   rW   r`  r    r   s         r/   r?   zAddService.post  s     


W\\
*4
mmo$$((8LFOOFCW34N##'$,,--	  GEF
;
 $   BB& B& &	C/ CCCNr  rb   r1   r/   r]  r]    s(    #>C015 25 r1   r]  c                   @    e Zd ZdZ e ed            d        Zd Zy)EditServicezedit_service.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        || j                  t                     S r  )
rm   r&   r;   rF   r   r<   rY  r   rQ   r   rS   r=   r   rz   r[  s        r/   r:   zEditService.get  rN  r1   c                    	 t        j                  |j                        }|j                         ro|j                  j                  d      }d}t        j                  j                  |      j                  ||       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                   |d       t        d      cY d }~S d }~ww xY w)	Nr`  r   r   ra  Update Succesfullyrb  r   r   )r   rc  rY   rZ   r[   r:   rY  r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   rW   r`  r    r   s          r/   r?   zEditService.post   s     


W\\
*4
mmo$$((8LFOOb!((l&(QW23N##'$,,--	  GEF
;
 $   BB6  B6 6	C*? C%C*%C*Nr  rb   r1   r/   rf  rf    s(    $>C015 25
 r1   rf  c                   6    e Zd Z e ed            d        Zy)changeServiceStatusrh   r   c                    	 t         j                  j                  |j                  d         }|j                  d   |_        |j                          |j                  dk(  r:t        j                  |d       t        |j                  j                  d            S t        j                  |d       t        |j                  j                  d            S # t        $ r+}t        j                  |d       t        d	      cY d }~S d }~ww xY w)
Nr   r   r    r   zService status is activatedr   zService status is deactivatedr   r   )rY  r&   r:   rY   r    rw   r   r]   r   r   r   r   r   r   r   s       r/   r?   zchangeServiceStatus.post  rT  r   Nr   rb   r1   r/   rm  rm    r   r1   rm  c                   :    e Zd ZdZ e ed            d        Zy)	SkillListzskill_list.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }|j                  j                  d      }|r:t        j                  j                  t        |      d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S # t         $ r+}t#        j$                  |d	       t'        d
      cY d }~S d }~ww xY w)Nr   Tr   r   r   )skill_name__icontainsr   r   r   r   )rm   r&   r;   rF   r   r<   Skillr   r9   r:   r   r   r   r   rQ   r   r   r   r   r   rZ  s	            r/   r:   zSkillList.get$  s    !!((glloo(>DDF9mm""d";DDUK8*;}}##AK$H\`#ajjkpqH2&9(;##K0;
++FH
55	  GEF
;
 r;  Nr   rb   r1   r/   rp  rp  "  s#    ">C01  2 r1   rp  c                   @    e Zd ZdZ e ed            d        Zd Zy)AddSkillzadd_skills.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        || j                  t                     S r?  r@  rA  s      r/   r:   zAddSkill.get7  rB  r1   c                    	 t        j                  |j                        }|j                         r_|j                  j                  d      }d}t        j                  j                  ||       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                  |d       t        d      cY d }~S d }~ww xY w)N
skill_namer   rx  r    rG  
skill-listr   r   )r   
skill_formrY   rZ   r[   r:   rs  r&   rJ  r   r]   r   r   rQ   r   r   )rS   r=   rW   rx  r    r   s         r/   r?   zAddSkill.post<  s     


7<<
(4
mmo""&&|4JF	MMJf=W34L!!'$,,--	  GEF
;
 rd  Nr  rb   r1   r/   ru  ru  5  s(    ">C015 25 r1   ru  c                   @    e Zd ZdZ e ed            d        Zd Zy)	EditSkillzedit_skill.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        || j                  t                     S r  )
rm   r&   r;   rF   r   r<   rs  r   rQ   r   rh  s        r/   r:   zEditSkill.getM  se      ''W\\__'=CCE)$$D$AGGI+	**68	44r1   c                    	 t        j                  |j                        }|j                         ro|j                  j                  d      }d}t        j                  j                  |      j                  ||       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                   |d       t        d      cY d }~S d }~ww xY w)	Nrx  r   r   ry  rj  rz  r   r   )r   r{  rY   rZ   r[   r:   rs  r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   rW   rx  r    r   s          r/   r?   zEditSkill.postS  s     


7<<
(4
mmo""&&|4JF	MMB&&*F&KW23L!!'$,,--	  GEF
;
 rk  Nr  rb   r1   r/   r}  r}  K  s(    ">C015 25
 r1   r}  c                   6    e Zd Z e ed            d        Zy)changeSkillStatusrh   r   c                    	 t         j                  j                  |j                  d         }|j                  d   |_        |j                          |j                  dk(  r:t        j                  |d       t        |j                  j                  d            S t        j                  |d       t        |j                  j                  d            S # t        $ r+}t        j                  |d       t        d	      cY d }~S d }~ww xY w)
Nr   r   r    r   zSkill status is activatedr   zSkill status is deactivatedr   r   )rs  r&   r:   rY   r    rw   r   r]   r   r   r   r   r   r   r   s       r/   r?   zchangeSkillStatus.postd  s    &!!w||I'>!?3X&3:88:	jjCW9:((899NN79:((899	 &GEF
$
%%&r   Nr   rb   r1   r/   r  r  c  r   r1   r  c                   :    e Zd ZdZ e ed            d        Zy)PaymentListszpayment_list.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                         j                  d      }|j                  j                  d      }|j                  j                  d      }d}t               }|r^|j                  t        |      t        |      z  t        |      z  t        |	      z  t        |
      z  t        j                         |r_t        |      }t        t!        j"                  |            }	t%        d|	       |j                  t        |	      t        j                         t        j                  j                  |      j                  d      }t'        |d      }
|j                  j                  d      }|
j)                  |      }t+        || j,                  t/                     S )Nr   r   r   booking_dater    seer_user__first_name__icontainsseer_user__last_name__icontains.booking__fortune_teller__first_name__icontains-booking__fortune_teller__last_name__icontains)transcation_id__icontainsbooking_date_timecreated_at__dater   r   )rm   r&   r;   rF   r   r<   r%   r'   r   r9   r:   r   r   r   r+   r   r   fromisoformatr\   r   r   r   rQ   r   )rS   r=   rz   r9  r   r  r   r   date_stringr  r   r   payment_objs                r/   r:   zPaymentLists.getx  s     ''W\\__'=CCE) ((,,.77>()+0,	$C'
;;q+>qal?mmno  `k  ol  l  mn  ]h  mi  i  jk  FQ  jR  R  TU  TY  TY  Z \";!("8"8"EF	/0
;;q"34aee< !((//8AA%H("%)'+"";/+	**68	44r1   Nr   rb   r1   r/   r  r  v  s#    $>C015 25r1   r  c                   :    e Zd ZdZ e ed            d        Zy)PaymentDetailszpayment_details.htmlrh   r   c                 8   t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        d|       t        || j                  t                     S )Nr   r   r  )rm   r&   r;   rF   r   r<   r%   r\   r   rQ   r   )rS   r=   r   rz   r  s        r/   r:   zPaymentDetails.get  so      ''W\\__'=CCE)#++22b29??A+k"	**68	44r1   Nr   rb   r1   r/   r  r    s#    '>C015 25r1   r  c                   :    e Zd ZdZ e ed            d        Zy)BookingListszbooking_list.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                         j                  d      }|j                  j                  d      }|rnt        j                  j                  t        |      t        |      z  t        |      z  t        |      z  t        |      z  d	
      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t!                     S )Nr   r   r   )%fortune_teller__first_name__icontains)$fortune_teller__last_name__icontainsr  r  ) service__service_name__icontainsTr   r   r   )rm   r&   r;   rF   r   r<   r   r'   r   r9   r:   r   r   r   r   rQ   r   )rS   r=   rz   r9  r   r   r   booking_objs           r/   r:   zBookingLists.get  sO     ''W\\__'=CCE)#++//1::5A()+$,,33A\g4hij  Q\  j]  5]  ^_  AL  ^M  5M  NO  p{  N|  5|  }~  `k  }l  5l  @D3  E  N  N  OT  U8"%)'+"";/+	**68	44r1   Nr   rb   r1   r/   r  r    s#    $>C01	5 2	5r1   r  c                   :    e Zd ZdZ e ed            d        Zy)BookingDetailszbooking_details.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        || j                  t                     S Nr   r   )
rm   r&   r;   rF   r   r<   r   r   rQ   r   )rS   r=   r   rz   r  s        r/   r:   zBookingDetails.get  se      ''W\\__'=CCE)&..555<BBD+	**68	44r1   Nr   rb   r1   r/   r  r    s#    '>C015 25r1   r  c                 N   t         j                  j                         }t        d      }d|d<   t	        j
                  |      }|j                  g d       |D ]  }|j                  |j                  |j                  j                  dz   |j                  j                  z   |j                  j                  dz   |j                  j                  z   |j                  |j                  |j                  j                  |j                   |j"                  |j$                  g	        |S )Ntext/csvcontent_typez"attachment; filename="booking.csv"Content-Disposition)	Appointment IdFortuneteller Name	User NameAppointment DateAppointment TimeService NamezService TypezAppointment StatusPricer   )r   r&   r'   r   csvwriterwriterowappointment_idr*  r  r  r  appointment_dateappointment_timeservicer`  service_typer  pricer=   querysetresponser  items        r/   ExportCSVBookingr    sy   "**..0j1#G
 
**X
  j  k T//4&&(;(;(F(Fs(J4K^K^KhKh(hjnjxjx  kD  kD  EH  kH  IM  IW  IW  Ia  Ia  ka  bf  bw  bw  x|  xM  xM  NR  NZ  NZ  Ng  Ng  hl  hy  hy  z~  zQ  zQ  RV  R\  R\  ]  ^  	r1   c                   @    e Zd ZdZ e ed            d        Zd Zy)EditProfileDatabasezedit_profile_database.htmlrh   r   c                    |j                   j                  d      }t        j                  j	                  |j
                  j                        j                         }	 |dk(  r<t        j                  j	                  |d      j                         }|j                  }n|dk(  r<t        j                  j	                  |d      j                         }|j                  }n|dk(  r<t        j                  j	                  |d      j                         }|j                  }n@|dk(  r;t        j                  j	                  |d      j                         }|j                  }t!        || j"                  t%                     S )	Nprofiler   	horoscopeTr   chinese_zodiacfive_elementmbti)r9   r:   rm   r&   r;   rF   r   r<   	Horoscoper  ChineseZodiacr  FiveElementselement_nameMBTI	mbti_namer   rQ   r   )rS   r=   r   tab_namerz   profile_objtitle_values          r/   r:   zEditProfileDatabase.get  s<   [[__Y'(  ''W\\__'=CCE))""))R)FLLN;&&;/##&&--T-JPPR;++;->!%%,,D,IOOQ;));%6$$D$AGGI;&&;	**68	44r1   c                    	 |j                   j                  d      }t        d|       |dk(  r	t        }d}n)|dk(  r	t        }d}n|dk(  r	t
        }d}n|dk(  rt        }d}t        j                  |j                         }|j                         r|j                  j                  d	      }|j                  j                  d
      }|j                  j                  d      }	|d|d|	i}
 j                  j                  |      j                  di |
 t        j                  |d       t!        d      S t#        || j$                        S # t&        $ r+}t        j(                  |d       t!        d      cY d }~S d }~ww xY w)Nr  tab_name====r  r  r  r  r  r  profile_titleprofile_taglineprofile_descriptiontaglinedescriptionr   r  profile-databaser   r   rb   )rY   r:   r\   r  r  r  r  r   profiledatabaseformrZ   r[   r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   r  
modal_namemodal_fieldrW   r  r  r  update_datar   s               r/   r?   zEditProfileDatabase.post  sn   ' lly)8!+JK$$J"KN"J KFJK

#
#GLL
14
mmo%%))/:M''++,=>O++//0EF -'K ,J$++:k:W34&'''$,,--	  GEF
;
 s$   D2E 5E 	E? E:4E?:E?Nr  rb   r1   r/   r  r    s(    ->C015 25,( r1   r  c                   :    e Zd ZdZ e ed            d        Zy)ProfileDatabasezprofile_database.htmlrh   r   c                 t   	 t         j                  j                  |j                  j                        j                         }	 t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }	 t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }	 t        j                  j                  d      j                  d      }	t        |	d      }|j                  j                  d      }|j                  |      }
	 t        j                  j                  d      j                  d	      }t        |d      }|j                  j                  d
      }|j                  |      }t        || j                   t#                     S # t$        $ r+}t'        j(                  |d       t+        d      cY d }~S d }~ww xY wNr   Tr   r   r   r  r  r  r   r  r   r   )rm   r&   r;   rF   r   r<   r  r   r   r9   r:   r   r  r  r  r   rQ   r   r   r   r   r   rS   r=   rz   horoscope_objr   all_page_numberall_horoscope_objchinese_zodiac_objall_chinese_objfive_elements_objall_five_element_objmbti_objall_mbti_objr   s                 r/   r:   zProfileDatabase.get  s    !!((glloo(>DDF9*$$++t+DMMdS=+9[[__[1? ))/:/%--444MVVW[\+R09[[__%56?''8?-#++22d2KTTUYZ*B/9[[__^4?#,,_=%ll!!T!:CCEJ82&9[[__V,?$$_5<
++FH
55	  GEF
;
    H H 	H7 H2,H72H7Nr   rb   r1   r/   r  r    s#    (>C01  2 r1   r  c                    	 | j                   dk(  r| j                  d   rw| j                  d   }| j                  j                  d      }t	        |       |j                         j                  d      j                         }t        j                  |      }d}|dk(  r|D ]  }	 | j                  j                  }t        j                  j                  |      }|s1t        j                   | d|j"                   d	       t%        d
      c S 	 d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S t(        j                  j                  |d         j+                         }	|	r0|d   |	_        |d   |	_        |d   |	_        |	j3                          qt)        |d   |d   |d         }
|
j3                           n|dk(  r|D ]  }	 | j                  j                  }t        j                  j                  |      }|s1t        j                   | d|j"                   d	       t%        d
      c S 	 d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S t4        j                  j                  |d         j+                         }	|	r0|d   |	_        |d   |	_        |d   |	_        |	j3                          qt5        |d   |d   |d         }|j3                           nj|dk(  r|D ]  }	 | j                  j                  }t        j                  j                  |      }|s1t        j                   | d|j"                   d	       t%        d
      c S 	 d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S t8        j                  j                  |d         j+                         }	|	r0|d   |	_        |d   |	_        |d   |	_        |	j3                          qt9        |d   |d   |d         }|j3                           n|dk(  r|D ]  }	 | j                  j                  }t        j                  j                  |      }|s1t        j                   | d|j"                   d	       t%        d
      c S 	 d|vr1t        j                   | d |j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S d|vr1t        j                   | d|j"                   d	       t%        d
      c S t<        j                  j                  |d   !      j+                         }	|	r0|d   |	_        |d   |	_        |d   |	_        |	j3                          qt=        |d   |d   |d   "      }|j3                           n!t        j                   | d#       t%        d
      S |dkD  r$t        j                   | | d$       t%        d
      S t        j@                  | d%       t%        d
      S t        j@                  | d&       t%        d
      S # t&        $ r4 t        j                   | d|j"                   d	       t%        d
      cY c S w xY w# t&        $ r4 t        j                   | d|j"                   d	       t%        d
      cY c S w xY w# t&        $ r4 t        j                   | d|j"                   d	       t%        d
      cY c S w xY w# t&        $ r4 t        j                   | d|j"                   d	       t%        d
      cY c S w xY w# tB        $ r+}t        jD                  | d'       t%        d(      cY d }~S d }~ww xY w))NrY   myFileInput
active_tabutf-8r   horoscope-tabr   "Invalid user found. Error in line .r  'User must be an integer. Error in line r  z+horoscope is missing in csv. Error in line Tagline)tagline is missing in csv. Error in line Description-description is missing in csv. Error in line )r  )r  r  r  
zodiac-tabzChinese Zodiacz0Chinese Zodiac is missing in csv. Error in line )r  )r  r  r  element-tabzFive Elementz.five element is missing in csv. Error in line )r  )r  r  r  mbti-tabr  z&mbti is missing in csv. Error in line )r  )r  r  r  Invalid tab selected." duplicate record(s) found in CSV.Uploaded successfullyr   r   r   )#methodFILESrY   r:   r\   readdecode
splitlinesr  
DictReaderrF   r   r   r&   r;   r   r   line_numr   
ValueErrorr  r<   r  r  r  rw   r  r  r  r  r  r  r]   r   r   r=   csv_filer  decoded_filereaderduplicate_countrowrF   r   existing_profile_datar  
zodiac_objelements_objr  r   s                  r/   importProfileDataCSVr  +  s   X^^v'--">mmM*8ll|,8?--/((1<<><NN<(6?/!
 *\\__d$$$$/h~~g!CFOOCTTUVW)**  	3nnWJ6??J[[\]^())nnWHHYYZ[\())S nnWLV__L]]^_`())&..55K@P5QWWY 	(+K(8%&))n#*-m*<'  "  [!9~}%m W X 	L 
 *\\__d$$$$/h~~g!CFOOCTTUVW)**  	#nnWOPVP_P_O``abc())nnWHHYYZ[\())S nnWLV__L]]^_`())*2299M]I^9_eeg 	-01A-B*&))n#*-m*<'  " !*+9~}%j ooU V 	M!
 *\\__d$$$$/h~~g!CFOOCTTUVW)**  	c!nnWMfooM^^_`a())nnWHHYYZ[\())S nnWLV__L]]^_`()))1188c.FY8Z``b 	+.~+>(&))n#*-m*<'  " "'9~}%l U V 	J
 *\\__d$$$$/h~~g!CFOOCTTUVW)**  	cnnWEfooEVVWXY())nnWHHYYZ[\())S nnWLV__L]]^_`()) "\\003v;0GMMO 	(+F%&))n#*-m*<'  " V9~}%h mmoW Z NN734&''NN7//QRS&''W56&''
723	$	%%C  *nnW GGXXYZ[())*b  *nnW GGXXYZ[())*`  *nnW GGXXYZ[())*`  *nnW GGXXYZ[())*b 	 
7DE	+	s(  B%b: (A&^:b: 5b: 4b: <4b: 1Bb: A&_:3b: 65b: ,4b: !4b: Bb: 2A&`:b: 5b: 4b: 4b: ;Bb: A&a:=b:  5b: 64b: +4b:  B.b: (b: 8 b:  b: :8_72b: 6_77b: :8`72b: 6`77b: :8a72b: 6a77b: :8b72b: 6b77b: :	c. c)#c.)c.c                   @    e Zd ZdZ e ed            d        Zd Zy)EditUserCompatibilityzedit_user_compatibility.htmlrh   r   c                 z   |j                   j                  d      }t        d|       t        j                  j                  |j                  j                        j                         }	 |dk(  rHt        j                  j                  |d      j                         }|j                  }|j                  }n|dk(  rHt        j                  j                  |d      j                         }|j                  }|j                  }n|dk(  rHt        j                  j                  |d      j                         }|j                   }|j"                  }nL|d	k(  rGt$        j                  j                  |d      j                         }|j&                  }|j(                  }t+        || j,                  t/                     S )
Ncompatibilityr  r   r  Tr   r  r  r  )r9   r:   r\   rm   r&   r;   rF   r   r<   CompatibilityHoroscopefemale_horoscopemale_horoscopeCompatibilityChineseZodiacfemale_chinese_zodiacmale_chinese_zodiacCompatibilityFiveElementsfemale_element_namemale_element_nameCompatibilityMBTIfemale_mbti_namemale_mbti_namer   rQ   r   )rS   r=   r   r  rz   compatibility_objfemale_value
male_values           r/   r:   zEditUserCompatibility.get  s{   [[___-(x   ''W\\__'=CCE))-55<<TX<Y__a#44<!00:/##199@@BX\@]cce#99<!55:->!088??2W[?\bbd#77<!33:%6(00772t7TZZ\#44<!00:	**68	44r1   c           
         	 |j                   j                  d      }t        d|       |dk(  rt        }d}d}n/|dk(  rt        }d}d}n|d	k(  rt
        }d
}d}n|dk(  r
t        }d}d}t        j                  |j                         }|j                         r|j                  j                  d      }|j                  j                  d      }	|j                  j                  d      }
|j                  j                  d      }|j                  j                  d      }||	d|
d|d|i} j                  j                  |      j                  di | t        j                  |d       t!        d      S t#        || j$                        S # t&        $ r+}t        j(                  |d       t!        d      cY d }~S d }~ww xY w)Nr  r  r  r  r  r  r  r  r  r  r  r  r  r  femalemalecompatibility_scorer  r  r   r  user-compatibilityr   r   rb   )rY   r:   r\   r  r  r  r  r   usercompatibilityformrZ   r[   r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   r  r  female_modal_fieldmale_modal_fieldrW   r"  r#  r$  r  r  r  r   s                  r/   r?   zEditUserCompatibility.post%  s   / ll/8!+'J+'$$+J0,N"*J.*F"J+'

%
%gll
34
mmo""8,F  (D++//0EF##I.G##''6K t.KK ,J$++:k:W34())'$,,--	  GEF
;
 s$   E4F 7F 	G F<6G<GNr  rb   r1   r/   r  r    s(    />C015 2580 r1   r  c                   :    e Zd ZdZ e ed            d        Zy)UserCompatibilityzuser_compatibility.htmlrh   r   c                 t   	 t         j                  j                  |j                  j                        j                         }	 t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }	 t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }	 t        j                  j                  d      j                  d      }	t        |	d      }|j                  j                  d      }|j                  |      }
	 t        j                  j                  d      j                  d	      }t        |d      }|j                  j                  d
      }|j                  |      }t        || j                   t#                     S # t$        $ r+}t'        j(                  |d       t+        d      cY d }~S d }~ww xY wr  )rm   r&   r;   rF   r   r<   r  r   r   r9   r:   r   r  r  r  r   rQ   r   r   r   r   r   r  s                 r/   r:   zUserCompatibility.getZ  s    !!((glloo(>DDF9*)1188D8QZZ[_`=+9[[__[1? ))/:/2::AAUYAZccdhi+R09[[__%56?''8?-088??SW?Xaabfg*B/9[[__^4?#,,_=%''..$.GPPQVW82&9[[__V,?$$_5<
++FH
55	  GEF
;
 r  Nr   rb   r1   r/   r*  r*  X  s#    *>C01  2 r1   r*  c           	      2   	 | j                   dk(  
r/| j                  d   
r| j                  d   }| j                  j                  d      }t	        |       |j                         j                  d      j                         }t        j                  |      }d}|dk(  rIt        j                  j                         j                          |D ]  }	 | j                  j                  }t         j                  j#                  |      }|s1t%        j&                  | d|j(                   d	       t+        d
      c S 	 d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S t        j                  j#                  |d   |d   |d   |d   |d   d      j/                         }	|	r+|dz  }t%        j0                  | d|j(                   d	       t        |d   |d   |d   |d   |d         }
|
j3                           n|dk(  rIt4        j                  j                         j                          |D ]  }	 | j                  j                  }t         j                  j#                  |      }|s1t%        j&                  | d|j(                   d	       t+        d
      c S 	 d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S t4        j                  j#                  |d   |d   |d   |d   |d   d      j/                         }	|	r+|dz  }t%        j0                  | d|j(                   d	       t5        |d   |d   |d   |d   |d         }|j3                           n|dk(  rIt6        j                  j                         j                          |D ]  }	 | j                  j                  }t         j                  j#                  |      }|s1t%        j&                  | d|j(                   d	       t+        d
      c S 	 d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S t6        j                  j#                  |d   |d   |d   |d   |d   d       j/                         }	|	r+|dz  }t%        j0                  | d|j(                   d	       t7        |d   |d   |d   |d   |d   !      }|j3                           no|d"k(  rHt8        j                  j                         j                          |D ]  }	 | j                  j                  }t         j                  j#                  |      }|s1t%        j&                  | d|j(                   d	       t+        d
      c S 	 d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S t8        j                  j#                  |d   |d   |d   |d   |d   d#      j/                         }	|	r+|dz  }t%        j0                  | d|j(                   d	       t9        |d   |d   |d   |d   |d   $      }|j3                           n!t%        j&                  | d%       t+        d
      S |dkD  r$t%        j&                  | | d&       t+        d
      S t%        j:                  | d'       t+        d
      S t%        j&                  | d(       t+        d
      S # t,        $ r4 t%        j&                  | d|j(                   d	       t+        d
      cY c S w xY w# t,        $ r4 t%        j&                  | d|j(                   d	       t+        d      cY c S w xY w# t,        $ r4 t%        j&                  | d|j(                   d	       t+        d
      cY c S w xY w# t,        $ r4 t%        j&                  | d|j(                   d	       t+        d
      cY c S w xY w# t<        $ r+}t%        j0                  | d)       t+        d*      cY d }~S d }~ww xY w)+NrY   r  r  r  r   r  r   r  r  r%  r  Femalez(female is missing in csv. Error in line Malez&male is missing in csv. Error in line Score'score is missing in csv. Error in line r  r  r  r  T)r  r  r$  r  r  r   r   Duplicate data found in line )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   )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  rY   r:   r\   r  r  r   r  r  r  r&   r'   deleterF   r   r   r;   r   r   r  r   r  r<   r   rw   r  r  r  r]   r   r  s                  r/   importUserCompatibilityDataCSVr3  }  s)   l^^v'--">mmM*8ll|,8?--/((1<<><NN<(6?/!""&&(//1,\\__d$$$$/h~~g!CFOOCTTUVW+,,  	nnWGGXXYZ[*++cnnWEfooEVVWXY*++snnWFvFWWXYZ*++nnWHHYYZ[\*++S nnWLV__L]]^_`*++3;;BB8}[g,)nm$ C  uw  	ow"??PPQ RS ,8}[g,)nm$] e f 	L &&**,335*\\__d$$$$/h~~g!CFOOCTTUVW+,,  	nnWGGXXYZ[*++cnnWEfooEVVWXY*++snnWFvFWWXYZ*++nnWHHYYZ[\*++S nnWLV__L]]^_`*++7??FFMf+g,)nm$ G  uw  	ow"??PPQ RS,Mf+g,)nm$Z __a b 	M!%%))+224,\\__d$$$$/h~~g!CFOOCTTUVW+,,  	nnWGGXXYZ[*++cnnWEfooEVVWXY*++snnWFvFWWXYZ*++nnWHHYYZ[\*++S nnWLV__L]]^_`*++ 7>>EEh-Fg,)nm$ F  uw  	ow"??PPQ RS .h-Fg,)nm$\ e f 	J!!#**,,\\__d$$$$/h~~g!CFOOCTTUVW+,,  	nnWGGXXYZ[*++cnnWEfooEVVWXY*++snnWFvFWWXYZ*++nnWHHYYZ[\*++S nnWLV__L]]^_`*++.66==8}[g,)nm$ >  uw  	ow"??PPQ RS "8}[g,)nm$X ]]_c f NN734())NN7//QRS())W56())>>'12
'
((o  ,nnW GGXXYZ[*++,l  *nnW GGXXYZ[())*h  ,nnW GGXXYZ[*++,l  ,nnW GGXXYZ[*++,p 	 
7DE	+	sX  Cm" A&i":m" =5m" 34m" (4m" 4m" 4m" Cm" #A&j"	m" 5m" 4m" 74m" ,4m" !4m" Cm" 2A&k"m" 5m" 4m" 4m" ;4m" 04m" %Cm" A&l"'m" *5m"  4m" 4m" 
4m" ?4m" 4Cm" 7(m"   m"  m" "8jm" jm" "8km" km" "8lm" lm" "8mm" mm" "	n+ nnnc                   @    e Zd ZdZ e ed            d        Zd Zy)EditAdvisorsCompatibilityzedit_advisor_compatibility.htmlrh   r   c                    |j                   j                  d      }t        d|       t        j                  j                  |j                  j                        j                         }	 |dk(  r<t        j                  j                  |d      j                         }|j                  }n@|dk(  r;t        j                  j                  |d      j                         }|j                  }t        || j                  t                     S )Nadvisorr  r   r  Tr   r  )r9   r:   r\   rm   r&   r;   rF   r   r<   AdvisorCompatibilityHoroscoper  AdvisorCompatibilityMBTItagline_for_relationshipr   rQ   r   )rS   r=   r   r  rz   advisor_objr  s          r/   r:   zEditAdvisorsCompatibility.getp  s    [[__Y'(
8  ''W\\__'=CCE)).66==UY=Z``b;  7%6)1188BPT8U[[];117	**68	44r1   c                    	 |j                   j                  d      }t        d|       |dk(  r	t        }d}n|dk(  rt        }d}t        j                  |j                         }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d	      }	|j                  j                  d      }
d|d|d	|	|
i} j                  j                  |
      j                  di | t        j                  |d       t        d      S t        || j                         S # t"        $ r+}t        j$                  |d       t        d      cY d }~S d }~ww xY w)Nadvisor_tabr  r  r  r  r:  r7  rF   r$  r   r  advisor-compatibilityr   r   rb   )rY   r:   r\   r8  r9  r   advisorscompatibilityformrZ   r[   r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   r  r  r  rW   r7  rF   r$  r  r  r   s                r/   r?   zEditAdvisorsCompatibility.post  sc   # ll}-8!+.JKF)J,K

)
)',,
74
mmo##I.G  (D++//0EF##I.G T/'	K ,J$++:k:W34+,,'$,,--	  GEF
;
 s$   D3E 6E 	F  E;5F ;F Nr  rb   r1   r/   r5  r5  n  s(    2>C015 25$ r1   r5  c                   :    e Zd ZdZ e ed            d        Zy)AdvisorsCompatibilityzadvisors_compatibility.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }	 t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }	 t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S # t         $ r+}	t#        j$                  |d       t'        d	      cY d }	~	S d }	~	ww xY w)
Nr   Tr   r   r   r  r  r   r   )rm   r&   r;   rF   r   r<   r8  r   r   r9   r:   r   r9  r   rQ   r   r   r   r   r   )
rS   r=   rz   r  r   r  r  r  r  r   s
             r/   r:   zAdvisorsCompatibility.get  s"    !!((glloo(>DDF9*088??SW?Xaabfg=+9[[__[1? ))/:%&..555NWWX\]82&9[[__V,?$$_5<
++FH
55	  GEF
;
 s   D0D3 3	E'< E"E'"E'Nr   rb   r1   r/   rA  rA    s#    .>C01  2 r1   rA  c                    	 | j                   dk(  r| j                  d   r| j                  d   }| j                  j                  d      }t	        |       |j                         j                  d      j                         }t        j                  |      }d}|dk(  rt        j                  j                         j                          |D ]  }	 | j                  j                  }t         j                  j#                  |      }|s1t%        j&                  | d|j(                   d	       t+        d
      c S 	 d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S t        j                  j#                  |d   |d   |d   |d   d      j/                         }	|	r+|dz  }t%        j0                  | d|j(                   d	       t        |d   |d   |d   |d         }
|
j3                           n2|dk(  rt4        j                  j                         j                          |D ]  }	 | j                  j                  }t         j                  j#                  |      }|s1t%        j&                  | d|j(                   d	       t+        d
      c S 	 d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S d|vr1t%        j&                  | d|j(                   d	       t+        d
      c S t4        j                  j#                  |d   |d   |d   |d   d      j/                         }	|	r+|dz  }t%        j0                  | d|j(                   d	       t5        |d   |d   |d   |d         }|j3                           n!t%        j&                  | d       t+        d
      S |dkD  r$t%        j&                  | | d       t+        d
      S t%        j6                  | d       t+        d
      S t%        j6                  | d        t+        d
      S # t,        $ r4 t%        j&                  | d|j(                   d	       t+        d
      cY c S w xY w# t,        $ r4 t%        j&                  | d|j(                   d	       t+        d
      cY c S w xY w# t8        $ r+}t%        j0                  | d!       t+        d"      cY d }~S d }~ww xY w)#NrY   r  r  r  r   r  r   r  r  r>  r  Advisorz)Advisor is missing in csv. Error in line r   z&User is missing in csv. Error in line r/  r0  r  r  T)r7  rF   r$  r  r   r   r1  )r7  rF   r$  r  r  zTag Line for relationship)r7  rF   r$  r:  r   )r7  rF   r$  r:  r  r  r  r   r   r   )r  r  rY   r:   r\   r  r  r   r  r  r8  r&   r'   r2  rF   r   r   r;   r   r   r  r   r  r<   r   rw   r9  r]   r   )r=   r  r  r  r  r  r	  rF   r   r
  r  r  r   s                r/   importAdvisorCompatibilityCSVrE    s   x^^v'--">mmM*8ll|,8?--/((1<<><NN<(6?/!!))--/668/\\__d$$$$/h~~g!CFOOCTTUVW.//  	nnWHHYYZ[\-..cnnWEfooEVVWXY-..snnWFvFWWXYZ-..nnWHHYYZ[\-..:BBII)nv;g,)n J  uw  	ow"??PPQ RS 3)nv;g,)n	] [ \ 	J$$((*113/\\__d$$$$/h~~g!CFOOCTTUVW.//  	nnWHHYYZ[\-..cnnWEfooEVVWXY-..snnWFvFWWXYZ-..#3.nnWHHYYZ[\-..5==DD)nv;g,"#>? E  uw  	ow"??PPQ RS ))nv;g,"#>?	X ]]_[ ^ NN734+,,NN7//QRS+,,W56+,,
723	)	**G  /nnW GGXXYZ[-../b  /nnW GGXXYZ[-../f 	 
7DE	+	s   CW
 A&U
:W
 =5W
 34W
 (4W
 4W
 CW
 &A&V
W
 5W
 4W
 :4W
 /4W
 $B:W
 (W
  W
 ) W
 
8VW
 VW
 
8WW
 WW
 
	W> W93W>9W>c                   @    e Zd ZdZ e ed            d        Zd Zy)AdminProfilezadmin_profile.htmlrh   r   c                 4   	 t         j                  j                  |j                  j                        j                         }t        || j                  t                     S # t        $ r+}t        j                  |d       t        d      cY d }~S d }~ww xY w)Nr   r   r   )rm   r&   r;   rF   r   r<   r   rQ   r   r   r   r   r   )rS   r=   rz   r   s       r/   r:   zAdminProfile.get;  st     !!((glloo(>DDF9
++FH
55	  GEF
;
 s   A A# #	B, BBBc                     	 t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        j                  j                  |j                  j                        j                  |||||       |j                  j                  d      rvt        |j                  j                  d            }d	|z   }t        j                  j                  |j                  j                        j                  t        |      
       t        j                   |d       t#        d      S t%        || j&                        S # t(        $ r+}	t        j*                  |d       t#        d      cY d }	~	S d }	~	ww xY w)Nr  r  r3   r  addressr   )	firstNamelastNamer3   phoneNumberrJ  avatarrh   )imagerj  zadmin-profiler   r   )r   adminprofile_formrY   rZ   r[   r:   rm   r&   r;   rF   r   r  r  uploadTheImagesr+   r   r]   r   r   rQ   r   r   )
rS   r=   rW   r  r  r3   r  rJ  fileUrlr   s
             r/   r?   zAdminProfile.postD  s    

!
!',,
/4
mmo""&&|4J!!%%k2I!!'*E$$((8L##I.G7<<??3::ZYbin  |H  QX:  Y}}"W]]..x89W[WGLLOO4;;#g,;OW23O$$'$,,--	  GEF
;
 s$   F0G	 3G	 		G= G82G=8G=Nr  rb   r1   r/   rG  rG  9  s(    %>C01  2  r1   rG  c                   :    e Zd ZdZ e ed            d        Zy)ContentPageListingzcontent_page_list.htmlrh   r   c                 t   	 t         j                  j                  |j                  j                        j                         }t        j                  j                  d      }t        || j                  t                     S # t        $ r+}t        j                  |d       t        d      cY d }~S d }~ww xY w)Nr   Tr   r   r   rm   r&   r;   rF   r   r<   ContentManagementr   rQ   r   r   r   r   r   )rS   r=   rz   content_objr   s        r/   r:   zContentPageListing.get]  s     !!((glloo(>DDF9"**11T1J;
++FH
55	  GEF
;
 s   B B 	B7 B2,B72B7Nr   rb   r1   r/   rT  rT  [  s#    )>C01  2 r1   rT  c                   @    e Zd ZdZ e ed            d        Zd Zy)UpdateContentPagezupdate_content_page.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        || j                  t                     S # t        $ r+}t        j                  |d       t        d      cY d }~S d }~ww xY w)Nr   r   r   r   rV  )rS   r=   r   rz   rX  r   s         r/   r:   zUpdateContentPage.getj  s     !!((glloo(>DDF9"**11r1:@@B;
++FH
55	  GEF
;
 s   BB 	C C :C Cc                    	 t        j                  |j                        }|j                         rl|j                  j                  d      }t        j                  j                  |      j                  |       t        j                  |d       t        d      S t        || j                        S # t        $ r+}t        j                   |d       t        d      cY d }~S d }~ww xY w)Ncontentr   )r>   rj  zcontent-page-listingr   r   )r   updatecontent_formrY   rZ   r[   r:   rW  r&   r;   r  r   r]   r   r   rQ   r   r   )rS   r=   r   rW   r]  r   s         r/   r?   zUpdateContentPage.postt  s     

"
"7<<
04
mmo##I.G$$$+222@W23*++'$,,--	  GEF
;
 rP  Nr  rb   r1   r/   rZ  rZ  h  s(    +>C01  2  r1   rZ  c                   :    e Zd ZdZ e ed            d        Zy)RefundMoneyListzrefund_money_list.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }|j                  j                  d      }|j                  j                  d      }d}t               }|rSt        |      }t        t        j                  |            }	|j                  t        |	      t        j                          |r^|j                  t        |	      t        |
      z  t        |      z  t        |      z  t        |      z  t        j                          t        j                  j                  |d      j                  d      }t#        |d      }
|j                  j                  d      }|
j%                  |      }t'        || j(                  t+                     S )Nr   Tr   r   r   refund_dater   r  r  r  ))booking__seer_user__first_name__icontains)(booking__seer_user__last_name__icontains))booking__service__service_name__icontainsr   r   )rm   r&   r;   rF   r   r<   AdminRefundRequestr   r9   r:   r   r+   r   r   r  r   r   r   r   r   rQ   r   )rS   r=   rz   r9  r   rb  r   r   r  refund_date_timer   r   
refund_objs                r/   r:   zRefundMoneyList.get  s     ''W\\__'=CCE)''..$.GPPQVW()+.+	$C'[!; !7!7!DE
;;q"23QUU;
;;qLQ  ~I  NJ  J  KL  wB  KC  C  DE  oz  D{  {  |}  hs  |t  t  vw  v{  v{  |  ''..w$.OXXY^_("%)'+!!+.*	**68	44r1   Nr   rb   r1   r/   r`  r`    s#    )>C015 25r1   r`  c                   d    e Zd ZdZ e ed            d        Z e ed            d        Zy)RefundMoneyDetailszrefund_money_details.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  d|      j                         }t        || j                  t                     S )Nr   Tr   r   )
rm   r&   r;   rF   r   r<   rf  r   rQ   r   )rS   r=   r   rz   r9  s        r/   r:   zRefundMoneyDetails.get  sg      ''W\\__'=CCE)''..$".MSSU(	**68	44r1   c                    t         j                  j                  d|      j                         }|j                  j                  d      }|j                  }t        j                  j                  |j                  j                        j                         }|dk(  r_|j                  dk(  r.t        j                  j                  |j                        j                         }|j                  |z   }||_        |j                          d|_
        t        j                          |_        |j                          t$        j                  j'                  t)               d	||j                  |d
       t*        j                  j'                  d|j,                  z   dz   t/        |      z   d	|j                         t1        j2                  |d       tC        d      S t1        j4                  |d       tC        d      S |dk(  rt$        j                  j                  |      j                         }	|	j6                  rJ|j                  dk(  r|dz  }
t8        j:                  t<        _        t<        j@                  j'                  |	j6                  |
       d|_
        t        j                          |_        |j                          t$        j                  j'                  t)               d	||j                  |d
       t*        j                  j'                  d|j,                  z   dz   t/        |      z   d	|j                         t1        j2                  |d       tC        d      S t1        j4                  |d       tC        d      S t1        j4                  |d       tC        d      S t1        j4                  |d       tC        d      S )NTrl  refund_typer   walletr   r  	Completedrefund)r)   transcation_typebookingr  r   payment_modezYour refund for appointment ID:z% has been processed. Refund amount: $)r@   notification_typer  zRefund to Wallet SuccessfulzAlready Refundedaccount)rs  d   )charger   zRefund to Account SuccessfulzJCharge ID is not provided. Cannot process the refund. Proceed with wallet.zInvalid Refund Typezrefund-money-list)"rf  r&   r;   r<   rY   r:   refund_amountr   appointmentr   r    SeerUserWalletr  r   rw   r   nowdate_processedr%   rJ  r0   SeerUserNotificationsr  r+   r   r]   r   	charge_idr   STRIPE_SECRET_KEYstripeapi_keyRefundr   )rS   r=   r   r9  rn  ry  appointment_objuser_wallet
new_amountseer_user_transexact_amounts              r/   r?   zRefundMoneyDetails.post  s    !((//"/MSSU8!!-0;))=+33::h>R>R>U>U:V\\^?X)#!))00?;T;T0U[[][$$}4Z$["X_'||~X]]_  ''7M7Obj  uD  P_  Pi  Pi  r  NV'  W""))2SVeVtVt2t  x_  3_  be  fs  bt  3t  HP  \k  \u  \u)  vg<=. &
''+ ^^G/0* &
'') 	y )11888QWWYO  9$"S(l11fnmm/";";<P#ho (hmmo!!((8N8Pck  vE  Q`  Qj  Qj  s@  OW(  X##**3TWfWuWu3u  y`  4`  cf  gt  cu  4u  IQ  ]l  ]v  ]v*  ww >? &
'' nnW01 &
''	 nnWjk &
'' NN712
&
''r1   Nr  rb   r1   r/   rj  rj    sA    ,>C015 25 >C01(( 2((r1   rj  c                 h   t         j                  j                  d      }|s!t        j                  | d       t        d      S t        d      }d|d<   t        j                  |      }|j                  g d	       |D ]/  }|j                  |j                  j                  |j                  j                  j                  d
z   |j                  j                  j                  z   |j                  j                  j                  d
z   |j                  j                  j                  z   |j                  j                   |j                  j"                  |j                  j$                  j&                  dt)        |j                  j*                        z   |j                  j,                  dg	       2 |S )Nrq  )rr  zNo data foundz/refund-money-listr  r  z!attachment; filename="refund.csv"r  )	r  r  zCustomer Namer  r  r  zRefund AmountzRefund DatezRefund Statusr   z$ rp  )r%   r&   r;   r   r   r   r   r  r  r  rs  r  r*  r  r  r  r  r  r  r`  r+   r  
created_atr  s        r/   ExportCSVRefundr    sN   ''...I
7O,	&	''j1#F
 
**X
  p  q T//4<<..,,((,T\\-H-H-R-RR,,##C'(>(>(H(HH,,,,,,##DLL,,   	r1   c                   6    e Zd Z e ed            d        Zy)AdminLogoutrh   r   c                 Z    t        |       t        j                  |d       t        d      S )NzLogout Succesfullyrh   )r
   r   r]   r   rR   s     r/   r:   zAdminLogout.get  s$    /
701	#r1   Nr_   r`   ra   r   r   r:   rb   r1   r/   r  r    s    >C01 2r1   r  c                   @    e Zd ZdZ e ed            d        Zd Zy)AdminResetPasswordadmin_reset_password.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        || j                  t                     S r?  r@  rA  s      r/   r:   zAdminResetPassword.get  rB  r1   c                 &   	 t        j                  |j                        }|j                         r|j                  j	                  d      }t
        j                  j	                  |j                  j                        }|j                  |       |j                          t        |       t        j                  |d       t        d      S t        |dd|i      S # t         $ r+}t        j"                  |d       t        d      cY d }~S d }~ww xY w)	NconfirmPasswordrJ   z)You have successfully reset your passwordrh   r  rW   r   r   )r   change_password_formrY   rZ   r:   r   r&   rF   r3   r   rw   r
   r   infor   r   r   r   )rS   r=   rW   rD   rF   r   s         r/   r?   zAdminResetPassword.post  s     

$
$W\\
24
mmo|| 12H||gll&8&89DhIIK
7OMM'FGC='6GG	  GEF
;
 s$   C
C C 	D% DDDNr  rb   r1   r/   r  r    s(    ,>C015 25 r1   r  c                   @    e Zd ZdZ e ed            d        Zd Zy)CancellationChargecancellation_charge.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                         j                         }t        || j                  t                     S r?  )rm   r&   r;   rF   r   r<   GeneralSettingsr'   r   rQ   r   )rS   r=   rz   general_objs       r/   r:   zCancellationCharge.get  s`      ''W\\__'=CCE) ((,,.446+	**68	44r1   c                 z   t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        j                  j                         j                         }|r=t        j                  j                  |j                        j                  |||       n!t        j                  j                  ||       t        j                  |d       t!        d      S t#        |d	d
|i      S )Ncancellation_chargerefer_friend_offcommission_percentager   )r  r  r  )r  r  zCharges added succesfullyz/cancellation-charger  rW   )r   generalsettingformrY   rZ   r[   r:   r  r&   r'   r<   r;   r   r  rJ  r   r]   r   r   )rS   r=   rW   r  r  r  
check_datas          r/   r?   zCancellationCharge.post  s   		!	!',,	/$	]]_**../DE''++,>?,,001HI''++-335:""jmm"4;;Re  xH  _t;  u""7J\l"mG89
)
**
3VDM
BBr1   Nr  rb   r1   r/   r  r    s)    +>C015 25
Cr1   r  c                   :    e Zd ZdZ e ed            d        Zy)HelpSupportListzhelp_support_list.htmlrh   r   c                    	 t         j                  j                  |j                  j                        j                         }t        j                  j                         j                         }t        j                  j                  d      j                         }t        j                  j                  d      j                         }t        j                  j                         j                  d      }t        |d      }|j                  j                  d      }|j                  |      }	t        || j                  t!                     S # t"        $ r+}
t%        j&                  |d       t)        d	      cY d }
~
S d }
~
ww xY w)
Nr   Tr   Fr   r   r   r   r   )rm   r&   r;   rF   r   r<   HelpSupportr'   r   r   r   r9   r:   r   r   rQ   r   r   r   r   r   )rS   r=   rz   totalresolvedpendinghelp_objr   r   sup_objr   s              r/   r:   zHelpSupportList.get-  s"    !!((glloo(>DDF9""$**,5!!(($(7==?8  '''7==?7!!%%'00782&9(;,7
++FH
55	  GEF
;
 s   EE 	F E?9F?FNr   rb   r1   r/   r  r  +  s#    )>C01  2 r1   r  c                   :    e Zd ZdZ e ed            d        Zy)HelpSupportViewzhelp_support_view.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        || j                  t                     S r  
rm   r&   r;   rF   r   r<   r  r   rQ   r   )rS   r=   r   rz   r  s        r/   r:   zHelpSupportView.getA  se      ''W\\__'=CCE)  ''2'.446'	**68	44r1   Nr   rb   r1   r/   r  r  ?  s#    )>C015 25r1   r  c                   @    e Zd ZdZ e ed            d        Zd Zy)HelpSupportSendhelp_support_send.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        || j                  t                     S r  r  )rS   r=   r   rz   helps        r/   r:   zHelpSupportSend.getK  se      ''W\\__'=CCE)



$
$
$
+
1
1
3$	**68	44r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        d|||d      }|}t        j                  }	|}
t        j                  |||	|
g|       t        j                  j                  |      j                  |t        j                          d	       t        j                  j                  |      j#                         }|j$                  r|j$                  j&                  }t)        t        j*                        }|j$                  j,                  d
k(  r#dddd}t/        |      j1                  ||      }|j$                  j,                  dk(  rd}d}dddd}t/        |      j1                  ||||      }n|j2                  j&                  }t)        t        j*                        }|j2                  j,                  d
k(  r#dddd}t/        |      j1                  ||      }|j2                  j,                  dk(  r)d}d}dddd}t/        |      j1                  ||||      }t5        j6                  |d       t9        d      S t;        |dd|i      S )Nr3   r   replyzsupport_email.html)
reply_textr3   r   rj   r   T)r  
reply_dater    Androidhelp_supportHELP & SUPPORTz7You recived a mail for help and support from seer team.)typetitler@   )r  )registration_iddata_messageIos)r  )r  message_titlemessage_bodyr  zsend successfullyz/help-support-listr  rW   )r   sendsupportformrY   rZ   r[   r:   r   r   rx   r   ry   r  r&   r;   r  r   r|  r<   r  	fcm_tokenr+   FIREBASE_SERVER_KEYdevice_typer   notify_single_devicer*  r   r]   r   r   )rS   r=   r   rW   r3   r   r  rk   r   r   r   r  r  
server_keyr  resultr  r  s                     r/   r?   zHelpSupportSend.postQ  s   



-4
mmo""7+E##I.G!!'*E#$8W\gn:opL M))J	BNN7M:t,W"%,,5hlln\`,a""))R)0668H))33_h223Z&&)3 .&Ql
 z2GGXg  xDG  Ef&&%/'mOl .&Ql z2GGXg  xEl H <f  ..88_h223Z++y8 .&Ql
 z2GGXg  xDG  Ef++u4'mOl .&Ql z2GGXg  xEl H <f W12())'2F4=AAr1   Nr  rb   r1   r/   r  r  I  s)    )>C015 25
9Br1   r  c                   :    e Zd ZdZ e ed            d        Zy)LifestyleQuestionListzlife_question_list.htmlrh   r   c                 v   t         j                  j                  |j                  j                        j                         }t        j                  j                  d      }|j                  j                  d      }t               }|r*|j                  t        |      t        j                         t        j                  j                  |d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                   t#                     S )	Nr   Tr   r   question_title__icontainsr   r   r   )rm   r&   r;   rF   r   r<   LifestyleQuestionr9   r:   r   r   r   r   r   r   r   rQ   r   	rS   r=   rz   r9  r   r   r   r   ques_objs	            r/   r:   zLifestyleQuestionList.get  s      ''W\\__'=CCE)''..$.G()+C'
;;q;7?&&--g-NWWX]^("%)'+,(	**68	44r1   Nr   rb   r1   r/   r  r    #    *>C015 25r1   r  c                   @    e Zd ZdZ e ed            d        Zd Zy)AddLifestyleQuestionadd_lifestyle_question.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        || j                  t                     S r?  r@  rS   r=   r   rz   s       r/   r:   zAddLifestyleQuestion.get  rB  r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      }t        j                  j                  ||       |j                  j                  d      r]|j                  j                  d      }t        j                  |      }|D ](  }|d   }t        j                  j                  ||       * t        j                  |d       t        d      S t        |dd	|i      S )
Nlifestyle_questionoptionquestion_titler  r  hidden-fieldQuestion Added Successfully/lifestyle-questions-listr  rW   )r   addlifestyleformrY   rZ   r[   r:   r  r&   rJ  LifestyleOptionsjsonloadsr   r]   r   r   )	rS   r=   rW   r  r  lifestyle_objhidden_value	rows_datar	  s	            r/   r?   zAddLifestyleQuestion.post  s   				-$	]]_))--.BC!!(+6$,,33CU3V=""V"Tll~&<<##N3L

<(I(mV$$V$T  G:;
.
//
6t}
EEr1   Nr  rb   r1   r/   r  r    s)    .>C015 25Fr1   r  c                   @    e Zd ZdZ e ed            d        Zd Zy)EditLifestyleQuestionedit_lifestyle_question.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        j                  j                  |      j                         }t        j                  j                  |      dd  }t        || j                  t                     S )Nr   r   r  r   )rm   r&   r;   rF   r   r<   r  r  r   rQ   r   rS   r=   r   rz   question_objoption_obj_first
option_objs          r/   r:   zEditLifestyleQuestion.get  s      ''W\\__'=CCE)"**11R18>>@,%--44"4MSSU''..".EabI*	**68	44r1   c                     t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      j                  |      }t        j                  j                  |      j                         }t        j                  j                  |j                        }|D ]  }	|	j                           t        j                  j                  ||       |j                  j                  d      rt        j                  j                  |      dd  }
|
D ]  }|j                           |j                  j                  d      j                  d	      }|D ]%  }|}t        j                  j                  ||       ' t!        j"                  |d
       t%        d      S t'        |dd|i      S )Nr  r  r   r  r  r  hidden-field-twor   ,Question Updated Successfullyr  r  rW   )r   r  rY   rZ   r[   r:   r  r&   r;   r  r<   r  r   r2  rJ  r   r   r]   r   r   )rS   r=   r   rW   r  option_datar  lifestyle_mainoptions_obj
option_allvariation_objvarr  r	  s                 r/   r?   zEditLifestyleQuestion.post  s   				-$	]]_))--.BC""&&x0;$,,33r3:AAQcAd=&..555<BBD>!))00NDUDU0V; z !""k"Zll)*$,,33r3J12NMZZ\ <<##$67==cBL[$$k$Z  G<=
.
//
7
FFr1   Nr  rb   r1   r/   r  r    s)    />C015 25Gr1   r  c                     | j                   j                  d      }t        j                  j	                  |      j                         }|j                          t        d      S N	option_idr   r]   )r9   r:   r  r&   r;   r<   r2  r   r=   r>   mbit_objs      r/   RemoveLifestyleOptionr    sK    $$$++t+4::<	Yr1   c                   :    e Zd ZdZ e ed            d        Zy)MbtiQuestionListzmbit_question_list.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }|j                  j                  d      }t               }|r*|j                  t        |      t        j                         t        j                  j                  |d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                   t#                     S )	Nr   Tr   r   r   r  r   r   )rm   r&   r;   rF   r   r<   MbtiQuestionr   r9   r:   r   r   r   r   r   r   rQ   r   r  s	            r/   r:   zMbtiQuestionList.get  s      ''W\\__'=CCE)""))T)BKKER()+C'
;;q;7?!!((D(IRRSXY("%)'+,(	**68	44r1   Nr   rb   r1   r/   r  r    r  r1   r  c                   d    e Zd ZdZ e ed            d        Z e ed            d        Zy)AddMbtiQuestionadd_mbit_question.htmlrh   r   c                     t         j                  j                  |j                  j                        j                         }t        || j                  t                     S r?  r@  rA  s      r/   r:   zAddMbtiQuestion.get  rB  r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      }t        j                  j                  ||       |j                  j                  d      r]|j                  j                  d      }t        j                  |      }|D ](  }|d   }t        j                  j                  ||       * t        j                  |d       t        d      S t        |dd	|i      S )
Nmbit_questionr  r  mbti_questionr  r  r  z/mbit-questions-listr  rW   )r   addMbitformrY   rZ   r[   r:   r  r&   rJ  MbtiOptionsr  r  r   r]   r   r   )	rS   r=   rW   mbit_question_datar  r   r  r  r	  s	            r/   r?   zAddMbtiQuestion.post  s   			7<<	($	]]_))--o>!!(+6""))9K)L8hfEll~&<<##N3L

<(I(mVhfE  G:;
)
**
16$-
@@r1   Nr  rb   r1   r/   r  r    sC    )>C015 25 >C01A 2Ar1   r  c                   @    e Zd ZdZ e ed            d        Zd Zy)EditMbtiQuestionedit_mbti_question.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                         }t        j                  j                  |      j                         }t        j                  j                  |      dd  }t        || j                  t                     S )Nr   r   r  r   )rm   r&   r;   rF   r   r<   r  r  r   rQ   r   r  s          r/   r:   zEditMbtiQuestion.get  s      ''W\\__'=CCE)%%,,,399;, ((///CIIK"")));AB?*	**68	44r1   c                     t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      j                  |      }t        j                  j                  |      j                         }t        j                  j                  |j                        }|D ]  }	|	j                           t        j                  j                  ||       |j                  j                  d      rt        j                  j                  |      dd  }
|
D ]  }|j                           |j                  j                  d      j                  d	      }|D ]%  }|}t        j                  j                  ||       ' t!        j"                  |d
       t%        d      S t'        |dd|i      S )Nr  r  r   r  r  r  r  r   r  r  z/mbti-questions-listr  rW   )r   r  rY   rZ   r[   r:   r  r&   r;   r  r<   r  r   r2  rJ  r   r   r]   r   r   )rS   r=   r   rW   r  r  r  	mbti_mainr  r  r  r  r  r	  s                 r/   r?   zEditMbtiQuestion.post  s   			7<<	($	]]_))--o>""&&x0;""))R)077GY7Z8$$++r+288:9$$++),,+G; z ! i{Kll)*''..R.@DMZZ\ <<##$67==cBL[i{K  G<=
)
**
2F4=
AAr1   Nr  rb   r1   r/   r  r  
  s)    *>C015 25Br1   r  c                     | j                   j                  d      }t        j                  j	                  |      j                         }|j                          t        d      S r  )r9   r:   r  r&   r;   r<   r2  r   r  s      r/   RemoveMbitOptionr  3  sK    $&&$&/557	Yr1   c                   :    e Zd ZdZ e ed            d        Zy)AdminNotificationsListzadmin_notifications.htmlrh   r   c                 2   t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        j                  j                  dd      j                  d      }t        |d      }|j                  j                  d	      }|j                  |      }	t        j                  j                  d
d      j                  d      }
t        |
d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S )Nr   Tr   r   r   all_pager   is_readr   	read_pager   unread_page)rm   r&   r;   rF   r   r<   AdminNotificationsr   r   r9   r:   r   r   rQ   r   )rS   r=   rz   
all_notifyr   r  all_notify_objread_notifyread_page_numberread_notify_objunread_notifyunread_page_numberunread_notify_objs                r/   r:   zAdminNotificationsList.get<  sJ      ''W\\__'=CCE)!))00D0IRRSXY*
B')KKOOJ//%%o6."**11!t1T]]^cd+R()[[__[1&&'78/$,,33aSW3Xaabgh-r*){{}5(();< 
**68	44r1   Nr   rb   r1   r/   r  r  :  s#    +>C015 25r1   r  c                   6    e Zd Z e ed            d        Zy)ReadAllNotificationsrh   r   c                 F   t         j                  j                  |j                  j                        j                         }t        j                  j                  dd      }|D ]  }d|_        |j                           t        j                  |d       t        d      S )Nr   r   Tr  r   z%All notifications readed successfullyz/admin-notifications)rm   r&   r;   rF   r   r<   r"  r  rw   r   r]   r   )rS   r=   rz   
notify_objnotifys        r/   r:   zReadAllNotifications.getU  s      ''W\\__'=CCE)!))001PT0U*f6>	;;=  7BC	(	))r1   Nr  rb   r1   r/   r,  r,  T  s    >C01* 2*r1   r,  c                   :    e Zd ZdZ e ed            d        Zy)
FaqListingzfaq_listing.htmlrh   r   c                    t         j                  j                  |j                  j                        j                         }t        j                  j                  d      j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S )Nr   Tr   r   r   r   )rm   r&   r;   rF   r   r<   Faqr   r   r9   r:   r   r   rQ   r   )rS   r=   rz   r9  r   r   faq_objs          r/   r:   zFaqListing.geta  s      ''W\\__'=CCE)[[48AA%H("%)'+{+'	**68	44r1   Nr   rb   r1   r/   r1  r1  _  s#    #>C015 25r1   r1  c                   :    e Zd ZdZ e ed            d        Zy)AddFaqadd_faq.htmlrh   r   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        j                  j                  |||       t        j                  |d       t        d      S t        |d      S )Nr  r]  r  r  r]  r  zCreated Successfully/faq-listingr7  )r   
addfaqformrY   rZ   r[   r:   r3  r&   rJ  r   r]   r   r   )rS   r=   rW   r  r]  r  s         r/   r?   zAddFaq.postn  s    			',,	'$	]]_  )5""9-7





'4;;E't<G34
>
""

((r1   N)r_   r`   ra   rQ   r   r   r?   rb   r1   r/   r6  r6  l  s#    >C01
) 2
)r1   r6  c                   @    e Zd ZdZ e ed            d        Zd Zy)EditFaqedit_faq.htmlrh   r   c                 "   t         j                  j                  |j                  j                        j                         }t        j                  j                  |d      j                         }t        || j                  t                     S r  )
rm   r&   r;   rF   r   r<   r3  r   rQ   r   )rS   r=   r   rz   r4  s        r/   r:   zEditFaq.get  se      ''W\\__'=CCE)KK"=CCE'	**68	44r1   c                    t        j                  |j                        }|j                         r|j                  j                  d      }|j                  j                  d      }|j                  j                  d      }t        j                  j                  |      j                  |||       t        j                  |d       t        d      S t        |d      S )	Nr  r]  r  r   r9  zUpdated Successfullyr:  r>  )r   r;  rY   rZ   r[   r:   r3  r&   r;   r  r   r]   r   r   )rS   r=   r   rW   r  r]  r  s          r/   r?   zEditFaq.post  s    			',,	'$	]]_  )5""9-7





'4;;##%T#JG34
>
""

))r1   Nr  rb   r1   r/   r=  r=  }  s(     >C015 25
*r1   r=  c                   6    e Zd Z e ed            d        Zy)	DeleteFaqrh   r   c                 L   t         j                  j                  |j                  j                        j                         }t        j                  j                  |      j                  t        j                                t        j                  |d       t        d      S )Nr   r   )end_datezFaq Deleted Successfullyr:  )rm   r&   r;   rF   r   r<   r3  r  r   r|  r   r]   r   r  s       r/   r:   zDeleteFaq.get  sq      ''W\\__'=CCE)++""HLLN";
767	.	!!r1   Nr  rb   r1   r/   rB  rB    s    >C01" 2"r1   rB  c                   :    e Zd ZdZ e ed            d        Zy)UserReportszuser_reports.htmlrh   r   c           	      \   t         j                  j                  |j                  j                        j                         }t        j                  j                  ddddddd      j                  t        d	      
      j                  d	      }|j                  j                  d      }t               }|rD|j                  t        |      t        |      z  t        |      z  t        j                         t        j                  j                  |      j                  ddddddd      j                  t        d	      
      j                  d	      }t!        |d      }|j                  j                  d      }|j#                  |      }t%        || j&                  t)                     S )Nr   seer_user__idseer_user__first_nameseer_user__last_nameseer_user__emailseer_user__primary_imageseer_user__created_atseer_user__statusr  total_appointmentsr   )rI  )rJ  )rK  r   r   rm   r&   r;   rF   r   r<   r   valuesannotater   r   r9   r:   r   r   r   r   r   r   rQ   r   	rS   r=   rz   r9  r   r   r   r   user_appointmentss	            r/   r:   zUserReports.get  sm     ''W\\__'=CCE)!!
F?23IJ\]w  yP  Qd  eHk 2H3H[	  )+C'
;;q{3A;4WWXYkvXwwyzy~y~!!((1
F?23IJ\]w  yP  Qd  eHk 2H3H[	  "%)'+((5	**68	44r1   Nr   rb   r1   r/   rF  rF    s#    $>C015 25r1   rF  c                       e Zd Zd Zy)ExportUserCsvReportc                    t         j                  j                  ddddddd      j                  t	        d      	      j                  d      }t        d
      }d|d<   t        j                  |      }|j                  g d       |D ]8  }|j                  |d   |d   dz   |d   z   |d   |d   |d   |d   |d   g       : |S )NrH  rI  rJ  rK  rL  rM  rN  r  rO  r  r  z&attachment; filename="user_report.csv"r  )zUser Idr  
User Emailz
User ImagezUser Created DatezUser StatuszBooked Appointmentsr   rP  
r   r&   rR  rS  r   r   r   r  r  r  rS   r=   r  r  r  r  s         r/   r:   zExportUserCsvReport.get  s2   !!
F?23IJ\]w  yP  Qd  eHk 2H3H[	  z2($L( !::h&//  A d	??D)40G+H3+NQUVlQm+mos  uG  pH  JN  Oi  Jj  lp  qH  lI  KO  Pc  Kd  fj  k  f@  A  B  
/r1   Nr_   r`   ra   r:   rb   r1   r/   rW  rW        r1   rW  c                       e Zd ZdZd Zy)ViewUserReportzview_user_report.htmlc                    t         j                  j                  |j                  j                        j                         }t        j                  j                  |      }g d}g }dd l}|j                  j                         }|j                  }	|D ]D  }
t        j                  j                  |	|
d|      j                         }|j                  |       F t        || j                  t                     S )Nr   r  r   r   T)r   r   r   r  rm   r&   r;   rF   r   r<   r   r   r   r   r   r   r   r   rQ   r   rS   r=   r   rz   r   r   r   r   r   r   r   r   s               r/   r:   zViewUserReport.get  s      ''W\\__'=CCE)'//6626F,a*(
--


%	$d'//66`dw{  IK6  L  R  R  T;??;  
**68	44r1   Nr_   r`   ra   rQ   r:   rb   r1   r/   r_  r_    s    (5r1   r_  c                   :    e Zd ZdZ e ed            d        Zy)FortuneTellerReportszfortune_report.htmlrh   r   c           	      \   t         j                  j                  |j                  j                        j                         }t        j                  j                  ddddddd      j                  t        d	      
      j                  d	      }|j                  j                  d      }t               }|rD|j                  t        |      t        |      z  t        |      z  t        j                         t        j                  j                  |      j                  ddddddd      j                  t        d	      
      j                  d	      }t!        |d      }|j                  j                  d      }|j#                  |      }t%        || j&                  t)                     S )Nr   fortune_teller__idfortune_teller__first_namefortune_teller__last_namefortune_teller__emailfortune_teller__imagefortune_teller__created_atfortune_teller__statusr*  rO  r   )rh  )ri  )rj  r   r   rQ  rT  s	            r/   r:   zFortuneTellerReports.get  s     ''W\\__'=CCE)!!
F <=XYp  rI  Jf  g  @H&6 7H8H	  )+C'
;;qK8U`9aabc  {F  cG  G  IJ  IN  IN  O!!((1
F <=XYp  rI  Jf  g  @H&6 7H8H	  "%)'+((5	**68	44r1   Nr   rb   r1   r/   re  re    s#    &>C015 25r1   re  c                       e Zd ZdZd Zy)ViewFortuneTellerReportszview_fortune_report.htmlc                    t         j                  j                  |j                  j                        j                         }t        j                  j                  |      }g d}g }dd l}|j                  j                         }|j                  }	|D ]D  }
t        j                  j                  |	|
d|      j                         }|j                  |       F t        || j                  t                     S )Nr   r)  r   r   T)r   r   r   r*  ra  rb  s               r/   r:   zViewFortuneTellerReports.get  s      ''W\\__'=CCE)'//666K,a*(
--


%	$d'//66`dw{  NP6  Q  W  W  Y;??;  
**68	44r1   Nrc  rb   r1   r/   ro  ro    s    +5r1   ro  c                       e Zd Zd Zy)ExportFortuneCsvReportc                    t         j                  j                  ddddddd      j                  t	        d      	      j                  d      }t        d
      }d|d<   t        j                  |      }|j                  g d       |D ]8  }|j                  |d   |d   dz   |d   z   |d   |d   |d   |d   |d   g       : |S )Nrg  rh  ri  rj  rk  rl  rm  r  rO  r  r  /attachment; filename="fortuneteller_report.csv"r  )zFortuneTeller IdzFortuneTeller NamezFortuneTeller EmailzFortuneTeller ImagezFortuneTeller Created DatezFortuneTeller StatuszAppointments Recivedr   rP  rZ  r[  s         r/   r:   zExportFortuneCsvReport.get
	  s@   !!
F <=XYp  rI  Jf  g  @Hk 2H3H[	  z2($U( !::h&//  w  x d	??D-.5Q0RUX0X[_`{[|0|  C  D[  \  ^b  cz  ^{  }A  B^  }_  ae  f~  a  AE  FZ  A[  \  ]  
/r1   Nr\  rb   r1   r/   rr  rr  		  r]  r1   rr  c                       e Zd ZdZd Zy)AllTranscationsReportszall_transcation_report.htmlc                    t         j                  j                  |j                  j                        j                         }t        j                  j                         j                  d      }t        |d      }|j                  j                  d      }|j                  |      }t        || j                  t                     S )Nr   r   r   r   )rm   r&   r;   rF   r   r<   r%   r'   r   r   r9   r:   r   r   rQ   r   )rS   r=   rz   r9  r   r   r  s          r/   r:   zAllTranscationsReports.get	  s      ''W\\__'=CCE) ((,,.77>("%)'+"";/+	**68	44r1   Nrc  rb   r1   r/   rv  rv  	  s    .5r1   rv  c                       e Zd Zd Zy)ExportTranscationReportCSVc           
         t         j                  j                  |j                  j                        j                         }t        j                  j                         j                  d      }t        d      }d|d<   t        j                  |      }|j                  g d       |D ]  }|j                  j                  dk(  rd	}nd
}|j                  |j                  |j                   j"                  dz   |j                   j$                  z   |j                   j&                  |j(                  |j*                  |j,                  |g        |S )Nr   r   r  r  rt  r  )zTranscation IdUsernamerY  zPayment ModeDateAmountStatusr   rp  r   r   )rm   r&   r;   rF   r   r<   r%   r'   r   r   r  r  r  rs  is_paidr)   r  r  r  r3   rt  r  r   )rS   r=   rz   r9  r  r  r  r    s           r/   r:   zExportTranscationReportCSV.get)	  s6     ''W\\__'=CCE) ((,,.77>(z2($U( !::h&//hi d
llaFF	??D'')B)BS)H4>>KcKc)ceieseseyey{  |M  |M  OS  O^  O^  `d  `k  `k  ms  t  u  
/r1   Nr\  rb   r1   r/   ry  ry  (	  r]  r1   ry  c                       e Zd Zd Zy)GetCountriesc                 :   	 t         j                  j                  d      j                  d      }t	        |d      j
                  }t        d|d      S # t        $ r;}t        |       t        dt        |      it        j                        cY d }~S d }~ww xY w)	NTr   country_namemanySuccessr@   datar@   r   )	Countriesr&   r;   r   CountrySerializerr  r   r   r\   r+   r    HTTP_500_INTERNAL_SERVER_ERROR)rS   r=   country_objall_datar   s        r/   r:   zGetCountries.getp	  s    T""))D)AJJ>Z;6;;8
ix8
99	 T8
Ic!f%V-R-R
SSTs   AA 	B0BBBNr\  rb   r1   r/   r  r  o	  s    Tr1   r  c                       e Zd Zd Zy)	GetStatesc                    	 |j                   }|j                  d      }|st        ddit        j                        S t
        j                  j                  |d      j                  d      }t        |d      j                  }t        d	|d
      S # t        $ r;}t        |       t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r@   id is requiredr   T)countryr   
state_namer  r  r  )query_paramsr:   r   r    HTTP_400_BAD_REQUESTStater&   r;   r   StateSerializerr  r   r\   r+   r  )rS   r=   r  
country_id	state_objr  r   s          r/   r:   zGetStates.getz	  s    
T4:
Y/08S8STT}}##J#NWWXde9iT2778
ix8
99	 T8
Ic!f%V-R-R
SST#   ;B AB 	C0CCCNr\  rb   r1   r/   r  r  y	      Tr1   r  c                       e Zd Zd Zy)	GetCitiesc                    	 |j                   }|j                  d      }|st        ddit        j                        S t
        j                  j                  |d      j                  d      }t        |d      j                  }t        d	|d
      S # t        $ r;}t        |       t        dt        |      it        j                        cY d }~S d }~ww xY w)Nr   r@   r  r   T)stater   	city_namer  r  r  )r  r:   r   r    r  Cityr&   r;   r   CitySerializerr  r   r\   r+   r  )rS   r=   r  state_idcity_objr  r   s          r/   r:   zGetCities.get	  s    
T4hhtn8
Y/08S8STTll!!4!HQQR]^8X40558
ix8
99	 T8
Ic!f%V-R-R
SSTr  Nr\  rb   r1   r/   r  r  	  r  r1   r  c                 6   t        j                  |       }t        j                  j	                  d      \  }}|j                         D ]N  \  }}t        j                  j                  ||      }|D ]#  }t        j                  j                  ||       % P y )NUSA)r  )r  r  )r  r  )	r  r  r  r&   get_or_createitemsr  rJ  r  )	json_datar  r  _r  citiesr  r  s           r/   "create_states_and_cities_from_jsonr  	  s|    

9--5-A!::<Z
--

w:

F%i<<Ui8 	 (r1   c                 \   | j                   dk(  rB	 d}t        |d      5 }|j                         }d d d        t               t	        ddid      S t	        ddid      S # 1 sw Y   2xY w# t
        $ r t	        dd	id
      cY S t        j                  $ r t	        ddid      cY S w xY w)Nr9   zUS_States_and_Cities.jsonrr@   z(States and cities imported successfully.   r   r   zJSON file not found.i  zInvalid JSON data in the file.i  zOnly POST requests are allowed.i  )r  openr  r  r   FileNotFoundErrorr  JSONDecodeError)r=   json_file_pathfiler  s       r/   import_states_citiesr  	  s    NNe
P/>^S!T		I 	"%i0
	#MNWZ
[[ 
w AB3	OO 	"! 
 F
!78
EE			 P
!AB3
OOPs-   A- A!!A- !A*&A- -B+!B+*B+)django.shortcutsr   django.views.genericr   django.views.generic.baser   r   r   django.contrib.authr   r	   r
   django.contribr   rC   r   django.contrib.auth.modelsr   django.httpr   django.corer   mathrp   rr   django.confr   django.template.loaderr   modelsseer_user.modelsfortune_teller.modelsdjango.db.modelsr   r   django.core.paginatorr   r  	functionsr   r  django.contrib.auth.decoratorsr   django.utils.decoratorsr   r	  django.utils.timezoner   r   calendarpyfcmr   rest_framework.viewsr   rest_framework.responser   rest_frameworkr    serializersr  r0   rA   rG   rK   rM   rd   r   r   r   r   r   r  r!  r#  r'  r,  r/  r3  r5  r=  rL  rR  rV  r]  rf  rm  rp  ru  r}  r  r  r  r  r  r  r  r  r  r  r*  r3  r5  rA  rE  rG  rT  rZ  r`  rj  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r,  r1  r6  r=  rB  rF  rW  r_  re  ro  rr  rv  ry  r  r  r  r  r  rb   r1   r/   <module>r     s(   # - * ; ; : : #  + $      3   # $ + 
    9 4 
 
 ,    ! ( , !  
*3 30>, >4$> $>N5 58 |  4&| &$5| 5 -| -(   6	5 	5& &$- -( ,  (   * ,  ,&, &( ,  &   , ,  0&, &$   & |  ,   0& &&5< 585\ 55< 55\ 5A , A J" l " JYvO L O d"  " Jmb5  5 n L  .yz <  D
  
    65l 5:0( 0(l0,    2C C8 l  (5l 5ABl ABF5L 5"F< F4 GL  GD 5| 5"Al A4%B| %BR 5\ 54	*4 	*	5 	5)\ )"*l *," "5, 5:$ (5\ 5 5< 585| 5 T (5\ 5 $ nf ,T7 TT TT T"9Pr1   