
    h                         S r SSKrSSK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Jr  S rS	 rS
S\\4S jrS rS\4S jrg)zC
Creates permissions for all installed apps that need permissions.
    N)apps)get_permission_codename)create_contenttypes)
exceptions)DEFAULT_DB_ALIASrouterc                 4    / [        U 5      QU R                  Q$ )z@
Return (codename, name) for all permissions in the given opts.
)_get_builtin_permissionspermissions)optss    Y/var/www/html/env/lib/python3.13/site-packages/django/contrib/auth/management/__init__.py_get_all_permissionsr      s!     @%d+?d.>.>??    c                     / nU R                    H1  nUR                  [        X 5      SU< SU R                  < 345        M3     U$ )zt
Return (codename, name) for all autogenerated permissions.
By default, this is ('add', 'change', 'delete', 'view')
zCan  )default_permissionsappendr   verbose_name_raw)r   permsactions      r   r
   r
      sG    
 E**'5%t'<'<=	
 + Lr      Tc                    U R                   (       d  g  UR                  SS5      n[        R                  " X65      (       d  g [        U 4UUUUS.UD6  U R                  n UR                  U5      n UR                  SS5      n[        U R                  5       5      n	UR                  R                  U5      R                  " U	SS06n
[        UR                  R                  U5      R                  [        U
R!                  5       5      S9R#                  S	S
5      5      n/ nU	 Hx  nX   n[%        UR&                  5       HX  u  nnUR(                  U4U;  d  M  U" 5       nUUR*                  l        UUl        UUl        UUl        UR5                  U5        MZ     Mz     UR                  R                  U5      R7                  U5        US:  a  U H  n[9        SU-  5        M     g g ! [         a     g f = f! [         a     g f = f)Nauth
Permission)	verbosityinteractiveusingr   contenttypesContentTypefor_concrete_modelsF)content_type__incontent_typecodenamer   zAdding permission '%s')models_module	get_modelLookupErrorr   allow_migrate_modelr   labelget_app_configlist
get_modelsobjects
db_managerget_for_modelssetr   filtervaluesvalues_listr   _metapk_statedbr#   namer"   r   bulk_createprint)
app_configr   r   r   r   kwargsr   	app_labelr   modelsctypes	all_permsr   modelctyper#   r7   
permissionperms                      r   create_permissionsrD   &   s	    ##^^FL9
 %%e88
     I((3
nn^]C *'')*F   ++E2AA	%*F   '	 1 
 

 
^Z	0I E25;;?NHd(#94'\
',
!!$&.
#"&
*/
'Z( @  U#//6A~D*T12  o  *  s#   G(  #G8 (
G54G58
HHc                  h     [         R                  " 5       n U $ ! [        [        [        4 a     gf = f)zh
Return the current system user's username, or an empty string if the
username could not be determined.
 )getpassgetuserImportErrorKeyErrorOSError)results    r   get_system_usernamerM   o   s7    
" M 7+  s    11c                    SSK Jn  UR                  R                  R                  (       a  g[        5       n [        R                  " SU5      R                  SS5      R                  S5      R                  SS5      R                  5       n UR                  R                  R                  S5      R                  U5        U (       a;  U(       a4   UR                  R"                  R%                  U5      R'                  US	9  gU$ ! [         a     gf = f! [        R                    a     gf = f! UR                  R(                   a     U$ f = f)
a  
Try to determine the current system user's username to use as a default.

:param check_db: If ``True``, requires that the username does not match an
    existing ``auth.User`` (otherwise returns an empty string).
:param database: The database where the unique check will be performed.
:returns: The username, or an empty string if no username can be
    determined or the suggested username is already taken.
r   )r=   rF   NFKDasciiignorer   username)rR   )django.contrib.authr=   Userr3   swappedrM   unicodedata	normalizeencodedecodereplacelowerUnicodeDecodeError	get_fieldrun_validatorsr   ValidationError_default_managerr-   getDoesNotExist)check_dbdatabaseauth_appdefault_usernames       r   get_default_usernamerg      s*    7 }}""*,	!!&*:;VGX&VG_WS"UW 	%%j1@@AQR
 $	MM**55h?CC) D  '   %%  }})) 	 		s6   AD 4D 2D/ 
DDD,+D,/EE)__doc__rG   rV   django.appsr   global_appsrS   r   &django.contrib.contenttypes.managementr   django.corer   	django.dbr   r   r   r
   rD   rM   rg    r   r   <module>ro      sS      + 7 F " .@$ 
	F3R" #'1A .r   