
    Q+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   )Important_Documentsc                       e Zd Zd Zy)ImportantDocumentsViewc                     |j                   j                  r-t        j                  j	                         }t        |dd|i      S t        j                  |d       t        d      S )Nz9custom_admin/important-documents/important-documents.htmlimportant_documentsYou have to login first.
adminLogin)	useris_authenticatedr   objectsallr   r   errorr   )selfrequestr   s      </var/www/html/SAHYOG_SETU_ADMIN/important_documents/views.pygetzImportantDocumentsView.get
   sc    <<(("5"="="A"A"C'#^av  yL  aM  N  NNN7$>?L))    N)__name__
__module____qualname__r    r   r   r
   r
   	   s    *r   r
   c                       e Zd Zd Zd Zy)ImportantDocumentViewc                     |j                   j                  rt        |d      S t        j                  |d       t        d      S )Nz<custom_admin/important-documents/new-important-document.htmlr   r   )r   r   r   r   r   r   )r   r   s     r   r   zImportantDocumentView.get   s7    <<(('#abb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_application&Important document saved successfully.adminImportantDocuments-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   important_documentes       r   postzImportantDocumentView.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 #'')  *RS 9:: NN7$>?L))  ;aw(WX 9::;s   EE= =	F<+F71F<7F<Nr   r   r   r   r5   r   r   r   r   r      s    **r   r   c                       e Zd Zd Zd Zy)EditImportantDocumentViewc                 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idz=custom_admin/important-documents/edit-important-document.htmlr3   z"Important document doesn't exists.r+   r   r   )
r   r   r   r   r   r   DoesNotExistr   r   r   )r   r   r;   r3   s       r   r   zEditImportantDocumentView.get>   s    <<((;%8%@%@%D%D"%D%M"g'fi}  AS  iT  U  U
 NN7$>?L)) '33 ;w(LM 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)Nr:   r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r   r   )r   r   r   r   r   r-   r!   r.   r"   r#   r$   r%   r&   r'   r(   r)   r/   r   r0   r   r1   r2   r   )r   r   r;   r3   r4   s        r   r5   zEditImportantDocumentView.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.Nr6   r   r   r   r8   r8   =   s    
**r   r8   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;   r:   z(Important document deleted successfully.r+   r   r   )r   r   r-   r   r   r   deleter   r0   r   r   )r   r;   r3   s      r   deleteImportantDocumentr@   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   r8   r@   r   r   r   <module>rE      s<    -  # '*T *#*D #*P+* +*`	&r   