Ë
    ¸2Úi  ã                   ór   — d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d„ Zd„ Zd	„ Z G d
„ d«      Zy)é    )Úget_user_model)Úmodels)Úsettings)ÚObjectPermissionChecker)Úget_content_type)ÚWrongAppErrorc                 ó6   — t        | t        j                  «      S )z8
    Returns ``True`` if given ``obj`` is supported
    )Ú
isinstancer   ÚModel)Úobjs    úH/var/www/html/acx/venv/lib/python3.12/site-packages/guardian/backends.pyÚcheck_object_supportr   	   s   € ô �cœ6Ÿ<™<Ó(Ð(ó    c                 óÎ   — | j                   sVt        j                  €d| fS t        «       }|j                  t        j                  i} |j
                  j                  di |¤Ž} d| fS )zÙ
    Returns a tuple of checkresult and ``user_obj`` which should be used for
    permission checks

    Checks if the given user is supported. Anonymous users need explicit
    activation via ANONYMOUS_USER_NAME
    FT© )Úis_authenticatedr   ÚANONYMOUS_USER_NAMEr   ÚUSERNAME_FIELDÚobjectsÚget)Úuser_objÚUserÚlookups      r   Úcheck_user_supportr      sf   € ð ×$Ò$ô ×'Ñ'Ð/Ø˜(�?Ð"ÜÓˆØ×%Ñ%¤x×'CÑ'CÐDˆØ#�4—<‘<×#Ñ#Ñ- fÑ-ˆà�ˆ>Ðr   c                 óD   — t        |«      }t        | «      \  }} |xr || fS )zL
    Combination of ``check_object_support`` and ``check_user_support``
    )r   r   )r   r   Úobj_supportÚuser_supports       r   Úcheck_supportr   )   s-   € ô ' sÓ+€KÜ/°Ó9Ñ€L�(ØÒ'˜<¨Ð1Ð1r   c                   ó0   — e Zd ZdZdZdZdd„Zdd„Zdd„Zy)ÚObjectPermissionBackendTNc                  ó   — y ©Nr   )ÚselfÚrequestÚusernameÚpasswords       r   Úauthenticatez$ObjectPermissionBackend.authenticate7   s   € Ør   c           	      ó^  — t        ||«      \  }}|syd|v r{|j                  dd«      \  }}||j                  j                  k7  rMt	        |«      }||j                  k7  r3t        d|›d|j                  j                  ›d|j                  ›d�«      ‚t        |«      }|j                  ||«      S )ab  
        Returns ``True`` if given ``user_obj`` has ``perm`` for ``obj``. If no
        ``obj`` is given, ``False`` is returned.

        .. note::

           Remember, that if user is not *active*, all checks would return
           ``False``.

        Main difference between Django's ``ModelBackend`` is that we can pass
        ``obj`` instance here and ``perm`` doesn't have to contain
        ``app_label`` as it can be retrieved from given ``obj``.

        **Inactive user support**

        If user is authenticated but inactive at the same time, all checks
        always returns ``False``.
        Fú.é   zPassed perm has app label of 'z!' while given obj has app label 'z+' and given objcontent_type has app label 'ú')r   ÚsplitÚ_metaÚ	app_labelr   r   r   Úhas_perm)	r#   r   Úpermr   Úsupportr.   Ú_ÚctypeÚchecks	            r   r/   z ObjectPermissionBackend.has_perm:   s©   € ô* *¨(°CÓ8Ñˆ�ÙØà�$‰;ØŸ:™: c¨1Ó-‰LˆI�qØ˜CŸI™I×/Ñ/Ò/ô )¨Ó-�Ø §¡Ò/Ý'ò *3°C·I±I×4GÓ4GÈÏËð)Zó [ð [ô
 (¨Ó1ˆØ�~‰~˜d CÓ(Ð(r   c                 óp   — t        ||«      \  }}|s
t        «       S t        |«      }|j                  |«      S )za
        Returns a set of permission strings that the given ``user_obj`` has for ``obj``
        )r   Úsetr   Ú	get_perms)r#   r   r   r1   r4   s        r   Úget_all_permissionsz+ObjectPermissionBackend.get_all_permissionsb   s8   € ô
 *¨(°CÓ8Ñˆ�ÙÜ“5ˆLä'¨Ó1ˆØ�‰˜sÓ#Ð#r   )NNr"   )	Ú__name__Ú
__module__Ú__qualname__Úsupports_object_permissionsÚsupports_anonymous_userÚsupports_inactive_userr'   r/   r8   r   r   r   r    r    2   s$   „ Ø"&ÐØ"ÐØ!Ðóó&)ôP
$r   r    N)Údjango.contrib.authr   Ú	django.dbr   Úguardian.confr   Úguardian.corer   Úguardian.ctypesr   Úguardian.exceptionsr   r   r   r   r    r   r   r   ú<module>rE      s0   ðÝ .Ý Ý "Ý 1Ý ,Ý -ò)òò,2÷:$ò :$r   