
    jJh                     v    d dl mZ d dlmZ d dlmZ d dlmZ  G d de      Z	 G d deej                        Zy	)
    )absolute_import)Query)db)TimestampMixinc                       e Zd Zd Zd Zd Zy)RegistrationQueryc                 b    | j                  t        j                  |k(        j                         S N)filterRegistrationidfirst)selfregistration_ids     5/var/www/dostadmin/dostadmin/db_model/registration.py	get_by_idzRegistrationQuery.get_by_id   s#    {{<??o=>DDFF    c                 b    | j                  t        j                  |k(        j                         S r
   )r   r   user_idr   )r   r   s     r   get_by_user_idz RegistrationQuery.get_by_user_id   s%    {{<//7:;AACCr   c                     | j                  t        j                  j                  |dd              j	                         S )Ni)r   r   phonecontainsr   )r   r   s     r   get_by_user_phonez#RegistrationQuery.get_by_user_phone   s1    {{<--66uST{CDJJLLr   N)__name__
__module____qualname__r   r   r    r   r   r   r      s    GDMr   r   c                      e Zd ZdZeZ G d d      Z G d d      Z ej                  ej                  d      Z ej                  ej                   ej                  d            Z ej                  ej                   ej                  d	            Z ej                   ej                  d
      d      Z ej                   ej                  d
      d      Z ej                  ej                   ej                  d            Z ej                   ej                  d
      d      Z ej                  ej                   ej                  d            Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                   ej                  d      d      Z ej                  ej:                        Z ej                  ej:                        Z ej                  ej:                        Z  ej                  ej:                        Z! ej                  ej:                        Z" ej                  ej:                        Z# ej                  ej:                        Z$ ej                   ej                  d      d      Z% ej                   ej                  d      d      Z& ej                   ej                  d      d      Z' ej                   ej                  d      d      Z( ej                   ej                  d      d      Z) ej                  ej:                        Z* ej                   ej                  d      d      Z+ ejX                  dd      Z-e.d        Z/e.d        Z0e.d        Z1y)r   registrationc                       e Zd ZdZdZy)Registration.SignupStatuscomplete
incompleteN)r   r   r   COMPLETE
INCOMPLETEr   r   r   SignupStatusr"      s    !
r   r'   c                       e Zd ZdZdZy)Registration.OnboardingSourcemissed_calluiN)r   r   r   MISSED_CALL_REGISTEREDUI_REGISTEREDr   r   r   OnboardingSourcer)      s    !.r   r.   T)primary_keyzusers.idz
partner.id2   )uniqueFz
program.idztimecategory.idd   User)back_populatesc                 N    ||_         t        j                  j                          y r
   )
program_idr   sessioncommit)clsr    r6   s      r   update_program_idzRegistration.update_program_idB   s    ",


r   c                 N    ||_         t        j                  j                          y r
   )time_category_idr   r7   r8   )r9   r    r<   s      r   update_time_category_idz$Registration.update_time_category_idG   s    (8%


r   c                 0   	 | j                   j                  |      j                         }|j                  }t        j
                  j                  |       t        j
                  j                          |S # t        $ r}t        |      cY d }~S d }~ww xY w)N)r   )
query	filter_byr   r   r   r7   deleter8   	Exceptionstr)r9   
user_phoneregistration_datar   es        r   delete_registration_for_phonez*Registration.delete_registration_for_phoneL   su    	 #		 3 3* 3 E K K M/22OJJ/0JJ"" 	q6M	s   A4A7 7	B 
B
BBN)2r   r   r   __tablename__r   query_classr'   r.   r   ColumnIntegerr   
ForeignKeyr   
partner_idStringr   provider_numberr6   signup_statusr<   districtcentreblocksectorstateonboarding_sourceonboarded_byparent_typeBooleanis_child_between_0_3is_child_between_3_6is_child_above_6has_no_childhas_smartphonehas_dropped_missedcallhas_received_callbackeducation_level
occupationgender_of_childnumber_of_eligible_kidsvillageis_alumni_userclusterrelationshipuserclassmethodr:   r=   rG   r   r   r   r   r      s   "M#K" "  
2::4	0Bbii

MBMM*$=>G2::}r}}\'BCJBIIibiimD1Ebii			"e<O2::}r}}\'BCJBIIibiimE:M ryy]R]];L-MNryy36HRYYyryy~e4FBIIibiinU3ERYYyryy~e4FBIIibiinU3E!		)"))C.?299YRYYs^E:L"))IBIIcN59K$299RZZ0$299RZZ0 ryy,299RZZ(LRYYrzz*N&RYYrzz2%BIIbjj1bii			#u=O9299S>%8Jbii			#u=O'bii			#uEbii			#u5GRYYrzz*Nbii			#u5G2??%D
      r   r   N)
__future__r   flask_sqlalchemy.queryr   	BaseQuery	dostadminr   dostadmin.mixinsr   r   Modelr   r   r   r   <module>rq      s3    & 5  +M	 MC>288 Cr   