
    h,                         S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	J
r
  S SKJr   " S S5      r " S	 S
\5      r " S S\5      r " S S\5      rg)    )urlparse)settings)REDIRECT_FIELD_NAME)redirect_to_login)ImproperlyConfiguredPermissionDenied)resolve_urlc                   @    \ rS rSrSrSrSrSr\r	S r
S rS rS	 rS
rg)AccessMixin
   zR
Abstract CBV mixin that gives access mixins the same customizable
functionality.
N Fc                    U R                   =(       d    [        R                  nU(       dP  [        U R                  R
                   SU R                  R
                   SU R                  R
                   S35      e[        U5      $ )z;
Override this method to override the login_url attribute.
z, is missing the login_url attribute. Define z,.login_url, settings.LOGIN_URL, or override z.get_login_url().)	login_urlr   	LOGIN_URLr   	__class____name__str)selfr   s     L/var/www/html/env/lib/python3.13/site-packages/django/contrib/auth/mixins.pyget_login_urlAccessMixin.get_login_url   sr     NN8h&8&8	&>>**++W>>**++W>>**++<> 
 9~    c                     U R                   $ )zK
Override this method to override the permission_denied_message attribute.
)permission_denied_messager   s    r   get_permission_denied_message)AccessMixin.get_permission_denied_message"   s     ---r   c                     U R                   $ )zE
Override this method to override the redirect_field_name attribute.
)redirect_field_namer   s    r   get_redirect_field_name#AccessMixin.get_redirect_field_name(   s     '''r   c                    U R                   (       d%  U R                  R                  R                  (       a  [	        U R                  5       5      eU R                  R                  5       n[        U R                  5       5      n[        U5      S S u  p4[        U5      S S u  pVU(       a  X5:X  a&  U(       a  XF:X  a  U R                  R                  5       n[        UUU R                  5       5      $ )N   )raise_exceptionrequestuseris_authenticatedr   r   build_absolute_urir	   r   r   get_full_pathr   r    )r   pathresolved_login_urllogin_schemelogin_netloccurrent_schemecurrent_netlocs          r   handle_no_permission AccessMixin.handle_no_permission.   s    4<<#4#4#E#E"4#E#E#GHH||..0(););)=> &..@%A"1%E")1$);& > ><<--/D ((*
 	
r    )r   
__module____qualname____firstlineno____doc__r   r   r$   r   r   r   r   r    r0   __static_attributes__r2   r   r   r   r   
   s3    
 I "O-.(
r   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )LoginRequiredMixinC   z.Verify that the current user is authenticated.c                    > UR                   R                  (       d  U R                  5       $ [        TU ]  " U/UQ70 UD6$ N)r&   r'   r0   superdispatchr   r%   argskwargsr   s       r   r>   LoginRequiredMixin.dispatchF   s9    ||,,,,..w9$9&99r   r2   )r   r3   r4   r5   r6   r>   r7   __classcell__r   s   @r   r9   r9   C   s    8: :r   r9   c                   <   ^  \ rS rSrSrSrS rS rU 4S jrSr	U =r
$ )PermissionRequiredMixinL   z;Verify that the current user has all specified permissions.Nc                 4   U R                   cP  [        U R                  R                   SU R                  R                   SU R                  R                   S35      e[	        U R                   [
        5      (       a  U R                   4nU$ U R                   nU$ )z^
Override this method to override the permission_required attribute.
Must return an iterable.
z6 is missing the permission_required attribute. Define z".permission_required, or override z.get_permission_required().)permission_requiredr   r   r   
isinstancer   r   permss     r   get_permission_required/PermissionRequiredMixin.get_permission_requiredQ   s    
 ##+&>>**+ ,9>>**++M>>**++FH  d..44--/E  ,,Er   c                 l    U R                  5       nU R                  R                  R                  U5      $ )zD
Override this method to customize the way permissions are checked.
)rM   r%   r&   	has_permsrK   s     r   has_permission&PermissionRequiredMixin.has_permissionc   s-     ,,.||  **511r   c                 v   > U R                  5       (       d  U R                  5       $ [        TU ]  " U/UQ70 UD6$ r<   )rQ   r0   r=   r>   r?   s       r   r>    PermissionRequiredMixin.dispatchj   s;    ""$$,,..w9$9&99r   r2   )r   r3   r4   r5   r6   rI   rM   rQ   r>   r7   rC   rD   s   @r   rF   rF   L   s     E$2: :r   rF   c                   8   ^  \ rS rSrSrS rS rU 4S jrSrU =r	$ )UserPassesTestMixinp   zQ
Deny a request with a permission error if the test_func() method returns
False.
c                 ^    [        SR                  U R                  R                  5      5      e)Nz;{} is missing the implementation of the test_func() method.)NotImplementedErrorformatr   r   r   s    r   	test_funcUserPassesTestMixin.test_funcv   s*    !IPP''
 	
r   c                     U R                   $ )z;
Override this method to use a different test_func method.
)r[   r   s    r   get_test_func!UserPassesTestMixin.get_test_func}   s     ~~r   c                    > U R                  5       " 5       nU(       d  U R                  5       $ [        TU ]  " U/UQ70 UD6$ r<   )r^   r0   r=   r>   )r   r%   r@   rA   user_test_resultr   s        r   r>   UserPassesTestMixin.dispatch   sA    --/1,,..w9$9&99r   r2   )
r   r3   r4   r5   r6   r[   r^   r>   r7   rC   rD   s   @r   rV   rV   p   s    

: :r   rV   N)urllib.parser   django.confr   django.contrib.authr   django.contrib.auth.viewsr   django.core.exceptionsr   r   django.shortcutsr	   r   r9   rF   rV   r2   r   r   <module>ri      sG    !   3 7 I (6
 6
r: :!:k !:H:+ :r   