
    
Ugx                     	   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
 d dlmZ ddlT 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mZ d dlmZ d dlm Z  d dl!Z!d dlm"Z" ddl#m$Z$ d dl%m&Z& ddl'T d dl(m)Z) d dl*m+Z+ d dl,Z,d dl-T d dl(T d dl.m/Z/ d dl*m0Z0 d dl1Z1d dl!m!Z! d dl2m3Z3 d Z4d Z5d Z6 G d de          Z7 G d  d!e          Z8 G d" d#e          Z9 G d$ d%e          Z: G d& d'e          Z;d dl.m/Z/ d dl*m0Z0 d dl1Z1 G d( d)e          Z< G d* d+e          Z= G d, d-e          Z> G d. d/e          Z? G d0 d1e          Z@ G d2 d3e          ZA G d4 d5e          ZB G d6 d7e          ZC G d8 d9e          ZD G d: d;e          ZE G d< d=e          ZF G d> d?e          ZG G d@ dAe          ZH G dB dCe          ZI G dD dEe          ZJ G dF dGe          ZK G dH dIe          ZL G dJ dKe          ZM G dL dMe          ZN G dN dOe          ZO G dP dQe          ZP G dR dSe          ZQ G dT dUe          ZR G dV dWe          ZS G dX dYe          ZT G dZ d[e          ZU G d\ d]e          ZV G d^ d_e          ZW G d` dae          ZX G db dce          ZY G dd dee          ZZ G df dge          Z[ G dh die          Z\ G dj dke          Z] G dl dme          Z^ G dn doe          Z_ G dp dqe          Z` G dr dse          Za G dt due          Zb G dv dwe          Zc G dx dye          Zd G dz d{e          Ze G d| d}e          Zf G d~ de          Zg G d de          Zh G d de          Zi G d de          Zj G d de          Zk G d de          Zl G d de          Zm G d de          Zn G d de          Zo G d de          Zp G d de          Zq G d de          Zr G d de          Zs G d de          Zt G d de          Zu G d de          Zv G d de          Zw G d de          Zx G d de          Zy G d de          Zz G d de          Z{ G d de          Z| G d de          Z} G d de          Z~ G d de          Z G d de          ZdS )    )render)View)TemplateView)authenticateloginlogout)r   redirect)HttpResponse   )*)messages)mail)render_to_stringN)settings)	Paginator)JsonResponse)login_required)method_decorator)HttpResponseRedirect)forms)User)AppUser)Q)
TruncMonth)Count)datetime)
strip_tagsc                     | j                             d          }t          j                            |                                          }|rt          d          S d}t          |d          S )Nemailusernametruez)This email does not exist in our databaseFsafe)GETgetr   objectsfilterfirstr
   r   )requesttextpostmessages       7/var/www/html/Alfredo_demo/alfredo/admin_panel/views.py
checkEmailr/   #   sg      T**0022 *	v		7'	g5	)	)	))    c                 "   | j                             dd          }| j                             d          }t          j                            |          }|                    |          dk    rd}t          |d          S t          d          S )	Nr    passwordr    Fz<<p style="color: red;">Please enter the correct password</p>r#   r"   )r%   r&   r   r'   check_passwordr   r
   )r*   r+   r3   userr-   s        r.   checkLoginPasswordr6   ,   s    ##KOOJ''  $ //!!U**J'	g5	)	)	))	v		r0   c                     | j                             d          }t          j                            | j        j                  }|                    |          dk    rd}t          |d          S t          d          S )Nold_passwordr   Fz%Does not match with the old password.r#   r"   )	r%   r&   r   r'   r5   r   r4   r   r
   )r*   r8   r5   r-   s       r.   adminCheckPasswordr:   7   sq    //  w|'9 ::%%..3'	g5	)	)	))	v		r0   c                       e Zd ZdZd Zd ZdS )
AdminLogInzadmin-signin.htmlc                 ,    t          || j                  S Nr   template_nameselfr*   s     r.   r&   zAdminLogIn.getD       	*	+	++r0   c                    t          j        |j                  }|                                r|j                            d          }|j                            d          }t          ||          }|rCt          d           t          ||           t          j
        |d           t          d          S t          j
        |d           t          || j                  S t          |dd	|i          S )
Nr   r3   )r!   r3   yeszLogin successfullyz/admin-dashboardzInvalid email and password.r   form)r   adminLoginFormPOSTis_validcleaned_datar&   r   printr   r   successr	   r   r@   )rB   r*   rF   r   r3   r5   s         r.   r,   zAdminLogIn.postF   s    		gl	+	+$	]]__ 3##G,,5##J//8

9
9
94
 /
5\\\
7Dg3444'((( W;<<<'4-...
'FD>
2
22r0   N__name__
__module____qualname__r@   r&   r,    r0   r.   r<   r<   B   s7        $, , ,3 3 3 3 3r0   r<   c                       e Zd ZdZd Zd ZdS )AdminForgetPasswordzforgot-password.htmlc                 ,    t          || j                  S r>   r?   rA   s     r.   r&   zAdminForgetPassword.get[   rC   r0   c                    t          j        |j                  }|                                r.|j                            d          }t          j                            |          	                                }d
                    d t          d          D                       }dt          |j                  z   dz   |z   }t          t          j                  |z   }||_        |                                 d}t%          d	d
|i          }	|	}
t          j        }|}t)          j        ||
||g|	           t-          j        |d           t1          d          S t3          || j        d|i          S )Nr   r9   r2   c                 d    g | ]-}t          j        t          j        t          j        z             .S rQ   )randomchoicestringascii_lettersdigits).0ns     r.   
<listcomp>z,AdminForgetPassword.post.<locals>.<listcomp>c   s,    ]]]afmF$86=$HII]]]r0      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-passwordrF   )r   adminforgetpasswordrH   rI   rJ   r&   
SuperAdminr'   r(   r)   joinrangestrr   r   BASE_URLforgotPasswordLinksaver   EMAIL_HOST_USERr   	send_mailr   rL   r	   r   r@   )rB   r*   rF   r   	admin_objran_numbaselinkcompletelinksubjectrb   plain_message
from_emailtos                r.   r,   zAdminForgetPassword.post^   sZ   		"7<	0	0$	]]__ >!!'**5!(((77==??9WW]]SXY[S\S\]]]^^7#io"6"66<wF8h'((83<"*9>>7"#EP\G]^^<=(:2>'=*rdVVVVGNOOO
+
,
,,
$,vtn
=
==r0   NrM   rQ   r0   r.   rS   rS   Y   s7        ', , ,> > > > >r0   rS   c                       e Zd ZdZd Zd ZdS )ForgetPasswordVerificationzreset-password.htmlc                    t          | j        j                  }|                    d          d         }t          j                            |                                          }|j        dk    rt          |d          S t          j                            ||                                          }|rd}nd}t          || j
        t                                S )	Nr`   r9   
LinkExpiryzlink-expire.html)r   ri   TF)rg   r*   pathsplitrd   r'   r(   r)   ri   r   r@   locals)rB   r*   ra   
user_emaillink_expiryrm   valids          r.   r&   zForgetPasswordVerification.getu   s    	T\		$zz#r"*"))*)==CCEE+#|33
+
,
,, ''
QU'VV\\^^) 555	*688	4	44r0   c                 v   t          j        |j                  }|                                rt|j                            d          }|j                            d          }t          | j        j                  }|	                    d          d         }t          d|           t          j                            |                                          }t          j                            |j        j                                                  }|rh|                    |           |                                 d|_        |                                 t+          j        |d	           t/          d          S t+          j        |d
           t/          d          S t3          || j        d|i          S )Nnew_passwordconfirm_new_passwordr`   r}   r9   idry   zPassword changed successfullySomething went wrongrF   )r   forgetverificationrH   rI   rJ   r&   rg   r*   rz   r{   rK   rd   r'   r(   r)   r   r5   r   set_passwordrj   ri   r   rL   r	   errorr   r@   )	rB   r*   rF   r   r   ra   r}   rm   user_objs	            r.   r,   zForgetPasswordVerification.post   so   		!',	/	/$	]]__ >#''77<+//0FGG
dl
 
 4

3#:j!!!!(((<<BBDD9l!!Y^%6!77==??8 	,'''MMOOO#/I NNW=>>>C==N72333C==
$,vtn
=
==r0   NrM   rQ   r0   r.   rv   rv   s   s7        &5 5 5> > > > >r0   rv   c                   J    e Zd Z e ed                    d             ZdS )AdminLogoutr`   	login_urlc                 h    t          |           t          j        |d           t          d          S )NzLogout Succesfullyr`   )r   r   rL   r	   rA   s     r.   r&   zAdminLogout.get   s-    ///
70111	#r0   NrN   rO   rP   r   r   r&   rQ   r0   r.   r   r      sF        >>C00011  21  r0   r   c                       e Zd ZdZd Zd ZdS )AdminResetPasswordadmin_reset_password.htmlc                     t           j                            |j        j                                                  }t          || j        t                                S Nr5   	rd   r'   r(   r5   r   r)   r   r@   r|   rB   r*   rm   s      r.   r&   zAdminResetPassword.get   sD     ''W\_'==CCEE)	*688	4	44r0   c                 :   	 t          j        |j                  }|                                r|j                            d          }t
          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confirmPasswordr9   z)You have successfully reset your passwordr`   r   rF   &Something went wrong.Please try again.admin-dashboard)r   change_password_formrH   rI   r&   r   r'   r5   r   r   rj   r   r   infor	   r   	Exceptionwarning)rB   r*   rF   r3   r5   es         r.   r,   zAdminResetPassword.post   s   &

$W\
2
24
mmoo 	H| 122H|gl&899DhIIKKK
7OOOM'FGGGC=='6GGG	 & & &GEFFF
$
%
%%%%%%%&s$   CC" C" "
D,#DDDNrM   rQ   r0   r.   r   r      s7        ,5 5 5& & & & &r0   r   c                   N    e Zd ZdZ e ed                    d             ZdS )AdminDashboardzdashboard.htmlr`   r   c                 	   t           j                            |j        j                                                  }t          j                            d                                          }t          j                            d                                          }t          j                            d                                          }t          j                            d          
                    d          d d         }t          j                            d          
                    d          d d         }t          j                            d          }t          j                            d                              t          d                                        d	                              t          d
                    
                    d	          }	d |	D             d |	D             d}
t          j        |
          }t          j                            d                              t          d                                        d	                              t          d
                    
                    d	          }d |D             d |D             d}t          j        |          }t          j                            d                              d                              d                              t          d
                    }t          j        d |D                       }t          j                            dd                                          }t          j                            dd                                          }t$          j                            d                              t          d
                    
                                }d |D             }d |D             }t          j        |          }t          j        |          }t'          ||           t)          || j        t-                                S )Nr   Tend_date__isnull-id   status
created_atmonthr   r   countc                 D    g | ]}|d                               d          S r   z%Y-%mstrftimer\   entrys     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s*    IIIEuW~&&w//IIIr0   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s    777%uW~777r0   )monthscountsc                 D    g | ]}|d                               d          S r   r   r   s     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s*    JJJEuW~&&w//JJJr0   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s    888%uW~888r0   gender__isnullr2   gender__exactgenderc                 0    g | ]}|d          |d         dS r   r   )nameyrQ   r   s     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s)    gggPUeHoE'NKKgggr0   r   is_profile_completedFexercise__exercise__namec                     g | ]
}|d          S r   rQ   r\   xs     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s    KKKaA01KKKr0   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z&AdminDashboard.get.<locals>.<listcomp>   s    999AQwZ999r0   )rd   r'   r(   r5   r   r)   r   r   TrainerAdminExerciseorder_byannotater   valuesr   jsondumpsexclude
AssesmentsrK   r   r@   r|   )rB   r*   rm   total_clientstotal_trainerstotal_exerciseclient_listingtrainers_listingtrainer_objclient_dataformatted_data_clientsformatted_data_jsontrainer_dataformatted_data_tranierformatted_data_json_trainergender_countsgender_datalogin_userssignup_usersexercise_countsexercise_nameexercise_countexercise_names_jsonexercise_counts_jsons                           r.   r&   zAdminDashboard.get   s&    !((glo(>>DDFF9?))T)BBHHJJ=O**d*CCIIKK>!)00D0IIOOQQ>O**d*CCLLUSSTVUVTVW>o,,,EENNuUUVXWXVXY?))T)CC;''t'44==J|D\D\=]]ddelmmvv  ~C  DH  ~I  ~Iv  J  J  S  S  T[  \  \;II[III77;777  $:;; /(((55>>ZP\E]E]>^^eefmnnww  D  EI  J  Jw  K  K  T  T  U\  ]  ]<JJ\JJJ88<888  "&,B!C!C OWDW!!W2WVHXE$KKX    ggYfggghh;%%SW%XX^^``;&&$TY&ZZ``bb<'../IJJSSZ_`dZeZeSffooqq?KK?KKK=99999>M22*^44~&&&
+FHH
5
55r0   NrN   rO   rP   r@   r   r   r&   rQ   r0   r.   r   r      sK        "-NNS11122,6 ,6 32,6 ,6 ,6r0   r   c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AdminProfilezadmin_profile.htmlr`   r   c                 6   	 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   )rd   r'   r(   r5   r   r)   r   r@   r|   r   r   r   r	   )rB   r*   rm   r   s       r.   r&   zAdminProfile.get   s    &!((glo(>>DDFF9
+FHH
5
55	 & & &GEFFF
$
%
%%%%%%%&s   AA   
B*#BBBc                    	 t          j        |j                  }|                                ry|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }t          j                            |j	        j
                                      |||||           |j                            d          rwt          |j                            d                    }d	|z   }t          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)N
first_name	last_namer   phone_numberaddressr   )	firstNamelastNamer   phoneNumberr   avatarr`   imageUpdate Succesfullyzadmin-profiler   r   )r   adminprofile_formrH   rI   rJ   r&   rd   r'   r(   r5   r   updateFILESuploadTheImagesrg   r   rL   r	   r   r@   r   r   )
rB   r*   rF   r   r   r   r   r   fileUrlr   s
             r.   r,   zAdminProfile.post   s   &

!',
/
/4
mmoo ."&&|44J!%%k22I!!'**E$((88L##I..G7<?33::ZYbin  |H  QX:  Y  Y  Y}"" PW]..x8899W[WGLO44;;#g,,;OOOW2333O$$$'$,---	 & & &GEFFF
$
%
%%%%%%%&s$   F&F> )F> >
G6#G1+G61G6NrN   rO   rP   r@   r   r   r&   r,   rQ   r0   r.   r   r      sZ        %>>C00011& & 21&& & & & &r0   r   c                   N    e Zd ZdZ e ed                    d             ZdS )TrainerListztrainer_list.htmlr`   r   c                 d   	 t           j                            |j        j                                                  }t          t          j                  }t          j                            d          
                    d          }|j                            d          }|j                            d          }t          d|           |j                            d          }t          d|           d}t                      }	|rSt          j                            t          |	          t          |
          z  d          
                    d          }|r8|r6t          j                            ||gd          
                    d          }|r6|s4t          j                            |d          
                    d          }|r6|s4t          j                            |d          
                    d          }t          |d          }
|j                            d          }|
                    |          }t#          || j        t'                                S # t(          $ r=}t          |           t+          j        |d           t/          d          cY d }~S d }~ww xY wNr   Tr   r   search
start_fromstart_toz11:59:59)full_name__icontains)email__icontainscreated_at__date__ranger   created_at__dater   
   pager   r   )rd   r'   r(   r5   r   r)   rg   r   rh   r   r   r%   r&   rK   r   r   get_pager   r@   r|   r   r   r   r	   )rB   r*   rm   base_urlr   search_postr  r  timelookups	paginatorpage_numberr   r   s                 r.   r&   zTrainerList.get  s    &!((glo(>>DDFF9(#$$8o$$$==FFuMM8**;--:j!!!kooj))8H 4SS7 Q_##A;$G$G$G[fHgHgHg$g{#  A  A  J  J  KP  Q  QH {X {_##Z<Qei#jjsstyzzH i i_##ZSW#XXaabghhH gz g_##XQU#VV__`effH2&&9((;$$[11<
+FHH
5
55	 & & &888GEFFF
$
%
%%%%%%%&s   I%I( (
J/22J*$J/*J/Nr   rQ   r0   r.   r  r    sK        $>>C00011!& !& 21!& !& !&r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )ViewTrainerzview_trainer.htmlr`   r   c           
         t           j                            |j        j                                                  }t          j                            |d                                          }t          j                            |d          }g }|D ]V}t          j                            |d          	                    dddd	d
dd          }|D ]}	|
                    |	           Wt          || j        t                                S )Nr   Tr   r   )trainerr   )
assessmentend_date__date__isnullstudent__app_user__imagestudent__app_user__full_nameassessment__exercise__nameassessment__repetitionsassessment__setsstudent__statusassessment__exercise__images)rd   r'   r(   r5   r   r)   r   r   StudentAssessmentr   appendr   r@   r|   )
rB   r*   r   rm   r   assessment_data
total_datar  student_assessmentdatas
             r.   r&   zViewTrainer.get:  s    ''W\_'==CCEE)&&"d&CCIIKK+$++KQU+VV/*#  j'/66*dh6iipp  rL  Mk  lH&'9:KLjl l "  tt 
*688	4	44r0   Nr   rQ   r0   r.   r  r  8  sK        $>>C000115 5 215 5 5r0   r  c                   J    e Zd Z e ed                    d             ZdS )DeleteTrainerr`   r   c                    t           j                            |j        j                                                  }t          j                            |          }|rBt          j	                    |_
        |                                 t          j        |d           nt          j        |d           t          d          S )Nr   r   zTrainer Deleted Successfullyr   z/trainer-listing)rd   r'   r(   r5   r   r)   r   r&   r   nowend_daterj   r   rL   r   r	   rB   r*   r   rm   r  s        r.   r&   zDeleteTrainer.getO  s      ''W\_'==CCEE)
/



$
$' 3LNN7
<<>>>G;<<<<>'1222	$	%	%%r0   Nr   rQ   r0   r.   r+  r+  N  F        >>C00011& & 21& & &r0   r+  c                       e Zd ZdZdS )
AddTrainerzadd_trainer.htmlNrN   rO   rP   r@   rQ   r0   r.   r2  r2  _          #r0   r2  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditTrainerzedit_trainer.htmlr`   r   c                 $   t           j                            |j        j                                                  }t          j                            |d                                          }t          || j        t                                S Nr   Tr  )
rd   r'   r(   r5   r   r)   r   r   r@   r|   )rB   r*   r   rm   r   s        r.   r&   zEditTrainer.getd  sl      ''W\_'==CCEE)&&"d&CCIIKK+	*688	4	44r0   c                    	 t          j        |j                  }|                                r|j                            d          }|j                            d          }t          j                            |          	                    ||           |j
                            d          r`t          |j
                            d                    }d|z   }t          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   	full_namer   )r   r;  r   r`   r   r   ztrainer-listingr   r   )r   EditTrainerFormrH   rI   rJ   r&   r   r'   r(   r   r   r   r   rL   r	   r   r@   r   r   rB   r*   r   rF   r   r;  r   r   s           r.   r,   zEditTrainer.postl  sp   &


-
-4
mmoo .!!'**E!%%k22IOb!!((uy(III}!! ;W]..w7788W[W_r""))'):::W2333%&&&'$,---	 & & &GEFFF
$
%
%%%%%%%&$   D4E 7E 
F#E?9F?FNr   rQ   r0   r.   r6  r6  b  sZ        $>>C000115 5 215& & & & &r0   r6  c                   J    e Zd Z e ed                    d             ZdS )changeTrainerStatusr`   r   c                 "   	 t           j                            |j        d                   }|j        d         |_        |                                 |j        dk    r<t          j        |d           t          |j	                            d                    S t          j
        |d           t          |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Trainer status is activatedHTTP_REFERERzTrainer status is deactivatedr   r   )r   r'   r&   rH   r   rj   r   rL   r
   METAr   r   r   r	   rB   r*   pubr   s       r.   r,   zchangeTrainerStatus.post  s   &##i)@#AA3X&3:88:::	jCW;<<<((88999N7;<<<((88999	 & & &GEFFF
$
%
%%%%%%%&$   BC ;C 
D #D	D	DNrN   rO   rP   r   r   r,   rQ   r0   r.   r@  r@    sF        >>C00011& & 21& & &r0   r@  c                   N    e Zd ZdZ e ed                    d             ZdS )
ClientListzclient_list.htmlr`   r   c                 F   	 t           j                            |j        j                                                  }t          t          j                  }t          j                            d          
                    d          }|j                            d          }|j                            d          }|j                            d          }d}t                      }	|rs|	                    t          |	          t          |
          z  t          j                   t          j                            |	d          
                    d          }|r8|r6t          j                            ||gd          
                    d          }|r6|s4t          j                            |d          
                    d          }|r6|s4t          j                            |d          
                    d          }t!          |d          }
|j                            d          }|
                    |          }t%          || j        t)                                S # t*          $ r.}t-          j        |d           t1          d          cY d }~S d }~ww xY wr  )rd   r'   r(   r5   r   r)   rg   r   rh   r   r   r%   r&   r   addANDr   r  r   r@   r|   r   r   r   r	   )rB   r*   rm   r  r   r  r  r  r  r  r  r  	user_datar   s                 r.   r&   zClientList.get  sg   &!((glo(>>DDFF9(#$$8o$$$==FFuMM8**;--:kooj))8
4SS7 WKK{333A{4S4S4SSUVUZ[[[%%g%FFOOPUVVH }X }%%z(>Sgk%lluuv{||h j jo$$jTX$YYbbchiiX hz ho$$hRV$WW``afggX2&&9((;!!+..9
+FHH
5
55	 & & &GEFFF
$
%
%%%%%%%&s   I%I( (
J 2#JJ J Nr   rQ   r0   r.   rK  rK    sK        #>>C00011& & 21& & &r0   rK  c                   N    e Zd ZdZ e ed                    d             ZdS )
ViewClientzview_client.htmlr`   r   c                    t           j                            |j        j                                                  }t          j                            |d                                          }t          j                            |d                                          }t          |           t          j                            |          
                    d                              t          d                                                    }d	 |D             }d
 |D             }t          j        |          }	t          j        |          }
t          ||           t!          || j        t%                                S )Nr   Tr  )app_userr   )student$assessment__exercise__exercise__namer   r   c                     g | ]
}|d          S )rU  rQ   r   s     r.   r^   z"ViewClient.get.<locals>.<listcomp>  s    VVV1;<VVVr0   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z"ViewClient.get.<locals>.<listcomp>  s    8881AgJ888r0   )rd   r'   r(   r5   r   r)   r   StudentsrK   r$  r   r   r   r   r   r   r   r@   r|   )rB   r*   r   rm   r   rT  r   r   r   r   r   s              r.   r&   zViewClient.get  sc    ''W\_'==CCEE)_##r4#@@FFHH(


!
!8T
!
J
J
P
P
R
R'...%-44W4EELLMstt}}  EJ  KO  EP  EP}  Q  Q  Z  Z  \  \/VVoVVV-88888.
=11N33n%%%	*688	4	44r0   Nr   rQ   r0   r.   rQ  rQ    sK        #>>C000115 5 215 5 5r0   rQ  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )
EditClientzedit_client.htmlr`   r   c                 $   t           j                            |j        j                                                  }t          j                            |d                                          }t          || j        t                                S r8  )
rd   r'   r(   r5   r   r)   r   r   r@   r|   )rB   r*   r   rm   r   s        r.   r&   zEditClient.get  sl      ''W\_'==CCEE)_##r4#@@FFHH(	*688	4	44r0   c                    	 t          j        |j                  }|                                r|j                            d          }|j                            d          }t          j                            |          	                    ||           |j
                            d          r`t          |j
                            d                    }d|z   }t          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r:  )r   EditClientFormrH   rI   rJ   r&   r   r'   r(   r   r   r   r   rL   r	   r   r@   r   r   r=  s           r.   r,   zEditClient.post  sp   &

w|
,
,4
mmoo .!!'**E!%%k22IOb!!((uy(III}!! ;W]..w7788W[W_r""))'):::W2333%&&&'$,---	 & & &GEFFF
$
%
%%%%%%%&r>  Nr   rQ   r0   r.   rZ  rZ    sZ        #>>C000115 5 215
& & & & &r0   rZ  c                   J    e Zd Z e ed                    d             ZdS )changeClientStatusr`   r   c                 "   	 t           j                            |j        d                   }|j        d         |_        |                                 |j        dk    r<t          j        |d           t          |j	                            d                    S t          j
        |d           t          |j	                            d                    S # t          $ r.}t          j        |d           t          d	          cY d }~S d }~ww xY w)
NrB  r   r   rC  zAppUser status is activatedrD  zAppUser status is deactivatedr   r   )r   r'   r&   rH   r   rj   r   rL   r
   rE  r   r   r   r	   rF  s       r.   r,   zchangeClientStatus.post  s   &##i)@#AA3X&3:88:::	jCW;<<<((88999N7;<<<((88999	 & & &GEFFF
$
%
%%%%%%%&rH  NrI  rQ   r0   r.   r_  r_    F        >>C00011& & 21& & &r0   r_  c                   J    e Zd Z e ed                    d             ZdS )DeleteClientr`   r   c                    t           j                            |j        j                                                  }t          j                            |          }|rBt          j	                    |_
        |                                 t          j        |d           nt          j        |d           t          d          S )Nr   r   zClient Deleted Successfullyr   z/client-listing)rd   r'   r(   r5   r   r)   r   r&   r   r-  r.  rj   r   rL   r   r	   )rB   r*   r   rm   rS  s        r.   r&   zDeleteClient.get  s      ''W\_'==CCEE)?"%%( 3\^^8==???G:;;;;>'1222	#	$	$$r0   Nr   rQ   r0   r.   rc  rc    sF        >>C00011	% 	% 21	% 	% 	%r0   rc  c                   N    e Zd ZdZ e ed                    d             ZdS )ExerciseListzexercise_list.htmlr`   r   c                    	 t           j                            |j        j                                                  }t          j                            d                              d          }|j        	                    d          }|rBt          j                            t          |          d                              d          }t          |d          }|j        	                    d          }|                    |          }t          || j        t                                S # t           $ r=}t#          |           t%          j        |d	           t)          d
          cY d }~S d }~ww xY w)Nr   Tr   r   r  )name__icontainsr  r  r   r   )rd   r'   r(   r5   r   r)   r   r   r%   r&   r   r   r  r   r@   r|   r   rK   r   r   r	   )	rB   r*   rm   data_objr  r  r  exercise_objr   s	            r.   r&   zExerciseList.get  sS   &!((glo(>>DDFF9#**d*CCLLUSS8**; t$++Ak,J,J,J^b+ccllmrssH2&&9((;$$[11<
+FHH
5
55	 & & &888GEFFF
$
%
%%%%%%%&s   D-D0 0
E7:2E2,E72E7Nr   rQ   r0   r.   rf  rf     sK        %>>C00011& & 21& & &r0   rf  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AddExercisezadd_exercise.htmlr`   r   c                     t           j                            |j        j                                                  }t          j                                        }t          || j	        t                                S r   )rd   r'   r(   r5   r   r)   FitnessLevelallr   r@   r|   )rB   r*   rm   fitness_levels       r.   r&   zAddExercise.get  sZ      ''W\_'==CCEE)&**,,-	*688	4	44r0   c                    	 t          j        |j                  }|                                rB|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          r,t          |j                            d                    }d|z   }t          j	        
                    |                                          }t          j	                            ||t          |          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)Nrp  dayr   descriptionr   r`   r   )exercise_levelr   rs  r   rr  Created Succesfullyexercise-listingr   r   )r   addExerciseformrH   rI   rJ   r&   r   r   rn  r'   r(   r)   r   creater   rg   r   rL   r	   r   r@   r   r   )
rB   r*   rF   
fitness_idrr  r   rs  r   fitness_objr   s
             r.   r,   zAddExercise.post  s   &


-
-4
mmoo ."&&77J




&
&C  ((D#''66K}"" W]..x8899W[W&---<<BBDDK  R\]hRiRipst{p|p|  DG   H  H  HW3444&''''$,---	 & & &GEFFF
$
%
%%%%%%%&s$   E/F 2F 
F?#F:4F?:F?Nr   rQ   r0   r.   rl  rl    sZ        $>>C000115 5 215
& & & & &r0   rl  c                   N    e Zd ZdZ e ed                    d             ZdS )ExerciseViewzview_exercise.htmlr`   r   c                    t           j                            |j        j                                                  }t          j                            |d                                          }t          j                            |          }t          j                            |                                          }t          t          j                  }t          || j        t                                S )Nr   Tr  )exercise)rd   r'   r(   r5   r   r)   r   AdminSubExerciser   rg   r   rh   r   r@   r|   )rB   r*   r   rm   rj  sub_exercise_objtotal_sub_exerciser  s           r.   r&   zExerciseView.get5  s     ''W\_'==CCEE)&--T-JJPPRR,%-44l4KK'/666MMSSUU"##(	*688	4	44r0   Nr   rQ   r0   r.   r|  r|  3  sK        %>>C000115 5 215 5 5r0   r|  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditExercisezedit_exercise.htmlr`   r   c                 `   t           j                            |j        j                                                  }t          j                            |d                                          }t          j                                        }t          || j
        t                                S r8  )rd   r'   r(   r5   r   r)   r   rn  ro  r   r@   r|   )rB   r*   r   rm   rj  rp  s         r.   r&   zEditExercise.get@  s     ''W\_'==CCEE)&--T-JJPPRR,&**,,-	*688	4	44r0   c                    	 t          d           t          j        |j                  }|                                rt          d           |j                            d          }|j                            d          }|j                            d          }|j                            d          }t          j        	                    |          
                                }t          j        	                    |                              ||t          |          |          }	|j                            d	          r|t          d
           t          |j                            d	                    }
d|
z   }
t          j        	                    |                              t!          |
                    }	t#          j        |d           t'          d          S t          d           t          |j                   t+          || j                  S # t.          $ r.}t#          j        |d           t'          d          cY d }~S d }~ww xY w)Nin posthererp  r   rs  rr  r   )rt  r   rs  rr  r   z	in avatarr`   r   Updated Successfullyrv  in elser   r   )rK   r   rw  rH   rI   rJ   r&   rn  r'   r(   r)   r   r   r   r   r   rg   r   rL   r	   errorsr   r@   r   r   )rB   r*   r   rF   ry  r   rs  rr  rz  rj  r   r   s               r.   r,   zEditExercise.postG  s5   &


-
-4
mmoo .	&MMM"&&77J  ((D#''66K




&
&C&---<<BBDDK (//2/66==[^boy  {F  pG  pG  LO=  P  PL}"" S
;w}00::;;W7{W!)00B077>>S\\>RR\W4555&''' 
)	$+'$,---	 & & &GEFFF
$
%
%%%%%%%&s$   G#H &7H 
I(#IIINr   rQ   r0   r.   r  r  >  sZ        %>>C000115 5 215& & & & &r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AddSubExercisezadd_sub_exercise.htmlr`   r   c                 "   t           j                            |                                          }t          j                            |j        j                                                  }t          || j        t                                S Nr   r   )
r   r'   r(   r)   rd   r5   r   r   r@   r|   rB   r*   r   rj  rm   s        r.   r&   zAddSubExercise.getg  sk     &---44::<<, ''W\_'==CCEE)	*688	4	44r0   c                     	 t          j        |j                  }|                                r|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }	|j                            d          }
|j                            d          }|j                            d	          }t          j                            |
          	                                }g }g }|j
                            d          rH|j
                            d          }|D ]+}t          |          }d|z   }|                    |           ,|j
                            d	          rH|j
                            d	          }|D ]+}t          |          }d|z   }|                    |           ,d }|j
                            d          r,t          |j
                            d                    }d|z   }t          j                            |||||||	|
||||           t!          j        |d           t%          dt'          |j                  z             S t+          || j                  S # t.          $ r.}t!          j        |d           t%          d          cY d }~S d }~ww xY w)Nr   rs  commentsnote
focus_areasetsrepsyoutube_linkvideosr   imagesr`   primary_image)r~  r   rs  r  r  r  r  r  r  r  r  r  ru  /view-exercise/r   r   )r   addSubExerciseformrH   rI   rJ   r&   r   r'   r(   r)   r   getlistr   r%  r  rx  r   rL   r	   rg   r   r   r@   r   r   )rB   r*   r   rF   r   rs  r  r  r  r  r  r  r  rj  
image_data
video_datar  r   r   videor  r   s                         r.   r,   zAddSubExercise.postn  s   -&

"7<
1
14
mmoo (.  ((D#''66K $$Z00H  ((D"&&|44J  ((D  ((D$((88L""8,,F (//2/66<<>>L JJ}X&& !m##H--V ! !e$$g'kg     }X&& !m##H--V ! !e$$g'kg    M})) W]..??@@Ww;]##\tP[gow{DLZdnx  HU $ V V VW3444%c,/&:&::;;;'$,---	 & & &GEFFF
$
%
%%%%%%%&s$   J=K  K 
L#LLLNr   rQ   r0   r.   r  r  e  sZ        (>>C000115 5 215
.& .& .& .& .&r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditSubExercisezedit_sub_exercise.htmlr`   r   c                    t           j                            |j        j                                                  }t          j                            |d                                          }t          j        |j	                  }t          j        |j
                  }t          || j        t                                S r8  rd   r'   r(   r5   r   r)   r  astliteral_evalr  r  r   r@   r|   rB   r*   r   rm   r  sub_exercise_imagessub_exercise_videoss          r.   r&   zEditSubExercise.get  s     ''W\_'==CCEE)%-44D4QQWWYY)*:*ABB)*:*ABB	*688	4	44r0   c           
         	 t          j        |j                  }|                                r|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }	|j                            d          }
|j                            d          }|j                            d	          }|j                            d
          }t          j                            |          	                                }t          j                            |          
                    ||||||	|
|           t          j        |j                  }t          j        |j                  }|j                            d          rmt!          |j                            d                    }d|z   }t          j                            |          
                    t#          |                     |j                            d          rH|j                            d          }|D ]+}t!          |          }d|z   }|                    |           ,|j                            d          rH|j                            d          }|D ]+}t!          |          }d|z   }|                    |           ,|r2t          j        |          }|D ]}||v r|                    |           |r2t          j        |          }|D ]}||v r|                    |           t          j                            |          
                    ||           t+          j        |d           t/          dt#          |j        j                  z             S t5          || j                  S # t8          $ r.}t+          j        |d           t/          d          cY d }~S d }~ww xY w)Nr   rs  r  r  r  r  r  r  removed_imagesremoved_videosr   )r   rs  r  r  r  r  r  r  r  r`   )r  r  r  )r  r  r  r  r   r   )r   r  rH   rI   rJ   r&   r  r'   r(   r)   r   r  r  r  r  r   r   rg   r  r%  remover   rL   r	   r~  r   r   r@   r   r   )rB   r*   r   rF   r   rs  r  r  r  r  r  r  r  r  r  r  r  r   r  r   r  r  removed_images_listremoved_imageremoved_videos_listr   s                             r.   r,   zEditSubExercise.post  sB   <&

"7<
0
04
mmoo 7.  ((D#''66K $$Z00H  ((D"&&|44J  ((D  ((D$((88L\%%&677N\%%&677N'/66"6==CCEE##r#**11t_gosDL 2 S S S *+;+BCC+,<,CDD})) OW]..??@@W[W$$$++22W2NNN}X&& *m##H--V * *e$$g'kg  )))) }X&& *m##H--V * *e$$g'kg  ))))  1+N;;- 1 1	-	-	-!!-000 2+N;;. 2 2	.	.	.!!.111 ##r#**119LTg1hhhW4555%c*:*C*F&G&GGHHH'$,---	 & & &GEFFF
$
%
%%%%%%%&s$   O6P 9P 
Q#Q;QQNr   rQ   r0   r.   r  r    sZ        )>>C000115 5 215=& =& =& =& =&r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )ViewSubExercisezview_sub_exercise.htmlr`   r   c                    t           j                            |j        j                                                  }t          j                            |                                          }t          j        |j	                  }t          j        |j
                  }t          || j        t                                S )Nr   r   r  r  s          r.   r&   zViewSubExercise.get  s     ''W\_'==CCEE)%-444;;AACC)*:*ABB)*:*ABB	*688	4	44r0   Nr   rQ   r0   r.   r  r    sK        )>>C000115 5 215 5 5r0   r  c                       e Zd ZdZdS )	PlansListzplans_list.htmlNr3  rQ   r0   r.   r  r            "r0   r  c                       e Zd ZdZdS )SubscribedListzsubscribed_list.htmlNr3  rQ   r0   r.   r  r            'r0   r  c                       e Zd ZdZdS )AddSubscriptionzadd_subscription.htmlNr3  rQ   r0   r.   r  r            (r0   r  c                       e Zd ZdZdS )EditSubscriptionzedit_subscription.htmlNr3  rQ   r0   r.   r  r    s        )r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )	GetReportzget_report.htmlr`   r   c                    	 t           j                            d                                          }t          j                            d                                          }t
          j                                                                        }t           j                            d                              t          d                    	                    d                              t          d                    	                    dd                              d          }d	 |D             }d
 |D             }t           j                            d                              d          	                    d                              t          d                    }t          j        d |D                       }	t           j                            dd                                          }
t           j                            dd                                          }t          j        	                    d                              t          d                                                    }d |D             }d |D             }t          j        |          }t          j        |          }t!          ||           t#          || j        t'                                S # t(          $ r=}t!          |           t+          j        |d           t/          d          cY d }~S d }~ww xY w)NTr   r   r   r   r   r   r   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z!GetReport.get.<locals>.<listcomp>  s    <<<!G*<<<r0   c                 D    g | ]}|d                               d          S )r   z%Br   r   s     r.   r^   z!GetReport.get.<locals>.<listcomp>  s*    JJJq7$$T**JJJr0   r   r2   r   r   c                 0    g | ]}|d          |d         dS r   rQ   r   s     r.   r^   z!GetReport.get.<locals>.<listcomp>  s)    hhhQVuXU7^LLhhhr0   r   Fr   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z!GetReport.get.<locals>.<listcomp>  s    LLLqQ12LLLr0   c                     g | ]
}|d          S r   rQ   r   s     r.   r^   z!GetReport.get.<locals>.<listcomp>  s    :::Qaj:::r0   r   r   )r   r'   r(   r   r   r   ro  r   r   r   r   r   r   r   r   r   rK   r   r@   r|   r   r   r   r	   )rB   r*   total_usersr   total_exercisesget_new_clients_count
count_list	date_listr   r   r   r   r   r   r   r   r   r   s                     r.   r&   zGetReport.get   s   "'&&$&??EEGGK?))T)BBHHJJN!)--//5577O!/00D0IIRRYcdpYqYqRrryy  {B  C  C  L  L;; L  fWWhhw//  =<&;<<<JJJ4IJJJIOWDW!!W2WVHXE$KKX    *hhZghhhiiK&&$TX&YY__aaK''4UZ'[[aaccL (//0JKKTT[`ae[f[fTggpprrOLLOLLLM::/:::N*]33:n55	-''''$,VXX666
 ' ' '	!HHHWFGGG%&&&&&&&&'s   K7K: :
M2L<6M<MNr   rQ   r0   r.   r  r    sK        #-NNS11122#' #' 32#' #' #'r0   r  c                       e Zd ZdZdS )ProductListingzproduct_listing.htmlNr3  rQ   r0   r.   r  r  &  r  r0   r  c                       e Zd ZdZdS )
AddProductzadd_product.htmlNr3  rQ   r0   r.   r  r  )  r4  r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )MainGoalsLisitngzgoals_listing.htmlr`   r   c                    	 t           j                            |j        j                                                  }t          j                            dd                              d          }|j        	                    d          }|r5t          j                            |dd                              d          }t          |d          }|j        	                    d	          }|                    |          }t          || j        t                                S # t          $ r=}t!          |           t#          j        |d
           t'          d          cY d }~S d }~ww xY w)Nr   
main_goalsTscreen_typer   r   r  )title__icontainsr  r   r  r  r   r   )rd   r'   r(   r5   r   r)   OnBoardingDatar   r%   r&   r   r  r   r@   r|   r   rK   r   r   r	   )	rB   r*   rm   ri  r  r  r  	goals_objr   s	            r.   r&   zMainGoalsLisitng.get/  s_   &!((glo(>>DDFF9$++X\+]]ffglmm8**; L%,,kVbvz,{{  E  E  FK  L  LH2&&9((;!!+..9
+FHH
5
55	 & & &888GEFFF
$
%
%%%%%%%&s   D!D$ $
E+.2E& E+&E+Nr   rQ   r0   r.   r  r  -  sK        %>>C00011& & 21& & &r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AddGoalszadd_goals.htmlr`   r   c                     t           j                            |j        j                                                  }t          || j        t                                S r   r   r   s      r.   r&   zAddGoals.getC  sF      ''W\_'==CCEE)	*688	4	44r0   c                    	 t          j        |j                  }|                                r_|j                            d          }t          j                            |d           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titler  r  r  ru  goals-listingr   r   r   onboarding_formrH   rI   rJ   r&   r  r'   rx  r   rL   r	   r   r@   r   r   rB   r*   rF   r  r   s        r.   r,   zAddGoals.postI  s    &


-
-4
mmoo .!!'**E!!,!GGGW3444O$$$'$,---	 & & &GEFFF
$
%
%%%%%%%&$   BB# B# #
C-#CCCNr   rQ   r0   r.   r  r  A  sZ        !>>C000115 5 215& & & & &r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )	EditGoalszedit_goals.htmlr`   r   c                 &   t           j                            |j        j                                                  }t          j                            |dd                                          }t          || j        t                                S )Nr   r  Tr   r  r   
rd   r'   r(   r5   r   r)   r  r   r@   r|   )rB   r*   r   rm   r  s        r.   r&   zEditGoals.getY  sn     ''W\_'==CCEE)$++rl\`+aaggii)	*688	4	44r0   c                 f   	 t          d           t          j        |j                  }|                                rt          d           |j                            d          }t          j        	                    |          
                    |d           t          j        |d           t          d          S t          d	           t          |j                   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   )rK   r   r  rH   rI   rJ   r&   r  r'   r(   r   r   rL   r	   r  r   r@   r   r   rB   r*   r   rF   r  r   s         r.   r,   zEditGoals.post_  s-   &


-
-4
mmoo .	&MMM!!'**E!!R!((//e/UUU W4555O$$$ 
)	$+'$,---	 & & &GEFFF
$
%
%%%%%%%&s$   B=C8  7C8 8
D0#D+%D0+D0Nr   rQ   r0   r.   r  r  W  sZ        ">>C000115 5 215
& & & & &r0   r  c                   P    e Zd Z e ed                    d             Zd ZdS )DeleteGoalsr`   r   c                    t           j                            |j        j                                                  }t          j                            |          }|rBt          j	                    |_
        |                                 t          j        |d           nt          j        |d           t          d          S )Nr   r   zGoals Deleted Successfullyr   z/goals-listingrd   r'   r(   r5   r   r)   r  r&   r   r-  r.  rj   r   rL   r   r	   r/  s        r.   r&   zDeleteGoals.getw  s      ''W\_'==CCEE)

 
$
$
$
+
+' 3LNN7
<<>>>G9::::>'1222	"	#	##r0   c                    	 t          j        |j                  }|                                rr|j                            d          }t          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  Updated Succesfullyr  r   	dashboardr   r  rH   rI   rJ   r&   r  r'   r(   r   r   rL   r	   r   r@   r   r   r  s         r.   r,   zDeleteGoals.post  s     


-
-4
mmoo .!!'**E!!R!((//e/<<<W3444O$$$'$,---	      GEFFF
;

 $   BB6 !B6 6
C. #C)#C.)C.N)rN   rO   rP   r   r   r&   r,   rQ   r0   r.   r  r  v  sU        >>C00011$ $ 21$         r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )MedicalConditionszmedical_listing.htmlr`   r   c                    	 t           j                            |j        j                                                  }t          j                            dd                              d          }|j        	                    d          }|rCt          j                            t          |          dd                              d          }t          |d          }|j        	                    d	          }|                    |          }t          || j        t                                S # t           $ r=}t#          |           t%          j        |d
           t)          d          cY d }~S d }~ww xY w)Nr   medical_conditionsTr  r   r  r  r  r  r   r   rd   r'   r(   r5   r   r)   r  r   r%   r&   r   r   r  r   r@   r|   r   rK   r   r   r	   )	rB   r*   rm   ri  r  r  r  medical_objr   s	            r.   r&   zMedicalConditions.get  su   &!((glo(>>DDFF9$++8L`d+eennotuu8**; W%,,Q-L-L-LYm  BF,  G  G  P  P  QV  W  WH2&&9((;##K00;
+FHH
5
55	 & & &888GEFFF
$
%
%%%%%%%&   D/D2 2
E9<2E4.E94E9Nr   rQ   r0   r.   r  r    K        '>>C00011& & 21& & &r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AddMedicalConditionszadd_conditions.htmlr`   r   c                     t           j                            |j        j                                                  }t          || j        t                                S r   r   r   s      r.   r&   zAddMedicalConditions.get  D     ''W\_'==CCEE)	*688	4	44r0   c                    	 t          j        |j                  }|                                r_|j                            d          }t          j                            |d           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  ru  medical-listingr   r   r  r  s        r.   r,   zAddMedicalConditions.post  s    &


-
-4
mmoo .!!'**E!!:N!OOOW3444%&&&'$,---	 & & &GEFFF
$
%
%%%%%%%&r  Nr   rQ   r0   r.   r  r    sZ        &>>C000115 5 215& & & & &r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditMedicalszedit_medicals.htmlr`   r   c                 &   t           j                            |j        j                                                  }t          j                            |dd                                          }t          || j        t                                S )Nr   r  Tr  r  )rB   r*   r   rm   medicals_objs        r.   r&   zEditMedicals.get  so     ''W\_'==CCEE)'.."AUgk.llrrtt,	*688	4	44r0   c                    	 t          j        |j                  }|                                rr|j                            d          }t          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  r  r  r   r   r  r  s         r.   r,   zEditMedicals.post      &


-
-4
mmoo .!!'**E!!R!((//e/<<<W3444%&&&'$,---	 & & &GEFFF
$
%
%%%%%%%&r  Nr   rQ   r0   r.   r  r    sZ        %>>C000115 5 215
& & & & &r0   r  c                   J    e Zd Z e ed                    d             ZdS )DeleteMedicalsr`   r   c                    t           j                            |j        j                                                  }t          j                            |d          }|rBt          j	                    |_
        |                                 t          j        |d           nt          j        |d           t          d          S )Nr   r  )r   r  z&Medical condition deleted Successfullyr   z/medical-listingr  r/  s        r.   r&   zDeleteMedicals.get  s      ''W\_'==CCEE)

 
$
$7K
$
L
L' 3LNN7
<<>>>GEFFFF>'1222	$	%	%%r0   Nr   rQ   r0   r.   r
  r
    r0  r0   r
  c                   N    e Zd ZdZ e ed                    d             ZdS )AllergyListingzallergy_listing.htmlr`   r   c                    	 t           j                            |j        j                                                  }t          j                            dd                              d          }|j        	                    d          }|rCt          j                            t          |          dd                              d          }t          |d          }|j        	                    d	          }|                    |          }t          || j        t                                S # t           $ r=}t#          |           t%          j        |d
           t)          d          cY d }~S d }~ww xY w)Nr   allergy_exclusionTr  r   r  r  r  r  r   r   r  )	rB   r*   rm   ri  r  r  r  allergy_objr   s	            r.   r&   zAllergyListing.get  su   &!((glo(>>DDFF9$++8K_c+ddmmnstt8**; V%,,Q-L-L-LYl  AE,  F  F  O  O  PU  V  VH2&&9((;##K00;
+FHH
5
55	 & & &888GEFFF
$
%
%%%%%%%&r  Nr   rQ   r0   r.   r  r    r  r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )
AddAllergyzadd_allergy.htmlr`   r   c                     t           j                            |j        j                                                  }t          || j        t                                S r   r   r   s      r.   r&   zAddAllergy.get  r   r0   c                    	 t          j        |j                  }|                                r_|j                            d          }t          j                            |d           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  ru  allergy-listingr   r   r  r  s        r.   r,   zAddAllergy.post  s    &


-
-4
mmoo .!!'**E!!:M!NNNW3444%&&&'$,---	 & & &GEFFF
$
%
%%%%%%%&r  Nr   rQ   r0   r.   r  r    sZ        #>>C000115 5 215& & & & &r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditAllergyzedit_allergy.htmlr`   r   c                 &   t           j                            |j        j                                                  }t          j                            |dd                                          }t          || j        t                                S )Nr   r  Tr  r  )rB   r*   r   rm   r  s        r.   r&   zEditAllergy.get  so     ''W\_'==CCEE)&--@Sei-jjpprr+	*688	4	44r0   c                    	 t          j        |j                  }|                                rr|j                            d          }t          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  r  r  r   r   r  r  s         r.   r,   zEditAllergy.post  r  r  Nr   rQ   r0   r.   r  r    sZ        $>>C000115 5 215
& & & & &r0   r  c                   J    e Zd Z e ed                    d             ZdS )DeleteAllergyr`   r   c                 L   	 t           j                            |                              t	          j                               t          j        |d           t          d          S # t          $ r.}t          j
        |d           t          d          cY d }~S d }~ww xY w)Nr   )r.  zDeleted Succesfullyr  r   r   )r  r'   r(   r   r   r-  r   rL   r	   r   r   )rB   r*   r   r   s       r.   r&   zDeleteAllergy.get#  s    '!!R!((///HHHW3444%&&&
 ' ' 'WFGGG%&&&&&&&&'s   A(A+ +
B#5#BB#B#Nr   rQ   r0   r.   r  r  "  sF        NNS11122' ' 32' ' 'r0   r  c                   J    e Zd Z e ed                    d             ZdS )changeOnBoardingStatusr`   r   c                 "   	 t           j                            |j        d                   }|j        d         |_        |                                 |j        dk    r<t          j        |d           t          |j	                            d                    S t          j
        |d           t          |j	                            d                    S # t          $ r.}t          j        |d           t          d	          cY d }~S d }~ww xY w)
NrB  r   r   rC  zStatus is activatedrD  zStatus is deactivatedr   r   )r  r'   r&   rH   r   rj   r   rL   r
   rE  r   r   r   r	   rF  s       r.   r,   zchangeOnBoardingStatus.post/  s   &&**Y0G*HH3X&3:88:::	jCW3444((88999N73444((88999	 & & &GEFFF
$
%
%%%%%%%&rH  NrI  rQ   r0   r.   r  r  .  ra  r0   r  c                       e Zd ZdZdS )
Commissionzcommission.htmlNr3  rQ   r0   r.   r!  r!  ?  r  r0   r!  c                   N    e Zd ZdZ e ed                    d             ZdS )PaymentListzpayment_listing.htmlr`   r   c                    |j                             d          }|j                             d          }t          d|           |j                             d          }t          d|           t          j                                        }|                    ddddd          }|r~t          d           |                    t          |	          t          |
          z  t          |          z            	                    d                              ddddd          }|rE|rC|                    ||gd          	                    d                              ddddd          }|rC|sA|                    |d          	                    d                              ddddd          }|rC|sA|                    |d          	                    d                              ddddd          }t          |d          }|j                             d          }|                    |          }	t          || j        t                                S )Nr  r  r  trainer__full_nameuser__imageuser__full_nameamountr  trainer__full_name__icontainsuser__full_name__icontainsamount__icontainsr   trainer__imageTr	  r  r  r  )r%   r&   rK   UserTranscationsr'   ro  r   r(   r   r   r   r  r   r@   r|   )
rB   r*   r  r  r  get_transactiontransactionsr  r  transactions_datas
             r.   r&   zPaymentList.getD  s    **;--:j!!!kooj))8H#+//11?!(()=>RS`ars{||<  	&MMM"))k222;///0+&&&'  xvv 	   ZX Z ''H@Uim'nnwwx}~~  F  F  G[  \p  q~  P  QY  Z  ZL H H ''W['\\eefkllss  uI  J^  _l  m~  G  H  HL Iz I!((*X\(]]ffglmmtt  vJ  K_  `m  n  @H  I  ILr**9((; ))+66
+FHH
5
55r0   Nr   rQ   r0   r.   r#  r#  B  sK        '>>C00011"6 "6 21"6 "6 "6r0   r#  c                       e Zd ZdZdS )ViewPaymentzview_payment.htmlNr3  rQ   r0   r.   r5  r5  j  s        $r0   r5  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )TrainerPaymentRequestlistingz!list_trainer_payment_request.htmlr`   r   c                 B   	 |j                             d          }|j                             d          }t          j                            |          }|dk    r%|                    d           t          d          S |dk    r%|                    d	           t          d          S |d
k    r%|                    d
           t          d          S t          d          S # t          $ r.}t          j	        |d           t          d          cY d }~S d }~ww xY w)Nr   r   r   acceptacceptedr   ztrainer-payment-request-listingrejectrejectedpendingr   )
rH   r&   Requestmoneyr'   r(   r   r	   r   r   r   )rB   r*   r   r   r1  r   s         r.   r,   z!TrainerPaymentRequestlisting.posto  sA   6LX&&6lt2'..".55?*---5666(*---5666 	)),,,5666
 5666	 6 6 6GEFFF
4
5
55555556s0   A>C& *C& ,*C& C& &
D0#DDDc                    	 |j                             d          }|j                             d          }t          d|           |j                             d          }t          d|           t          j                                        }|                    dddddd	                              d
          }|r~t          d           |                    t          |          t          |          z  t          |          z                                d
                              ddddd          }|rE|rC|                    ||gd                              d
                              ddddd          }|rC|sA|                    |d                              d
                              ddddd          }|rC|sA|                    |d                              d
                              ddddd          }t          || j        t                                S # t          $ r=}t          |           t          j        |d           t!          d          cY d }~S d }~ww xY w)Nr  r  r  r   r/  r%  r   requested_moneyr   z-created_atr  r)  r+  r-  trainer__idTr	  r  r   r   )r%   r&   rK   r>  r'   ro  r   r   r(   r   r   r@   r|   r   r   r   r	   )rB   r*   r  r  r  r1  r2  r   s           r.   r&   z TrainerPaymentRequestlisting.get  s   #&**;--:j!!!kooj))8H'++--?!((.>?ST`ars{||  F  F  GT  U  U<  	&MMM"))k222;///0+&&&'  xvv   	   fX f ''H@Uim'nnww  yF  G  G  N  N  O\  ]q  rF  GS  Te  f  fL T T ''W['\\eefstt{{  }J  K_  `t  uA  BS  T  TL Uz U!((*X\(]]ffgtuu||  ~K  L`  au  vB  CT  U  UL +FHH
5
55	 & & &888GEFFF
$
%
%%%%%%%&s   H+H. .
I582I0*I50I5N)rN   rO   rP   r@   r   r   r,   r&   rQ   r0   r.   r7  r7  m  sZ        2>>C000116 6 216:%& %& %& %& %&r0   r7  c                   N    e Zd ZdZ e ed                    d             ZdS )ContentManagementListzcontent_management.htmlr`   r   c                    	 t           j                            |j        j                                                  }t          j                            d                              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   r   )rd   r'   r(   r5   r   r)   ContentManagementr   r   r@   r|   r   r   r   r	   )rB   r*   rm   content_objr   s        r.   r&   zContentManagementList.get  s    &!((glo(>>DDFF9"*11T1JJSSTXYY;
+FHH
5
55	 & & &GEFFF
$
%
%%%%%%%&s   BB 
C#C CCNr   rQ   r0   r.   rC  rC    sK        *>>C00011& & 21& & &r0   rC  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )UpdateContentPagezupdate_content_page.htmlr`   r   c                    	 t           j                            |j        j                                                  }t          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   )rd   r'   r(   r5   r   r)   rE  r   r@   r|   r   r   r   r	   )rB   r*   r   rm   rF  r   s         r.   r&   zUpdateContentPage.get  s    &!((glo(>>DDFF9"*11r1::@@BB;
+FHH
5
55	 & & &GEFFF
$
%
%%%%%%%&s   BB 
C
#C?C
C
c                    	 t          j        |j                  }|                                rr|j                            d          }t          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+   r   zcontent-managementr   r   )r   updatecontent_formrH   rI   rJ   r&   rE  r'   r(   r   r   rL   r	   r   r@   r   r   )rB   r*   r   rF   rK  r   s         r.   r,   zUpdateContentPage.post  s    &

"7<
0
04
mmoo .##I..G$$$++222@@@W2333()))'$,---	 & & &GEFFF
$
%
%%%%%%%&r  Nr   rQ   r0   r.   rH  rH    sZ        +>>C00011& & 21&& & & & &r0   rH  c                   N    e Zd ZdZ e ed                    d             ZdS )
FaqListingzfaq_listing.htmlr`   r   c                    t           j                            |j        j                                                  }t          j                            d                              d          }t          |d          }|j	        
                    d          }|                    |          }t          || j        t                                S )Nr   Tr   r   r  r  )rd   r'   r(   r5   r   r)   Faqr   r   r%   r&   r  r   r@   r|   )rB   r*   rm   ri  r  r  faq_objs          r.   r&   zFaqListing.get  s     ''W\_'==CCEE)[488AA%HH("%%)''+{++'	*688	4	44r0   Nr   rQ   r0   r.   rN  rN    sK        #>>C000115 5 215 5 5r0   rN  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditFaqzedit_faq.htmlr`   r   c                 $   t           j                            |j        j                                                  }t          j                            |d                                          }t          || j        t                                S r8  )
rd   r'   r(   r5   r   r)   rP  r   r@   r|   )rB   r*   r   rm   rQ  s        r.   r&   zEditFaq.get  sj     ''W\_'==CCEE)K"==CCEE'	*688	4	44r0   c                    t          j        |j                  }|                                r|j                            d          }|j                            d          }|j                            d          }t          j                            |          	                    |||           t          j        |d           t          d          S t          || j                  S )Nr  rK  typer   r  rK  rV  r  /faq-listing)r   
addfaqformrH   rI   rJ   r&   rP  r'   r(   r   r   rL   r	   r   r@   )rB   r*   r   rF   r  rK  rV  s          r.   r,   zEditFaq.post  s    		',	'	'$	]]__ -  ))5""9--7




'
'4;##%T#JJJG3444
>
"
""
+
,
,,r0   Nr   rQ   r0   r.   rS  rS    sZ         >>C000115 5 215
- 
- 
- 
- 
-r0   rS  c                   N    e Zd ZdZ e ed                    d             ZdS )AddFaqadd_faq.htmlr`   r   c                    t          j        |j                  }|                                r|j                            d          }|j                            d          }|j                            d          }t          j                            |||           t          j
        |d           t          d          S t          |d          S )Nr  rK  rV  rW  Created SuccessfullyrX  r\  )r   rY  rH   rI   rJ   r&   rP  r'   rx  r   rL   r	   r   )rB   r*   rF   r  rK  rV  s         r.   r,   zAddFaq.post  s    		',	'	'$	]]__ )  ))5""9--7




'
'4;E't<<<G3444
>
"
""

(
((r0   NrN   rO   rP   r@   r   r   r,   rQ   r0   r.   r[  r[    sK        >>C00011
) 
) 21
) 
) 
)r0   r[  c                       e Zd ZdZdS )CreateWorkoutzcreate_workout.htmlNr3  rQ   r0   r.   ra  ra    s        &r0   ra  c                       e Zd ZdZdS )CreateWorkoutListzcreate_workout_list.htmlNr3  rQ   r0   r.   rc  rc    s        +r0   rc  c                       e Zd ZdZdS )SubWorkoutListzsub_workout_list.htmlNr3  rQ   r0   r.   re  re    r  r0   re  c                       e Zd ZdZdS )DayWorkoutListzday_workout.htmlNr3  rQ   r0   r.   rg  rg    r4  r0   rg  c                       e Zd ZdZdS )ScheduleListzschedule_list.htmlNr3  rQ   r0   r.   ri  ri    s        %r0   ri  c                   N    e Zd ZdZ e ed                    d             ZdS )AdminNotificationadmin_notifications.htmlr`   r   c                 x   t           j                            |j        j                                                  }t          j                                        }t          |d          }|j	        
                    d          }|                    |          }t          || j        t                                S )Nr      r  )rd   r'   r(   r5   r   r)   AdminNotificationsro  r   r%   r&   r  r   r@   r|   )rB   r*   rm   ri  r  r  
notify_objs          r.   r&   zAdminNotification.get  s      ''W\_'==CCEE)'++--(!$$)''+!!+..*	*688	4	44r0   Nr   rQ   r0   r.   rk  rk    sK        +>>C000115 5 215 5 5r0   rk  c                   N    e Zd ZdZ e ed                    d             ZdS )deleteAdminNotificationsrl  r`   r   c                    	 |j         dk    r|j                            d          }|rgd |                    d          D             }t          j                            |                                           t          j	        |d           nt          j
        |d           t          d          S t          d          S # t          $ r.}t          j        |d	           t          d
          cY d }~S d }~ww xY w)Nr%   	delete_idc                 ,    g | ]}t          |          S rQ   )int)r\   r   s     r.   r^   z0deleteAdminNotifications.get.<locals>.<listcomp>3  s    555CGG555r0   ,)pk__inzDeleted Sucessfullyz*At least One notification must be selectedz/admin-notificationsr   r   )methodr%   r&   r{   ro  r'   r(   deleter   rL   r   r	   r   r   )rB   r*   idsint_id_listr   s        r.   r&   zdeleteAdminNotifications.get,  s   &n
+//+
&
&C
 J55ciinn555[&&k&::AACCCg34444^GHIII*+++ *+++	 & & &GEFFF
$
%
%%%%%%%&s$   B1C 4C 
C;#C60C;6C;Nr   rQ   r0   r.   rr  rr  *  sK        +>>C00011& & 21& & &r0   rr  c                   N    e Zd ZdZ e ed                    d             ZdS )DiscoverMainListingzdiscover_main_list.htmlr`   r   c                    t           j                            d                              d          }|j                            d          }|r4t           j                            |d                              d          }t          |d          }|j                            d          }|                    |          }t          || j	        t                                S )NTr   r   r  )rh  r   rn  r  )DiscoverMainCategoryr'   r(   r   r%   r&   r   r  r   r@   r|   rB   r*   ri  r  r  r  dis_objs          r.   r&   zDiscoverMainListing.getE  s     #*11T1JJSSTYZZ())+ w"*11+ae1ffoopuvv8!$$)''+{++'	*688	4	44r0   Nr   rQ   r0   r.   r~  r~  C  sK        *>>C000115 5 215 5 5r0   r~  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AddMainListingadd_main_discover.htmlr`   r   c                 F    t          || j        t                                S r>   )r   r@   r|   rA   s     r.   r&   zAddMainListing.getS  s     
*688	4	44r0   c                 8   t          j        |j                  }|                                r^|j                            d          }t          j                            |           t          j
        |d           t          d          S t          |d          S )Nr   r   r^  /discover-main-listingr  )r   AddDiscoverCategoryFormrH   rI   rJ   r&   r  r'   rx  r   rL   r	   r   )rB   r*   rF   r   s       r.   r,   zAddMainListing.postX  s    		&w|	4	4$	]]__ 3




'
'4&&D&111G3444
+
,
,,
1
2
22r0   Nr   rQ   r0   r.   r  r  Q  sZ        )>>C000115 5 2153 3 3 3 3r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditMainListingedit_main_discover.htmlr`   r   c                     t           j                            |d                                          }t	          || j        t                                S )NTr  )r  r'   r(   r)   r   r@   r|   )rB   r*   r   ri  s       r.   r&   zEditMainListing.gete  sD     #*11R41PPVVXX(	*688	4	44r0   c                 `   t          j        |j                  }|                                rr|j                            d          }t          j                            |          	                    |           t          j        |d           t          d          S t          |d          S )Nr   r   r  r  r  r  )r   r  rH   rI   rJ   r&   r  r'   r(   r   r   rL   r	   r   )rB   r*   r   rF   r   s        r.   r,   zEditMainListing.postl  s    		&w|	4	4$	]]__ 4




'
'4&&B&//66D6AAAG3444
+
,
,,
2
3
33r0   Nr   rQ   r0   r.   r  r  c  sZ        *>>C000115 5 215
4 4 4 4 4r0   r  c                   J    e Zd Z e ed                    d             ZdS )DeleteMainListingr`   r   c                 ^   t           j                            |j        j                                                  }t          j                            |          }|r,t          j	                    |_
        |                                 t          j        |d           t          d          S )Nr   r   Category Deleted Successfullyr  )rd   r'   r(   r5   r   r)   r  r&   r   r-  r.  rj   r   rL   r	   )rB   r*   r   rm   main_categorys        r.   r&   zDeleteMainListing.getx  s      ''W\_'==CCEE)$,00B077- #<>>M
7;<<<	*	+	++r0   Nr   rQ   r0   r.   r  r  w  sF        >>C00011, , 21, , ,r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )DiscoverSubListingzdiscover_sub_list.htmlr`   r   c                    t           j                            d                              d          }|j                            d          }|rSt           j                            t          |          t          |          z  d                              d          }t          |d          }|j                            d          }|                    |          }t          || j
        t                                S )	NTr   r   r  r  )main_category__name__icontainsrn  r  )DiscoverSubCategoryr'   r(   r   r%   r&   r   r   r  r   r@   r|   r  s          r.   r&   zDiscoverSubListing.get  s    ")00D0IIRRSXYY())+ j!)00K1P1P1PSTt  TA  TA  TA  2A  UY0  Z  Z  c  c  di  j  j8!$$)''+{++'	*688	4	44r0   Nr   rQ   r0   r.   r  r    sK        )>>C000115 5 215 5 5r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AddSubListingadd_sub_discover.htmlr`   r   c                     t           j                            d          }t          || j        t                                S )NTr   )r  r'   r(   r   r@   r|   )rB   r*   main_objs      r.   r&   zAddSubListing.get  s6     #*11T1JJ(	*688	4	44r0   c                    t          j        |j                  }|                                r|j                            d          }|j                            d          }|j                            d          }t          j                            |          }t          j        	                    |||          }|j
                            d          r5|j
                            d          }t          |          }	d|	z   }	|	|_        t          j        |d           t          d	          S t!          |d
          S )Nr  rs  r  r   r  rs  r  r   r`   r  /discover-sub-listingr  )r   AddDiscoverSubCategoryFormrH   rI   rJ   r&   r  r'   r  rx  r   r   r   r   rL   r	   r   )
rB   r*   rF   r  rs  r  r  sub_objr  r   s
             r.   r,   zAddSubListing.post  s   		)',	7	7$	]]__ 2  ))5"&&}55;$((99="*..M.BB8 (//ebj/kk7m   ]w''FF##GKGGMG3444
*
+
++
0
1
11r0   Nr   rQ   r0   r.   r  r    sZ        (>>C000115 5 2152 2 2 2 2r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditSubListingzedit_sub_discover.htmlr`   r   c                     t           j                            |          }t          j                            d          }t          || j        t                                S )Nr   Tr   )r  r'   r&   r  r(   r   r@   r|   )rB   r*   r   r  r  s        r.   r&   zEditSubListing.get  sO     !(,,,33'"*11T1JJ(	*688	4	44r0   c                    t          j        |j                  }|                                rD|j                            d          }|j                            d          }|j                            d          }t          j                            |          }t          j        	                    |          
                    |||           |j                            d          rb|j                            d          }t          |          }	d|	z   }	t          j        	                    |          
                    |	           t          j        |d	           t          d
          S t!          |d          S )Nr  rs  r  r   r  r   r`   r   r  r  r  )r   r  rH   rI   rJ   r&   r  r'   r  r(   r   r   r   r   rL   r	   r   )
rB   r*   r   rF   r  rs  r  r  r  r   s
             r.   r,   zEditSubListing.post  sS   		)',	7	7$	]]__ 4  ))5"&&}55;$((99=#+//=/AA8%%2%..55EP[lt5uuum   H]w''FF##GKG&&B&//66w6GGGG3444
*
+
++
2
3
33r0   Nr   rQ   r0   r.   r  r    sZ        )>>C000115 5 2154 4 4 4 4r0   r  c                   J    e Zd Z e ed                    d             ZdS )DeleteSubListingr`   r   c                    t           j                            |j        j                                                  }t          j                            |          }|rBt          j	                    |_
        |                                 t          j        |d           nt          j        |d           t          d          S )Nr   r   r  r   r  )rd   r'   r(   r5   r   r)   r  r&   r   r-  r.  rj   r   rL   r	   )rB   r*   r   rm   sub_categorys        r.   r&   zDeleteSubListing.get  s      ''W\_'==CCEE)"*..".55, 5",..LW=>>>>G3444	)	*	**r0   Nr   rQ   r0   r.   r  r    sF        >>C00011	+ 	+ 21	+ 	+ 	+r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )viewSubListingzview_sub_discover.htmlr`   r   c                     t           j                            |          }t          j                            |d          }t          || j        t                                S )Nr   T)subcategory_idr   )r  r'   r&   DiscoverExerciser(   r   r@   r|   )rB   r*   r   r  execise_objs        r.   r&   zviewSubListing.get  sR      '++r+22' (//W[/\\+	*688	4	44r0   Nr   rQ   r0   r.   r  r    sK        )>>C000115 5 215 5 5r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )AdminDiscoverExericeszadd_discover_exercise.htmlr`   r   c                 "   t           j                            |                                          }t          j                            |j        j                                                  }t          || j        t                                S r  )
r  r'   r(   r)   rd   r5   r   r   r@   r|   r  s        r.   r&   zAdminDiscoverExerices.get  sk     %,33r3::@@BB, ''W\_'==CCEE)	*688	4	44r0   c                    t          j        |j                  }|                                rt	          d           |j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }	|	rd}
nd}
d}d}|j                            d	          r0|j                            d	          }t          |          }d
|z   }|}|j                            d          r,t          |j                            d                    }d
|z   }t          j
                            |                                          }|	r't          j
                            |
||	||||           n(t          j
                            |
||||||||	  	         t          j        |d           t#          dt%          |j                  z             S t	          |j                   t+          || j                  S )Nhellor   rs  r  r  weightminutesr2   r  r`   r  r   )exercise_typesubcategoryr  r   rs  r  r  )	r  r  r  r   rs  r  r  r  r  ru  /view-sub-listing/)r   addDiscoverExerciseformrH   rI   rK   rJ   r&   r   r   r  r'   r(   r)   r  rx  r   rL   r	   rg   r   r  r   r@   )rB   r*   r   rF   r   rs  r  r  r  r  r  r  r  r  r   subobjs                   r.   r,   zAdminDiscoverExerices.post  sP   

'
6
64
mmoo 6.	'NNN  ((D#''66K  ((D  ((D""8,,F##I..G ]]]JM}"" m))VV$$W[WZ})) W]..??@@Ww;] (//2/66<<>>F $$!! %     $$!! % 
 
 
 W3444(VY7888	$+'$,---r0   Nr   rQ   r0   r.   r  r    sZ        ->>C000115 5 215
8. 8. 8. 8. 8.r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )ViewDiscoverExericeszview_discover_exercise.htmlr`   r   c                     t           j                            |                                          }t	          || j        t                                S Nr   r  r'   r(   r)   r   r@   r|   rB   r*   r   exe_objs       r.   r&   zViewDiscoverExerices.get-  B     $++r+2288::'	*688	4	44r0   Nr   rQ   r0   r.   r  r  +  sK        .>>C000115 5 215 5 5r0   r  c                   T    e Zd ZdZ e ed                    d             Zd ZdS )EditDiscoverExericeszedit_discover_exercise.htmlr`   r   c                     t           j                            |                                          }t	          || j        t                                S r  r  r  s       r.   r&   zEditDiscoverExerices.get7  r  r0   c           
      P   t          j        |j                  }|                                rdt	          |           |j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }|j                            d          }	|	rd}
nd}
d}d}|j                            d          r0|j                            d          }t          |          }d	|z   }|}|j                            d
          r,t          |j                            d
                    }d	|z   }t          j
                            |                                          }|	r:t          j
                            |                              |
|	||||          }n;t          j
                            |                              |
|||||||          }t          j
                            |j        j                                                  }t#          j        |d           t'          dt)          |j                  z             S t+          || j                  S )Nr   rs  r  r  r  r  r2   r  r`   r  r   )r  r  r   rs  r  r  )r  r  r   rs  r  r  r  r  r  r  )r   r  rH   rI   rK   rJ   r&   r   r   r  r'   r(   r)   r   r  r  r   r   rL   r	   rg   r   r@   )rB   r*   r   rF   r   rs  r  r  r  r  r  r  r  r  r   get_discover_objupdated_discoverr  s                     r.   r,   zEditDiscoverExerices.post=  s   

'
6
64
mmoo %.	"III  ((D#''66K  ((D  ((D""8,,F##I..G ]]]MJ}"" m))VV$$W[WZ })) W]..??@@Ww;]%-444;;AACC Y&.555<<CCR_houy  GR  \f  uBC  C  C&.555<<CCR_gmsw  EP  X\  dh  r|  KXC  Y  Y !(//3C3O3R/SSYY[[FW3444(VY7888'$,---r0   Nr   rQ   r0   r.   r  r  5  sZ        .>>C000115 5 215'. '. '. '. '.r0   r  c                   N    e Zd ZdZ e ed                    d             ZdS )AddRestTimezadd_rest_time.htmlr`   r   c                    t          j        |j                  }|                                r|j                            d          }|j                            d          }|j                            d          }|rd}d }nd }d}t          j                            |||           t          j
        |d           t          d          S t          |j                   t          || j                  S )Nr  r  secondsT)r  r  r  ru  zadd-rest-time)r   addExercisetimerformrH   rI   rJ   r&   Exercisetimerr'   rx  r   rL   r	   rK   r  r   r@   )rB   r*   rF   r  r  r  s         r.   r,   zAddRestTime.posth  s    		#GL	2	2$	]]__ -




'
'4""9--7""9--7 GGGGG	     
 G2333
?
#
##
+
,
,,r0   Nr_  rQ   r0   r.   r  r  f  sK        %>>C00011- - 21- - -r0   r  )django.shortcutsr   django.views.generic.baser   django.views.genericr   django.contrib.authr   r   r   r	   django.http.responser
   modelsdjango.contribr   django.corer   django.template.loaderr   mathrW   rY   django.confr   django.core.paginatorr   django.httpr   django.contrib.auth.decoratorsr   django.utils.decoratorsr   r   r   r2   r   django.contrib.auth.modelsr   	functionsuser_app.modelsr   django.db.modelsr   r  trainer.modelsdjango.db.models.functionsr   r   r   django.utils.htmlr   r/   r6   r:   r<   rS   rv   r   r   r   r   r  r  r+  r2  r6  r@  rK  rQ  rZ  r_  rc  rf  rl  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#  r5  r7  rC  rH  rN  rS  r[  ra  rc  re  rg  ri  rk  rr  r~  r  r  r  r  r  r  r  r  r  r  r  r  rQ   r0   r.   <module>r     s   # # # # # # * * * * * * - - - - - - ; ; ; ; ; ; ; ; ; ; - - - - - - - - - - - - - -     # # # # # #       3 3 3 3 3 3                         + + + + + + $ $ $ $ $ $ 9 9 9 9 9 9 4 4 4 4 4 4  , , , , , ,       + + + + + +     # # # # # #       



         1 1 1 1 1 1 " " " " " "        ( ( ( ( ( (* * *	 	 	  3 3 3 3 3 3 3 3.> > > > >, > > >4$> $> $> $> $> $> $> $>N    ,   & & & & & & & &0 2 1 1 1 1 1 " " " " " " 06 06 06 06 06\ 06 06 06d& & & & &< & & &B%& %& %& %& %&, %& %& %&N5 5 5 5 5, 5 5 5,& & & & &D & & &"$ $ $ $ $ $ $ $& & & & &, & & &<& & & & &, & & &&& & & & & & & &>5 5 5 5 5 5 5 5 & & & & & & & &:& & & & & & & &&% % % % %4 % % %& & & & &< & & &(& & & & &, & & &>	5 	5 	5 	5 	5< 	5 	5 	5%& %& %& %& %&< %& %& %&N7& 7& 7& 7& 7&\ 7& 7& 7&tG& G& G& G& G&l G& G& G&R5 5 5 5 5l 5 5 5# # # # # # # #( ( ( ( (\ ( ( () ) ) ) )l ) ) )* * * * *| * * *&' &' &' &' &' &' &' &'P( ( ( ( (\ ( ( ($ $ $ $ $ $ $ $& & & & &| & & &(& & & & &| & & &,& & & & & & & &>         $      <& & & & & & & &(& & & & &< & & &*& & & & &< & & &,& & & & &T & & & & & & & &\ & & &(& & & & & & & &*& & & & &, & & &,
' 
' 
' 
' 
'L 
' 
' 
'& & & & &\ & & &"# # # # # # # #%6 %6 %6 %6 %6, %6 %6 %6P% % % % %, % % %F& F& F& F& F&< F& F& F&P
& 
& 
& 
& 
&L 
& 
& 
&& & & & & & & &6	5 	5 	5 	5 	5 	5 	5 	5- - - - -l - - -*) ) ) ) )\ ) ) ) ' ' ' ' 'L ' ' ', , , , , , , ,) ) ) ) )\ ) ) )$ $ $ $ $\ $ $ $& & & & &< & & &
5 
5 
5 
5 
5 
5 
5 
5& & & & &| & & &25 5 5 5 5, 5 5 53 3 3 3 3\ 3 3 3$4 4 4 4 4l 4 4 4(
, 
, 
, 
, 
, 
, 
, 
,5 5 5 5 5 5 5 52 2 2 2 2L 2 2 264 4 4 4 4\ 4 4 4<+ + + + +t + + +5 5 5 5 5\ 5 5 5A. A. A. A. A.L A. A. A.J5 5 5 5 5< 5 5 5/. /. /. /. /.< /. /. /.b- - - - -, - - - - -r0   