https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/admin/views/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/admin/views/__pycache__/autocomplete.cpython-310.pyc
o

3�a0�@sLddlmZddlmZmZddlmZmZddlm	Z	Gdd�de	�Z
dS)�)�apps)�FieldDoesNotExist�PermissionDenied)�Http404�JsonResponse)�BaseListViewc@sBeZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	ddd
�Z
dS)�AutocompleteJsonViewz3Handle AutocompleteWidget's AJAX requests for data.�Ncsd|�|�\|_|_|_�|�|�st�|��|_|��}t	�fdd�|dD�d|d�
�id��S)z�
        Return a JsonResponse with search results of the form:
        {
            results: [{id: "123" text: "foo"}],
            pagination: {more: true}
        }
        cs$g|]}tt|���t|�d��qS))�id�text)�str�getattr)�.0�obj��
to_field_name��I/usr/lib/python3/dist-packages/django/contrib/admin/views/autocomplete.py�
<listcomp>s��z,AutocompleteJsonView.get.<locals>.<listcomp>�object_list�more�page_obj)�results�
pagination)�process_request�term�model_admin�source_field�has_permr�get_querysetr�get_context_datar�has_next)�self�request�args�kwargs�contextrrr�gets


��zAutocompleteJsonView.getcOs|jj|jg|�Ri|��S)zUse the ModelAdmin's paginator.)r�
get_paginatorr#)r"r$r%rrrr(#sz"AutocompleteJsonView.get_paginatorcCsF|j�|j�}|�|j���}|j�|j||j�\}}|r!|��}|S)z9Return queryset based on ModelAdmin.get_search_results().)	rrr#�complex_filterr�get_limit_choices_to�get_search_resultsr�distinct)r"�qs�search_use_distinctrrrr'sz!AutocompleteJsonView.get_querysetc
Csf|j�dd�}z|jd}|jd}|jd}Wnty'}zt|�d}~wwzt�||�}Wnty?}zt|�d}~wwz|j�|�}Wnt	yW}zt|�d}~wwz|j
j}	Wntym}zt|�d}~wwz|j
j|	}
Wnty�}zt|�d}~ww|
�|�s�tdt|
�j��t|j
d|	jjj�}|	j�|�j}|
�||�s�t�||
||fS)a�
        Validate request integrity, extract and return request parameters.

        Since the subsequent view permission check requires the target model
        admin, which is determined here, raise PermissionDenied if the
        requested app, model or field are malformed.

        Raise Http404 if the target model admin is not configured properly with
        search_fields.
        r��	app_label�
model_name�
field_nameNz5%s must have search_fields for the autocomplete_view.)�GETr'�KeyErrorrr�	get_model�LookupError�_meta�	get_fieldr�remote_field�model�AttributeError�
admin_site�	_registry�get_search_fieldsr�type�__qualname__r
�pk�attname�to_field_allowed)r"r#rr0r1r2�e�source_modelr�remote_modelrrrrrr0sX

����������
��z$AutocompleteJsonView.process_requestcCs|jj||d�S)z9Check if user has permission to access the related model.)r)r�has_view_permission)r"r#rrrrrdszAutocompleteJsonView.has_perm)N)�__name__�
__module__r@�__doc__�paginate_byr<r'r(rrrrrrrrs	4rN)�django.appsr�django.core.exceptionsrr�django.httprr�django.views.generic.listrrrrrr�<module>s


https://t.me/RX1948 - 2025