
    vg                        d dl mZ d dl  G d dej                        Z G d dej                        Z G d dej                        Z G d	 d
ej                        Z G d dej                        Z G d dej                        Z	 G d dej                        Z
 G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Z G d dej                        Zy)    )serializers)*c                   H    e Zd Z ej                         Z G d d      Zd Zy)AssetCategorySerializerc                       e Zd ZeZg dZy)AssetCategorySerializer.Meta)
created_at
created_by
company_id	is_activeN)__name__
__module____qualname__AssetCategorymodelexclude     A/var/www/horilla/horilla_api/api_serializers/asset/serializers.pyMetar   	   s    Ir   r   c                 R    |j                   j                         j                         S N	asset_setallcountselfobjs     r   get_asset_countz'AssetCategorySerializer.get_asset_count       }}  "((**r   N)r   r   r   r   SerializerMethodFieldasset_countr   r    r   r   r   r   r      s#    3+335KJ J+r   r   c                   &    e Zd Z G d d      Zd Zy)AssetCategoryMiniSerializerc                       e Zd ZeZddgZy) AssetCategoryMiniSerializer.Metaidasset_category_nameN)r   r   r   r   r   fieldsr   r   r   r   r'      s    -.r   r   c                 R    |j                   j                         j                         S r   r   r   s     r   r    z+AssetCategoryMiniSerializer.get_asset_count   r!   r   N)r   r   r   r   r    r   r   r   r%   r%      s    / /+r   r%   c                        e Zd Z G d d      Zy)AssetLotSerializerc                       e Zd ZeZdZy)AssetLotSerializer.Meta__all__N)r   r   r   AssetLotr   r*   r   r   r   r   r/      s    r   r   Nr   r   r   r   r   r   r   r-   r-           r   r-   c                        e Zd Z G d d      Zy)AssetGetAllSerializerc                       e Zd ZeZg dZy)AssetGetAllSerializer.Meta)r(   
asset_nameasset_statusNr   r   r   Assetr   r*   r   r   r   r   r7   !   s    5r   r   Nr2   r   r   r   r5   r5       s    6 6r   r5   c                        e Zd Z G d d      Zy)AssetSerializerc                       e Zd ZeZdZy)AssetSerializer.Metar0   Nr:   r   r   r   r   r?   '   s    r   r   Nr2   r   r   r   r=   r=   &   r3   r   r=   c                        e Zd Z G d d      Zy)AssetAssignmentSerializerc                       e Zd ZeZdZy)AssetAssignmentSerializer.Metar0   Nr   r   r   AssetAssignmentr   r*   r   r   r   r   rC   -   s    r   r   Nr2   r   r   r   rA   rA   ,   r3   r   rA   c                       e Zd Z ej                         Z ej                         Z ej                         Z G d d      Zd Z	d Z
d Zy)AssetAssignmentGetSerializerc                       e Zd ZeZg dZy)!AssetAssignmentGetSerializer.Meta)r(   assetasset_categoryallocated_userassigned_datereturn_statusNrD   r   r   r   r   rI   7   s    
r   r   c                 .    |j                   j                  S r   )asset_idr8   r   s     r   	get_assetz&AssetAssignmentGetSerializer.get_assetB   s    ||&&&r   c                 B    |j                   j                  j                  S r   )rP   asset_category_idr)   r   s     r   get_asset_categoryz/AssetAssignmentGetSerializer.get_asset_categoryE   s    ||--AAAr   c                 @    t        |j                        j                  S r   )EmployeeGetSerializerassigned_to_employee_iddatar   s     r   get_allocated_userz/AssetAssignmentGetSerializer.get_allocated_userH   s    $S%@%@AFFFr   N)r   r   r   r   r"   rJ   rK   rL   r   rQ   rT   rY   r   r   r   rG   rG   2   sM    -K--/E6[668N6[668N	
 	
'BGr   rG   c                        e Zd Z G d d      Zy)AssetRequestSerializerc                       e Zd ZeZdZy)AssetRequestSerializer.Metar0   Nr   r   r   AssetRequestr   r*   r   r   r   r   r]   M       r   r   Nr2   r   r   r   r[   r[   L   r3   r   r[   c                   p    e Zd Z ej                         Z ej                         Z G d d      Zd Zd Z	y)AssetRequestGetSerializerc                       e Zd ZeZdZy)AssetRequestGetSerializer.Metar0   Nr^   r   r   r   r   rd   V   r`   r   r   c                 @    t        |j                        j                  S r   )r%   rS   rX   r   s     r   get_asset_category_idz/AssetRequestGetSerializer.get_asset_category_idZ   s    *3+@+@AFFFr   c                 @    t        |j                        j                  S r   )rV   requested_employee_idrX   r   s     r   get_requested_employee_idz3AssetRequestGetSerializer.get_requested_employee_id]   s    $S%>%>?DDDr   N)
r   r   r   r   r"   rS   rh   r   rf   ri   r   r   r   rb   rb   R   s:    999;=K==? GEr   rb   c                   H    e Zd Z ej                         Z G d d      Zd Zy)rV   c                       e Zd ZeZg dZy)EmployeeGetSerializer.Meta)r(   	full_nameemployee_profilebadge_idN)r   r   r   Employeer   r*   r   r   r   r   rl   d   s    Dr   r   c                 "    |j                         S r   )get_full_namer   s     r   rr   z#EmployeeGetSerializer.get_full_nameh   s      ""r   N)r   r   r   r   r"   rm   r   rr   r   r   r   rV   rV   a   s#    1113IE E#r   rV   c                   &    e Zd Z G d d      Zd Zy)AssetApproveSerializerc                       e Zd ZeZg dZy)AssetApproveSerializer.Meta)r(   rP   rW   assigned_by_employee_idassign_imagesNrD   r   r   r   r   rv   m   s    
r   r   c                     | j                   j                  d      }|j                  }|j                  |k7  rt        j                  d      |S )Nasset_requestzInvalid asset.)contextgetrS   r   ValidationError)r   valuerz   rK   s       r   validate_asset_idz(AssetApproveSerializer.validate_asset_idw   sF    ((9&88""n4--.>??r   N)r   r   r   r   r   r   r   r   rt   rt   l   s    
 
r   rt   c                   x    e Zd Z ej                  d      Z ej                  d      Z G d d      Zd Z	d Z
y)AssetReturnSerializerT)requiredc                       e Zd ZeZg dZy)AssetReturnSerializer.Meta)rN   return_conditionimageNrD   r   r   r   r   r      s    ?r   r   c                     |t         j                  D cg c]  }|d   	 c}vrt        j                  d      |S c c}w )Nr   zInvalid Choice)rE   STATUSr   r}   )r   r~   statuss      r   validate_return_statusz,AssetReturnSerializer.validate_return_status   s<    1G1GHvHH--.>?? Is   ;c                 \    | j                   j                  rt        j                  d      |S )NzAlready Returned)instancereturn_dater   r}   )r   rX   s     r   validatezAssetReturnSerializer.validate   s&    ==$$--.@AAr   N)r   r   r   r   	CharFieldrN   	FileFieldr   r   r   r   r   r   r   r   r      s<    )K))48M!K!!40E@ @
r   r   N)rest_frameworkr   asset.modelsModelSerializerr   r%   r-   r5   r=   rA   rG   r[   rb   rV   rt   r   r   r   r   <module>r      s    & +k99 +++"="= +44 6K77 6k11  ; ; G;#>#> G4[88 E ; ; E#K77 #[88 &K77 r   