
    sio                         d 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 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 ej(                  dej+                         ddg       y)zE
This page is handling the cbv methods of asset tab in profile page.
    )Any)reverse)gettext_lazy)AllocationListAssetRequestList)EmployeeProfileView)Employee)HorillaTabViewc                   x     e Zd ZdZdeddf fdZej                   ed      df ed      d	fgz   Z fd
Z	 xZ
S )AssetTabListViewz&
    Asset tab in individual view
    kwargsreturnNc                     t        |   di | | j                  j                  j                  j                  d      }t        dd|i      | _        d| _        y )Npkassets-tab-list-viewr   z	asset-div 	super__init__requestresolver_matchr   getr   
search_urlview_idselfr   r   	__class__s      7/var/www/python-projects/worksol/asset/cbv/asset_tab.pyr   zAssetTabListView.__init__   sM    "6"\\((//33D9!"8$L"    Statusstatus_displayzAssigned Dateassigned_date_displayc                     t         |          }| j                  j                  d      }|j	                  |      j                  d      }|S )zX
        Returns a filtered queryset of records assigned to a specific employee
        r   )assigned_to_employee_idF)return_status__isnull)r   get_querysetr   r   filterexcluder   querysetr   r   s      r   r'   zAssetTabListView.get_queryset    sO    
 7')[[__T"??2?>FF"' G 
 r    )__name__
__module____qualname____doc__r   r   r   columns_r'   __classcell__r   s   @r   r   r      sW    # # # $$	
8&'	
?	45( G

 
r    r   c                   6     e Zd ZdZdeddf fdZ fdZ xZS )AssetRequestTabz
    Asset request tab
    r   r   Nc                     t        |   di | | j                  j                  j                  j                  d      }t        dd|i      | _        d| _        y )Nr   asset-request-tab-list-viewr   zasset-request-divr   r   r   s      r   r   zAssetRequestTab.__init__2   sM    "6"\\((//33D9!"?r
S*r    c                 ~    t         |          }| j                  j                  d      }|j	                  |      }|S )zT
        Returns a filtered queryset of records for the requested employee.
        r   )requested_employee_id)r   r'   r   r   r(   r*   s      r   r'   zAssetRequestTab.get_queryset8   s9    
 7')[[__T"???<r    )r,   r-   r.   r/   r   r   r'   r2   r3   s   @r   r5   r5   -   s%    + + + r    r5   c                   6     e Zd ZdZdeddf fdZ fdZ xZS )AssetTabViewz(
    generic tab view for asset tab
    r   r   Nc                 2    t        |   di | d| _        y )Nz	asset-tabr   )r   r   r   )r   r   r   s     r   r   zAssetTabView.__init__H   s    "6""r    c           
      R   t        |   di |}| j                  j                  d      }||d<   t        j
                  j                  |      }||d<   t        d      t        dd|i       dt        d	      t        d
d|i       dddt        d       d| ddgdg|d<   |S )zO
        Adds the employee details and tab information to the context.
        r   emp_id)idinstanceAssetsr   r   )titleurlzAsset Requestr7   zCreate Requestz:asset.cbv.accessibility.create_asset_request_accessibilityz
                                data-toggle="oh-modal-toggle"
                                data-target="#genericModal"
                                hx-get="zasset-request-creationz?pk=z"
                                hx-target="#genericModalBody"
                                style="cursor: pointer;"
                                )actionaccessibilityattrs)rB   rC   actionstabsr   )r   get_context_datar   r   r	   objectsr1   r   )r   r   contextr   employeer   s        r   rI   zAssetTabView.get_context_dataL   s    
 '*4V4[[__T"##''2'.&
 8!"8r
KL
 ?+!"?bzRS #3)e&) *11I)J(K4PRt T!"$

. r    )r,   r-   r.   r/   r   r   rI   r2   r3   s   @r   r;   r;   C   s%    # # #! !r    r;   Assetz+asset.cbv.accessibility.asset_accessibility)rB   viewrE   )rH   N)r/   typingr   django.urlsr   django.utils.translationr   r1    asset.cbv.request_and_allocationr   r   employee.cbv.employee_profiler   employee.modelsr	   horilla_views.generic.cbv.viewsr
   r   r5   r;   add_tabas_viewr   r    r   <module>rX      sx      6 M = $ :~ :& ,*> *Z      ((*J	

r    