
    8j	                        d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	m
Z
 ddlmZ ddlmZ d dlmZ d d	lmZmZ dd
lmZmZ d dlmZ  G d de      Z G d de      Z G d dee      Z G d dee      Z G d dee      Z G d dee      Zy)    )JsonResponse)get_object_or_404renderredirect)View)Work_Sub_CategoriesWorks   )	LoginForm)EmailBackEnd)messages)loginlogout)ContractorProfileUsers)LoginRequiredMixinc                       e Zd Zd Zd Zy)AuthenticationViewsc                 (    t        |ddt        i      S )N
login.htmlform)r   r   selfrequests     -/var/www/html/HOMYLIO_ADMIN/accounts/views.pygetzAuthenticationViews.get   s    g|fy-ABB    c                 t   t        |j                        }|j                         rt        j                  ||j
                  d   |j
                  d         }t        |       |6|j                  dk(  rt        ||       t        d      S t        |d|dd      S t        |d|dd      S t        |dd	|i      S )
Nemailpassword)usernamer    r
   adminDashboardr   zInvalid email id or password)r   errorr   )r   POSTis_validr   authenticatecleaned_dataprint	user_typer   r   r   )r   r   r   users       r   postzAuthenticationViews.post   s    &==?,,WARARSZA[fjfwfw  yC  gD  ED$K>>Q&'4(#$455!'<4Sq9rssg|tOm5noo'<&4AAr   N)__name__
__module____qualname__r   r+    r   r   r   r      s    CBr   r   c                       e Zd Zd Zy)
LogoutViewc                 .    t        |       t        d      S )Nr   )r   r   r   s     r   r   zLogoutView.get(   s    w  r   Nr,   r-   r.   r   r/   r   r   r1   r1   &   s    !r   r1   c                       e Zd Zd Zy)	UsersViewc                 `    t         j                  j                  d      }t        |dd|i      S )N   )r)   z
users.htmlusers)r   objectsfilterr   )r   r   r8   s      r   r   zUsersView.get1   s-    $$$3g|g->??r   Nr3   r/   r   r   r5   r5   /   s    @r   r5   c                       e Zd Zd Zy)ContractorsViewc                     t         j                  j                  dd      j                  d      j	                  d      }t        |dd|i      S )N   F)r)   contractor_profile__isnullcontractor_profile-idzcontractors.htmlcontractors)r   r9   r:   select_relatedorder_byr   )r   r   rB   s      r   r   zContractorsView.get9   s[    mm**', + 
 . 

(5/ 	 {
 	
r   Nr3   r/   r   r   r<   r<   7   s    
r   r<   c                       e Zd Zd Zy)ContractorDetailsViewc                    t        t        j                  j                  d      j	                  d      |      }t
        j                  j                  dd      j                  |      j                  d      }|||j                         |j                  d	      j                         |j                  d
	      j                         |j                  d	      j                         d}t        |d|      S )Nr@   "contractor_profile__sub_categories)idworksub_category)
contractorrA   r
   )statusr7   r>   )rL   assigned_workstotal_assignedassigned_countstarted_countcompleted_countzcontractor.html)
r   r   r9   rC   prefetch_relatedr   r:   rD   countr   )r   r   rI   rL   rN   contexts         r   r   zContractorDetailsView.getN   s    &MM(($4 

 -44CC
 &!  

(5/ 	 %,,224,3313=CCE+22!2<BBD-44A4>DDF
 
 	
r   Nr3   r/   r   r   rF   rF   L   s    
r   rF   c                       e Zd Zd Zy) ToggleContractorVerificationViewc                     |j                   j                  d      }|j                   j                  d      dk(  }t        j                  j                  |      }||_        |j                          t        ddi      S )Ncontractor_idis_verifiedtrue)user_idrM   T)r$   r   r   r9   rZ   saver   )r   r   rY   rZ   rL   s        r   r+   z%ToggleContractorVerificationView.postr   sx    ((9ll&&}5?&..22! 3 

 "-
d
  	r   N)r,   r-   r.   r+   r/   r   r   rW   rW   p   s    r   rW   N)django.httpr   django.shortcutsr   r   r   django.viewsr   works.modelsr   r	   formsr   r   django.contribr   django.contrib.authr   r   modelsr   r   django.contrib.auth.mixinsr   r   r1   r5   r<   rF   rW   r/   r   r   <module>rg      s    $ @ @  3  & # - , 9B$ B0! !@"D @
($ 
*!
. !
H'94 r   