
    h|@                        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KJr  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  S SKJr  SSKJr  S r " S S\R:                  5      r " S S\R>                  5      r  " S S\R:                  5      r! " S S\R>                  5      r" " S S\5      r#S r$S r%S r& " S S\R>                  5      r' " S S \\'5      r( " S! S"\(5      r) " S# S$5      r*g%)&    )Iterable)apps)auth)AbstractBaseUserBaseUserManager)make_password)ContentType)PermissionDenied)	send_mail)models)EmptyManager)timezone)gettext_lazy   )UnicodeUsernameValidatorc                 X    [         R                  " 5       Ul        UR                  S/S9  g)zN
A signal receiver which updates the last_login date for
the user logging in.

last_login)update_fieldsN)r   nowr   save)senderuserkwargss      L/var/www/html/env/lib/python3.13/site-packages/django/contrib/auth/models.pyupdate_last_loginr      s!    
 llnDOII\NI+    c                       \ rS rSrSrS rSrg)PermissionManager   Tc                     U R                  U[        R                  R                  U R                  5      R                  X#5      S9$ )N)codenamecontent_type)getr	   objects
db_managerdbget_by_natural_key)selfr!   	app_labelmodels       r   r'   $PermissionManager.get_by_natural_key   sA    xx$,,77@SS  
 	
r    N)__name__
__module____qualname____firstlineno__use_in_migrationsr'   __static_attributes__r,   r   r   r   r      s    
r   r   c                       \ rS rSrSr\R                  " \" S5      SS9r\R                  " \
\R                  \" S5      S9r\R                  " \" S5      S	S9r\" 5       r " S
 S5      rS rS rS/\l        Srg)
Permission'   a  
The permissions system provides a way to assign permissions to specific
users and groups of users.

The permission system is used by the Django admin site, but may also be
useful in your own code. The Django admin site uses permissions as follows:

    - The "add" permission limits the user's ability to view the "add" form
      and add an object.
    - The "change" permission limits a user's ability to view the change
      list, view the "change" form and change an object.
    - The "delete" permission limits the ability to delete an object.
    - The "view" permission limits the ability to view an object.

Permissions are set globally per type of object, not per specific object
instance. It is possible to say "Mary may change news stories," but it's
not currently possible to say "Mary may change news stories, but only the
ones she created herself" or "Mary may only change news stories that have a
certain status or publication date."

The permissions listed above are automatically created for each model.
name   )
max_lengthzcontent type)verbose_namer!   d   c                   F    \ rS rSr\" S5      r\" S5      rSS//r/ SQrSr	g)	Permission.MetaI   
permissionpermissionsr"   r!   )content_type__app_labelcontent_type__modelr!   r,   N)
r-   r.   r/   r0   _r9   verbose_name_pluralunique_togetherorderingr2   r,   r   r   Metar<   I   s(    .*J78Qr   rF   c                 <    U R                   < SU R                  < 3$ )Nz | )r"   r6   r(   s    r   __str__Permission.__str__O   s     --tyy99r   c                 R    U R                   4U R                  R                  5       -   $ N)r!   r"   natural_keyrH   s    r   rM   Permission.natural_keyR   s#    $"3"3"?"?"AAAr   zcontenttypes.contenttyper,   N)r-   r.   r/   r0   __doc__r   	CharFieldrB   r6   
ForeignKeyr	   CASCADEr"   r!   r   r$   rF   rI   rM   dependenciesr2   r,   r   r   r4   r4   '   s    . AfI#6D$$~&L
 *#>H!GR R:B !;;Kr   r4   c                   "    \ rS rSrSrSrS rSrg)GroupManagerX   z)
The manager for the auth's Group model.
Tc                      U R                  US9$ )Nr6   )r#   )r(   r6   s     r   r'   GroupManager.get_by_natural_key_   s    xxTx""r   r,   N)r-   r.   r/   r0   rO   r1   r'   r2   r,   r   r   rU   rU   X   s     #r   rU   c                       \ rS rSrSr\R                  " \" S5      SSS9r\R                  " \
\" S5      SS9r\" 5       r " S	 S
5      rS rS rSrg)Groupc   a  
Groups are a generic way of categorizing users to apply permissions, or
some other label, to those users. A user can belong to any number of
groups.

A user in a group automatically has all the permissions granted to that
group. For example, if the group 'Site editors' has the permission
can_edit_home_page, any user in that group will have that permission.

Beyond permissions, groups are a convenient way to categorize users to
apply some label, or extended functionality, to them. For example, you
could create a group 'Special users', and you could write code that would
do special things to those users -- such as giving them access to a
members-only portion of your site, or sending them members-only email
messages.
r6      T)r8   uniquer?   )r9   blankc                   4    \ rS rSr\" S5      r\" S5      rSrg)
Group.Meta~   groupgroupsr,   N)r-   r.   r/   r0   rB   r9   rC   r2   r,   r   r   rF   ra   ~   s    zkr   rF   c                     U R                   $ rL   rX   rH   s    r   rI   Group.__str__   s    yyr   c                     U R                   4$ rL   rX   rH   s    r   rM   Group.natural_key   s    		|r   r,   N)r-   r.   r/   r0   rO   r   rP   rB   r6   ManyToManyFieldr4   r?   rU   r$   rF   rI   rM   r2   r,   r   r   r[   r[   c   s\    " AfI#dCD((}%K nG* *r   r[   c                   >    \ rS rSrSrS rS	S jrS	S jr S
S jrSr	g)UserManager   Tc                    U(       d  [        S5      eU R                  U5      n[        R                  " U R                  R
                  R                  U R                  R
                  R                  5      nUR                  U5      nU R                  " SXS.UD6n[        U5      Ul
        UR                  U R                  S9  U$ )zF
Create and save a user with the given username, email, and password.
zThe given username must be set)usernameemail)usingr,   )
ValueErrornormalize_emailr   	get_modelr*   _metar)   object_namenormalize_usernamer   passwordr   _db)r(   rn   ro   rw   extra_fieldsGlobalUserModelr   s          r   _create_userUserManager._create_user   s     =>>$$U+ ..JJ&&

(8(8(D(D
 #55h?zzI8ILI%h/			!r   Nc                 r    UR                  SS5        UR                  SS5        U R                  " XU40 UD6$ )Nis_staffFis_superuser)
setdefaultr{   r(   rn   ro   rw   ry   s        r   create_userUserManager.create_user   s:    
E26  (KlKKr   c                     UR                  SS5        UR                  SS5        UR                  S5      SLa  [        S5      eUR                  S5      SLa  [        S5      eU R                  " XU40 UD6$ )Nr~   Tr   z"Superuser must have is_staff=True.z&Superuser must have is_superuser=True.)r   r#   rq   r{   r   s        r   create_superuserUserManager.create_superuser   sx    
D15J't3ABBN+47EFF  (KlKKr   c                 L   Uc6  [         R                  " SS9n[        U5      S:X  a  US   u  pGOD[        S5      e[	        U[
        5      (       d  [        SU-  5      e[         R                  " U5      n[        US5      (       a  UR                  UUUUS9$ U R                  5       $ )	NT)return_tuplesr   r   zgYou have multiple authentication backends configured and therefore must provide the `backend` argument.z5backend must be a dotted import path string (got %r).	with_perm)	is_activeinclude_superusersobj)r   _get_backendslenrq   
isinstancestr	TypeErrorload_backendhasattrr   none)r(   permr   r   backendr   backendsrB   s           r   r   UserManager.with_perm   s     ?))=H8}!%a[
 E  GS))G'Q  ''0G7K(($$##5	 %   yy{r   r,   )NN)TTNN)
r-   r.   r/   r0   r1   r{   r   r   r   r2   r,   r   r   rk   rk      s%    &L
	L PTr   rk   c                     [        5       nSU-  n[        R                  " 5        H5  n[        XT5      (       d  M  UR	                  [        XT5      " X5      5        M7     U$ )Nzget_%s_permissions)setr   get_backendsr   updategetattr)r   r   	from_namer?   r6   r   s         r   _user_get_permissionsr      sQ    %K)+D$$&7!!ww5d@A ' r   c                     [         R                  " 5        H0  n[        US5      (       d  M   UR                  XU5      (       a    gM2     g! [         a       gf = f)N
A backend can raise `PermissionDenied` to short-circuit permission checking.
has_permTF)r   r   r   r   r
   )r   r   r   r   s       r   _user_has_permr      s`     $$&w
++	C00 1	 '    		s   A
AAc                     [         R                  " 5        H/  n[        US5      (       d  M   UR                  X5      (       a    gM1     g! [         a       gf = f)r   has_module_permsTF)r   r   r   r   r
   )r   r)   r   s      r   _user_has_module_permsr      s_     $$&w 233	''88 9	 '    		s   A


AAc            	       $   \ rS rSrSr\R                  " \" S5      S\" S5      S9r\R                  " \
\" S5      S\" S	5      S
SS9r\R                  " \\" S5      S\" S5      S
SS9r " S S5      rSS jrSS jrSS jrSS jrSS jrS rSrg)PermissionsMixin   zi
Add the fields and methods necessary to support the Group and Permission
models using the ModelBackend.
zsuperuser statusFzPDesignates that this user has all permissions without explicitly assigning them.default	help_textrd   TzaThe groups this user belongs to. A user will get all permissions granted to each of their groups.user_setr   )r9   r_   r   related_namerelated_query_namezuser permissionsz#Specific permissions for this user.c                       \ rS rSrSrSrg)PermissionsMixin.Metai  Tr,   N)r-   r.   r/   r0   abstractr2   r,   r   r   rF   r     s    r   rF   Nc                     [        XS5      $ )z
Return a list of permission strings that this user has directly.
Query all available auth backends. If an object is passed in,
return only permissions matching this object.
r   r   r(   r   s     r   get_user_permissions%PermissionsMixin.get_user_permissions  s     %T77r   c                     [        XS5      $ )z
Return a list of permission strings that this user has through their
groups. Query all available auth backends. If an object is passed in,
return only permissions matching this object.
rc   r   r   s     r   get_group_permissions&PermissionsMixin.get_group_permissions   s     %T88r   c                     [        XS5      $ Nallr   r   s     r   get_all_permissions$PermissionsMixin.get_all_permissions(      $T66r   c                 `    U R                   (       a  U R                  (       a  g[        XU5      $ )a0  
Return True if the user has the specified permission. Query all
available auth backends, but return immediately if any backend returns
True. Thus, a user who has permission from a single auth backend is
assumed to have permission in general. If an object is provided, check
permissions for that object.
T)r   r   r   r(   r   r   s      r   r   PermissionsMixin.has_perm+  s%     >>d// d#..r   c                    ^ ^ [        U[        5      (       a  [        U[        5      (       a  [        S5      e[	        UU 4S jU 5       5      $ )z
Return True if the user has each of the specified permissions. If
object is passed, check if the user has all required perms for it.
-perm_list must be an iterable of permissions.c              3   H   >#    U  H  nTR                  UT5      v   M     g 7frL   r   .0r   r   r(   s     r   	<genexpr>-PermissionsMixin.has_perms.<locals>.<genexpr>A       B	4==s++	   "r   r   r   rq   r   r(   	perm_listr   s   ` `r   	has_permsPermissionsMixin.has_perms:  s;    
 )X..*Y2L2LLMMB	BBBr   c                 ^    U R                   (       a  U R                  (       a  g[        X5      $ )zm
Return True if the user has any permissions in the given app label.
Use similar logic as has_perm(), above.
T)r   r   r   )r(   r)   s     r   r   !PermissionsMixin.has_module_permsC  s!     >>d//%d66r   r,   rL   )r-   r.   r/   r0   rO   r   BooleanFieldrB   r   ri   r[   rd   r4   user_permissionsrF   r   r   r   r   r   r   r2   r,   r   r   r   r      s    
 &&	
)
L ##x[/
  !
F --)*9:! 897/C	7r   r   c                     ^  \ rS rSrSr\" 5       r\R                  " \	" S5      SS\	" S5      \/S\	" S5      0S	9r
\R                  " \	" S
5      SSS9r\R                  " \	" S5      SSS9r\R                  " \	" S5      SS9r\R                  " \	" S5      S\	" S5      S9r\R                  " \	" S5      S\	" S5      S9r\R$                  " \	" S5      \R(                  S9r\" 5       rSrSrS/r " S S5      rU 4S jrS rS rSS jrSr U =r!$ ) AbstractUseriO  z
An abstract base class implementing a fully featured User model with
admin-compliant permissions.

Username and password are required. Other fields are optional.
rn   r]   TzFRequired. 150 characters or fewer. Letters, digits and @/./+/-/_ only.r^   z)A user with that username already exists.)r8   r^   r   
validatorserror_messagesz
first name)r8   r_   z	last namezemail address)r_   zstaff statusFz9Designates whether the user can log into this admin site.r   activezeDesignates whether this user should be treated as active. Unselect this instead of deleting accounts.zdate joined)r   ro   c                   8    \ rS rSr\" S5      r\" S5      rSrSrg)AbstractUser.Metai}  r   usersTr,   N)	r-   r.   r/   r0   rB   r9   rC   r   r2   r,   r   r   rF   r   }  s    yjr   rF   c                    > [         TU ]  5         U R                  R                  R	                  U R
                  5      U l        g rL   )superclean	__class__r$   rr   ro   )r(   r   s    r   r   AbstractUser.clean  s,    ^^++;;DJJG
r   c                 \    U R                   < SU R                  < 3nUR                  5       $ )zD
Return the first_name plus the last_name, with a space in between.
 )
first_name	last_namestrip)r(   	full_names     r   get_full_nameAbstractUser.get_full_name  s#      $?	  r   c                     U R                   $ )z#Return the short name for the user.)r   rH   s    r   get_short_nameAbstractUser.get_short_name  s    r   c                 4    [        XX0R                  /40 UD6  g)zSend an email to this user.N)r   ro   )r(   subjectmessage
from_emailr   s        r   
email_userAbstractUser.email_user  s    'JGGr   )ro   rL   )"r-   r.   r/   r0   rO   r   username_validatorr   rP   rB   rn   r   r   
EmailFieldro   r   r~   r   DateTimeFieldr   r   date_joinedrk   r$   EMAIL_FIELDUSERNAME_FIELDREQUIRED_FIELDSrF   r   r   r   r   r2   __classcell__)r   s   @r   r   r   O  sD    23	*T
 ''aCD
H !!!L/cNJ  ;CtLIa0=E""	.OPH
 ##	(:
I &&q'7NKmGKNiO 
H!H Hr   r   c                   B    \ rS rSrSr " S S\R                  5      rSrg)Useri  z
Users within the Django authentication system are represented by this
model.

Username and password are required. Other fields are optional.
c                       \ rS rSrSrSrg)	User.Metai  AUTH_USER_MODELr,   N)r-   r.   r/   r0   	swappabler2   r,   r   r   rF   r     s    %	r   rF   r,   N)r-   r.   r/   r0   rO   r   rF   r2   r,   r   r   r   r     s    &|   &r   r   c                       \ rS rSrSrSrSrSrSrSr	\
" \5      r\
" \5      rS rS rS rS rS	 rS
 rS rS r\S 5       r\S 5       rSS jrSS jrSS jrSS jrSS jrS r\S 5       r \S 5       r!S r"Sr#g)AnonymousUseri  N Fc                     g)Nr  r,   rH   s    r   rI   AnonymousUser.__str__  s    r   c                 ,    [        XR                  5      $ rL   )r   r   )r(   others     r   __eq__AnonymousUser.__eq__  s    %00r   c                     g)Nr   r,   rH   s    r   __hash__AnonymousUser.__hash__  s    r   c                     [        S5      e)NzLCannot cast AnonymousUser to int. Are you trying to use it in place of User?)r   rH   s    r   __int__AnonymousUser.__int__  s    
 	
r   c                     [        S5      eNz=Django doesn't provide a DB representation for AnonymousUser.NotImplementedErrorrH   s    r   r   AnonymousUser.save      !K
 	
r   c                     [        S5      er  r  rH   s    r   deleteAnonymousUser.delete  r  r   c                     [        S5      er  r  r(   raw_passwords     r   set_passwordAnonymousUser.set_password  r  r   c                     [        S5      er  r  r  s     r   check_passwordAnonymousUser.check_password  r  r   c                     U R                   $ rL   )_groupsrH   s    r   rd   AnonymousUser.groups  s    ||r   c                     U R                   $ rL   )_user_permissionsrH   s    r   r   AnonymousUser.user_permissions  s    %%%r   c                     [        XS5      $ )Nr   r   r   s     r   r   "AnonymousUser.get_user_permissions  s    $T77r   c                     [        5       $ rL   )r   r   s     r   r   #AnonymousUser.get_group_permissions  s	    ur   c                     [        XS5      $ r   r   r   s     r   r   !AnonymousUser.get_all_permissions  r   r   c                     [        XUS9$ )N)r   )r   r   s      r   r   AnonymousUser.has_perm  s    dc22r   c                    ^ ^ [        U[        5      (       a  [        U[        5      (       a  [        S5      e[	        UU 4S jU 5       5      $ )Nr   c              3   H   >#    U  H  nTR                  UT5      v   M     g 7frL   r   r   s     r   r   *AnonymousUser.has_perms.<locals>.<genexpr>  r   r   r   r   s   ` `r   r   AnonymousUser.has_perms  s9    )X..*Y2L2LLMMB	BBBr   c                     [        X5      $ rL   )r   )r(   modules     r   r   AnonymousUser.has_module_perms  s    %d33r   c                     g)NTr,   rH   s    r   is_anonymousAnonymousUser.is_anonymous  s    r   c                     g)NFr,   rH   s    r   is_authenticatedAnonymousUser.is_authenticated  s    r   c                     U R                   $ rL   )rn   rH   s    r   get_usernameAnonymousUser.get_username  s    }}r   r,   rL   )$r-   r.   r/   r0   idpkrn   r~   r   r   r   r[   r$  r4   r'  rI   r
  r  r  r   r  r  r!  propertyrd   r   r   r   r   r   r   r   r9  r<  r?  r2   r,   r   r   r  r    s    	B	BHHIL5!G$Z01








   & &873C
4    r   r  N)+collections.abcr   django.appsr   django.contribr   django.contrib.auth.base_userr   r   django.contrib.auth.hashersr   "django.contrib.contenttypes.modelsr	   django.core.exceptionsr
   django.core.mailr   	django.dbr   django.db.models.managerr   django.utilsr   django.utils.translationr   rB   r   r   r   Managerr   Modelr4   rU   r[   rk   r   r   r   r   r   r   r  r,   r   r   <module>rR     s    $   K 5 : 3 &  1 ! 6 0,	
 	
.< .<b#6>> ##FLL #L?/ ?FY7v|| Y7xDH#%5 DHN	&< 	&R Rr   