403Webshell
Server IP : 65.108.144.40  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : dev ( 1000)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/erp/asset/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/asset/__pycache__/forms.cpython-310.pyc
o

hͦh�@�@s*dZddlZddlmZddlmZddlmZddlm	Z
ddlmZm
Z
mZmZmZmZmZddlmZdd	lmZdd
lmZddlmZddlmZd
d�ZGdd�de�ZGdd�dej�ZGdd�de�Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$Gdd�de�Z%dS)z�
forms.py
Asset Management Forms

This module contains Django ModelForms for handling various aspects of asset management,
including asset creation, allocation, return, category assignment, and batch handling.
�N)�date)�forms)�ValidationError)�gettext_lazy)�Asset�AssetAssignment�
AssetCategory�AssetDocuments�AssetLot�AssetReport�AssetRequest)�	ModelForm)�reload_queryset)�MultipleFileField)�Employee)�_thread_localscCs"i}|jdur|j�d�|d<|S)z3this is used to update change the date value formatNz%Y-%m-%d�asset_purchase_date)r�strftime)�instance�initial�r�/var/www/erp/asset/forms.py�set_date_field_initial s
�rc�6eZdZdZGdd�d�Z�fdd�Zdd�Z�ZS)�	AssetFormzB
    A ModelForm for creating and updating asset information.
    c
@s�eZdZdZeZdZddgZej	ddd�d�ej
d	ed
�ddd
d�d�ej	ddd�d�ejddd�d�ejddd�d�ej
ddd�d�ejddid�ejddid�ejdddd�d�d�	ZdS)zAssetForm.Metaa*
        Specifies the model and fields to be used for the AssetForm.
        Attributes:
            model (class): The model class Asset to be used for the form.
            fields (str): A special value "__all__" to include all fields
                          of the model in the form.
        �__all__�	is_active�ownerzMacbook Pro.�oh-input w-100��placeholder�class��attrs�textz#A powerful laptop for business use.�+oh-input oh-input--textarea oh-input--block��(��typer r!�rows�cols�LPT001rzoh-input  w-100)r)r!z1200.00.)r!r r!z/oh-select oh-select-2 select2-hidden-accessiblez,oh-select oh-select--lg oh-select-no-search z1oh-select oh-select-2 select2-hidden-accessible  �LOT001zbatchNoChange($(this)))r!r �onchange)	�
asset_name�asset_description�asset_tracking_idr�expiry_date�asset_purchase_cost�asset_category_id�asset_status�asset_lot_number_idN)�__name__�
__module__�__qualname__�__doc__r�model�fields�excluder�	TextInput�Textarea�_�	DateInput�NumberInput�Select�widgetsrrrr�Meta0sT���	���������
�rEcsttd�}|�d�}|rt|�|d<t�j|i|��t|j�|jdjj	�
dtt�
��i�|jdjj	�
dtt�
��i�|jdjj	�
dtt�
��i�|j�d�r�d	td
�fgt|jdj�dd��}||jd_|jjdur�|jdjdtd
�fg7_dSdSdS)N�requestrrr4�idr6r5zasset.add_assetlot�z---Choose Batch No.---�
lot_number�createzCreate new batch number)�getattrr�getr�super�__init__rr<�widgetr#�update�str�uuid�uuid4�user�has_permr@�list�queryset�values_list�choicesr�pk)�self�args�kwargsrFr�batch_no_choices��	__class__rrrNfs0


 � ��
��zAssetForm.__init__cCs�|j}tjj|jd���}|jrG|j�dd�r0|j�dd�|jkr0|j	jdd��
�r0tddi��tjj|jdd�j
|jd��
�rItddi��dSdS)	N�rGr5T)�return_status__isnullz(Asset in use you can"t change the statusr1)r1z+Already asset with this tracking id exists.)rr�objects�filterrZ�first�cleaned_datarLr5�assetassignment_set�existsr�datar=)r[r�
prev_instancerrr�clean~s4���������zAssetForm.clean)r7r8r9r:rErNrk�
__classcell__rrr_rr+s
6rc@s>eZdZdZejejdddddd�d�d	�ZGd
d�d�ZdS)
�DocumentFormz�
    Form for uploading documents related to an asset.

    Attributes:
    - file: A FileField with a TextInput widget for file upload, allowing multiple files.
    �file�Filezform-control�Truez.jpeg, .jpg, .png, .pdf)�namer)r!�multiple�acceptr")rOc@s eZdZdZeZdgZdgZdS)zDocumentForm.Metaa
        Metadata options for the DocumentForm.

        Attributes:
        - model: The model associated with this form (AssetDocuments).
        - fields: Fields to include in the form ('file').
        - exclude: Fields to exclude from the form ('is_active').
        rnrN)r7r8r9r:r	r;r<r=rrrrrE�s	�
rEN)	r7r8r9r:r�	FileFieldr>rnrErrrrrm�s���rmc�.eZdZdZGdd�d�Z�fdd�Z�ZS)�AssetReportForma[
    Form for creating and updating asset reports.

    Metadata:
    - model: The model associated with this form (AssetReport).
    - fields: Fields to include in the form ('title', 'asset_id').
    - exclude: Fields to exclude from the form ('is_active').

    Methods:
    - __init__: Initializes the form, disabling the 'asset_id' field.
    c@s"eZdZdZeZddgZdgZdS)zAssetReportForm.Metaa
        Metadata options for the AssetReportForm.

        Attributes:
        - model: The model associated with this form (AssetReport).
        - fields: Fields to include in the form ('title', 'asset_id').
        - exclude: Fields to exclude from the form ('is_active').
        �title�asset_idrN)r7r8r9r:rr;r<r=rrrrrE�s	�
rEcs(t�j|i|��d|jdjjd<dS)z�
        Initialize the AssetReportForm, disabling the 'asset_id' field.

        Args:
        - *args: Variable length argument list.
        - **kwargs: Arbitrary keyword arguments.
        �disabledrxN)rMrNr<rOr#�r[r\r]r_rrrN�szAssetReportForm.__init__�r7r8r9r:rErNrlrrr_rrv�srvc@seZdZdZGdd�d�ZdS)�AssetCategoryFormzC
    A form for creating and updating AssetCategory instances.
    c@sReZdZdZeZdZdgZej	e
d�dd�d�ejde
d	�d
ddd
�d�d�ZdS)zAssetCategoryForm.Metaa�
        Specifies the model and fields to be used for the AssetForm.
        Attributes:
            model (class): The model class AssetCategory to be used for the form.
            fields (str): A special value "__all__" to include all fields
                          of the model in the form.
            widgets (dict): A dictionary containing widget configurations for
                            specific form fields.
        rrz
Computers.rrr"r$z$A category for all types of laptops.r%r&r'r()�asset_category_name�asset_category_descriptionN)
r7r8r9r:rr;r<r=rr>r@r?rDrrrrrE�s"
���
�rEN)r7r8r9r:rErrrrr|�sr|cru)�AssetRequestFormzN
    A Django ModelForm for creating and updating AssetRequest instances.
    c
@s\eZdZdZeZdZdgZej	ddid�ej	ddid�ej
dded	�d
ddd
�d�d�ZdS)zAssetRequestForm.Metaa�
        Specifies the model and fields to be used for the AssetRequestForm.
        Attributes:
            model (class): The model class AssetRequest to be used for the form.
            fields (str): A special value "__all__" to include all fields
                          of the model in the form.
            widgets (dict): A dictionary containing widget configurations for
                            specific form fields.
        rrr!z0oh-select  oh-select-2 select2-hidden-accessibler"r$�objective_descriptionz6Requesting a laptop for software development purposes.r%r&r')r)rGr r!r*r+)�requested_employee_idr4�descriptionN)
r7r8r9r:rr;r<r=rrCr?r@rDrrrrrEs2
�������
�rEcs�|�dd�}t�j|i|��t|j�|dur6|�d�r6tj��|jd_	tjj
|jjd��
�|jd_ntjj
|d�|jd_	|j|jd_|jdjj�dtt���i�dS)NrTzasset.add_assetrequestr�ra)�employee_user_idr4rG)�poprMrNrr<rUrrc�allrWrd�employee_getrGrerrOr#rPrQrRrS)r[r\r]rTr_rrrN5s
���$zAssetRequestForm.__init__r{rrr_rr	s'rcs.eZdZdZ�fdd�ZGdd�d�Z�ZS)�AssetAllocationFormzQ
    A Django ModelForm for creating and updating AssetAssignment instances.
    csNt�j|i|��t|j�tjjdd�|jd_t�|jd<d|jd_	dS)N�	Available)r5rx�
assign_imagesT)
rMrNrr<rrcrdrWr�requiredrzr_rrrNLs
�zAssetAllocationForm.__init__c@sPeZdZdZeZdZgd�Zej	ddid�ej	ddid�ej	ddid�d�Z
dS)	zAssetAllocationForm.Metaa�
        Specifies the model and fields to be used for the AssetAllocationForm.
        Attributes:
            model (class): The model class AssetAssignment to be used for the form.
            fields (str): A special value "__all__" to include all fields
                          of the model in the form.
            widgets (dict): A dictionary containing widget configurations for
                            specific form fields.
        r)�return_date�return_condition�
assigned_date�
return_imagesrr!zoh-select oh-select-2 r")rx�assigned_to_employee_id�assigned_by_employee_idN)r7r8r9r:rr;r<r=rrCrDrrrrrEVs
���
�rE�r7r8r9r:rNrErlrrr_rr�Gs
r�cr)�AssetReturnFormzX
    A Django ModelForm for updating AssetAssignment instances during asset return.
    c@s\eZdZdZeZgd�Zejdddd�d�ej	dd	d
e
d�d�d�ejd
dd�d�d�ZdS)zAssetReturnForm.Metaa�
        Specifies the model and fields to be used for the AssetReturnForm.
        Attributes:
            model (class): The model class AssetAssignment to be used for the form.
            fields (list): The fields to include in the form, referring to
                           related AssetAssignment fields.
            widgets (dict): A dictionary containing widget configurations for
                            specific form fields.
        )r�r��
return_statusr�rr�true)r)r!r�r"r%r&r'z=on returns the laptop. However, it has suffered minor damage.)r!r*r+r zoh-select oh-select-2)r!r�)r�r�r�N)
r7r8r9r:rr;r<rrAr?r@rCrDrrrrrEs(

����
�
�rEcsBt�j|i|��t��|jd_tdd�|jd<d|jd_dS)z`
        Initializes the AssetReturnForm with initial values and custom field settings.
        r��Images)�labelr�TN)rMrNr�todayr<rrr�rzr_rrrN�szAssetReturnForm.__init__cCs.|j�d�}|r|t��krt�td���|S)aF
        Validates the 'return_date' field.

        Ensures that the return date is not in the future. If the return date is in the future,
        a ValidationError is raised.

        Returns:
        - The cleaned return date.

        Raises:
        - forms.ValidationError: If the return date is in the future.
        r�z$Return date cannot be in the future.)rfrLrr�rrr@)r[r�rrr�clean_return_date�s
z!AssetReturnForm.clean_return_date)r7r8r9r:rErNr�rlrrr_rr�zs
 
r�cs0eZdZdZd�fdd�ZGdd�d�Z�ZS)	�AssetBatchFormzI
    A Django ModelForm for creating or updating AssetLot instances.
    �returnNcs t�j|i|��t|j�dS)N)rMrNrr<rzr_rrrN�szAssetBatchForm.__init__c@sHeZdZdZeZdZejddd�d�ej	de
d�d	d
dd�d�d
�ZdS)zAssetBatchForm.Metaa�
        Specifies the model and fields to be used for the AssetBatchForm.
        Attributes:
            model (class): The model class AssetLot to be used for the form.
            fields (str): A special value "__all__" to include all fields
                          of the model in the form.
            widgets (dict): A dictionary containing widget configurations for
                            specific form fields.
        rzA12345.rrr"r$zhA batch of 50 laptops, consisting of Lenovo ThinkPad T480s                              and Dell XPS 13.r%r&r'r()rI�lot_descriptionN)r7r8r9r:r
r;r<rr>r?r@rDrrrrrE�s$
����
�rE)r�Nr�rrr_rr��sr�)&r:rR�datetimer�djangor�django.core.exceptionsr�django.utils.translationrr@�asset.modelsrrrr	r
rr�
base.formsr
�base.methodsr�employee.formsr�employee.modelsr�horilla.horilla_middlewaresrrrrmrvr|rr�r�r�rrrr�<module>s*$	l%*#>3D

Youez - 2016 - github.com/yon3zu
LinuXploit