
    F+h                         d dl mZ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      Z
 G d
 de      Zd Zy)    )renderredirect)View)messages   )Legal_Registrationsc                       e Zd Zd Zy)LegalRegistrationsViewc                     |j                   j                  r-t        j                  j	                         }t        |dd|i      S t        j                  |d       t        d      S )NzJcustom_admin/entrepreneurship/legal-registrations/legal-registrations.htmllegal_registrationsYou have to login first.
adminLogin)	useris_authenticatedr   objectsallr   r   errorr   )selfrequestr   s      M/var/www/html/SAHYOG_SETU_ADMIN/entrepreneurship/legal_registrations/views.pygetzLegalRegistrationsView.get
   sg    <<(("5"="="A"A"C'#o  sH  J]  r^  _  _NN7$>?L))    N)__name__
__module____qualname__r    r   r   r
   r
   	   s    *r   r
   c                       e Zd Zd Zd Zy)LegalRegistrationViewc                     |j                   j                  rt        |d      S t        j                  |d       t        d      S )NzMcustom_admin/entrepreneurship/legal-registrations/new-legal-registration.htmlr   r   )r   r   r   r   r   r   )r   r   s     r   r   zLegalRegistrationView.get   s7    <<(('#rssNN7$>?L))r   c                 ~   |j                   j                  rD	 t               }|j                  j	                  d      |_        |j                  d   |_        |j                  d   |_        |j                  j	                  d      |_	        |j                  j	                  d      |_
        |j                  j	                  d      |_        |j                  j	                  d      |_        |j                  j	                  d      |_        |j                  j	                  d	      |_        |j                          t!        j"                  |d
       t%        d      S t!        j*                  |d       t%        d      S # t&        $ r6}t)        |       t!        j*                  |d       t%        d      cY d }~S d }~ww xY w)Ntitleimagebannerstatusdescriptioneligibilityrequired_documents	web_linksmode_of_applicationz'Legal RFegistration saved successfully.adminLegalRegistrations-Something went wrong. Please try again later.r   r   )r   r   r   POSTr   r!   FILESr"   r#   r$   r%   r&   r'   r(   r)   saver   successr   	Exceptionprintr   )r   r   legal_registrationes       r   postzLegalRegistrationView.post   sf   <<((;%8%:"+2<<+;+;G+D"(+2==+A"(,3MM(,C"),3LL,<,<X,F")181A1A-1P".181A1A-1P".8?8H8HI]8^"5/6||/?/?/L",9@9I9IJ_9`"6 #'')  *ST 9:: NN7$>?L))  ;aw(WX 9::;s   EE= =	F<+F71F<7F<Nr   r   r   r   r4   r   r   r   r   r      s    **r   r   c                       e Zd Zd Zd Zy)EditLegalRegistrationViewc                 D   |j                   j                  r0	 t        j                  j	                  |      }t        |dd|i      S t        j                  |d       t        d      S # t        j                  $ r$ t        j                  |d       t        d      cY S w xY w)NidzNcustom_admin/entrepreneurship/legal-registrations/edit-legal-registration.htmlr2   z#Legal reigistration doesn't exists.adminImportantDocumentsr   r   )
r   r   r   r   r   r   DoesNotExistr   r   r   )r   r   r:   r2   s       r   r   zEditLegalRegistrationView.get>   s    <<((;%8%@%@%D%D"%D%M"g'w  {O  Rd  ze  f  f
 NN7$>?L)) '33 ;w(MN 9::;s   .A( (4BBc                    |j                   j                  rv	 t        j                  j	                  |      }|j
                  j	                  d      |_        d|j                  v r|j                  d   |_        d|j                  v r|j                  d   |_	        |j
                  j	                  d      |_
        |j
                  j	                  d      |_        |j
                  j	                  d      |_        |j
                  j	                  d      |_        |j
                  j	                  d	      |_        |j
                  j	                  d
      |_        |j!                          t#        j$                  |d       t'        d      S t#        j,                  |d       t'        d      S # t(        $ r6}t+        |       t#        j,                  |d       t'        d      cY d }~S d }~ww xY w)Nr9   r!   r"   r#   r$   r%   r&   r'   r(   r)   z&Important document saved successfully.r*   r+   r   r   )r   r   r   r   r   r,   r!   r-   r"   r#   r$   r%   r&   r'   r(   r)   r.   r   r/   r   r0   r1   r   )r   r   r:   r2   r3   s        r   r4   zEditLegalRegistrationView.postK   s   <<((;%8%@%@%D%D"%D%M"+2<<+;+;G+D"(gmm+/6}}W/E&,w}},07h0G&-,3LL,<,<X,F")181A1A-1P".181A1A-1P".8?8H8HI]8^"5/6||/?/?/L",9@9I9IJ_9`"6"'')  *RS 9:: NN7$>?L))  ;aw(WX 9::;s   E4F/ /	G.8+G)#G.)G.Nr5   r   r   r   r7   r7   =   s    
**r   r7   c                 H   | j                   j                  rl| j                  j                  d      }t        j
                  j                  |      }|j                          t        j                  | d       t        d      S t        j                  | d       t        d      S )Nr:   r9   z(Legal registration deleted successfully.r*   r   r   )r   r   r,   r   r   r   deleter   r/   r   r   )r   r:   r2   s      r   deleteLegalRegistrationr@   m   s    ||$$\\d#088<<"<E!!#"LM122w :;%%r   N)django.shortcutsr   r   django.viewsr   django.contribr   modelsr   r
   r   r7   r@   r   r   r   <module>rE      s<    -  # '*T *#*D #*P+* +*`	&r   