
    `fr                         d Z ddlZddl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mZ d Zd	 Zd
deefdZd ZdefdZdS )zC
Creates permissions for all installed apps that need permissions.
    N)apps)get_permission_codename)create_contenttypes)
exceptions)DEFAULT_DB_ALIASrouterc                 2    g t          |           | j        S )zH
    Return (codename, name) for all permissions in the given opts.
    )_get_builtin_permissionspermissions)optss    Y/var/www/html/env/lib/python3.11/site-packages/django/contrib/auth/management/__init__.py_get_all_permissionsr      s!     @%d++?d.>??    c                 ~    g }| j         D ]2}|                    t          ||           d|d| j        f           3|S )z
    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
      sd    
 E* 
 
'555%vvt'<'<=	
 	
 	
 	
 Lr      Tc                 8   | j         sd S t          | f||||d| | j        }	 |                    |          } |                    dd          }|                    dd          }n# t
          $ r Y d S w xY wt          j        ||          sd S g }	t                      }
| 	                                D ]t}|j
                            |                              |d          }|
                    |           t          |j                  D ]}|	                    ||f           ut          |j
                            |                              |
                              d	d
                    }g }|	D ]S\  }\  }}|j        |f|vr@ |            }||j        _        ||_        ||_        ||_        |                    |           T|j
                            |                              |           |dk    r|D ]}t7          d|z             d S d S )N)	verbosityinteractiveusingr   contenttypesContentTypeauth
PermissionF)for_concrete_model)content_type__incontent_typecodenamer   zAdding permission '%s')models_moduler   labelget_app_config	get_modelLookupErrorr   allow_migrate_modelset
get_modelsobjects
db_managerget_for_modeladdr   _metar   r   filtervalues_listpk_statedbr#   namer"   bulk_createprint)
app_configr   r   r   r   kwargs	app_labelr   r   searched_permsctypesklassctypeperm	all_permsr   ctr#   r6   
permissions                       r   create_permissionsrD   %   s    # 
       I((33
nn^]CC^^FL99

    %eZ88  NUUF&&(( 	1 	1 #..u55CCe D 
 
 	

5(55 	1 	1D!!5$-0000	1   ''	# 
 

 

 
^Z	0	0 I E . % %XtE8I--#J#(J "*J"JO&(J#LL$$$U##//666A~~ 	3 	3D*T12222 ~	3 	3s   AA& &
A43A4c                  `    	 t          j                    } n# t          t          f$ r Y dS w xY w| S )zt
    Return the current system user's username, or an empty string if the
    username could not be determined.
     )getpassgetuserImportErrorKeyError)results    r   get_system_usernamerL   r   sF    
"""    rr	
 Ms    ++c                 p   ddl m} |j        j        j        rdS t                      }	 t          j        d|                              dd          	                    d          
                    dd                                          }n# t          $ r Y dS w xY w	 |j        j                            d                              |           n# t          j        $ r Y dS w xY w| rM|rK	 |j        j                            |                              |	           dS # |j        j        $ r Y nw xY w|S )
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   )modelsrF   NFKDasciiignorer   username)rR   )django.contrib.authrN   Userr0   swappedrL   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66666 }" r*,,	!&*:;;VGX&&VG__WS"UWW 	    rr%%j11@@AQRRRR%   rr  $ 	M*55h??CC) D    2 }) 	 	 	D	 s6   A"B 
BB2C C$#C$,3D! !D32D3)__doc__rG   rV   django.appsr   global_appsrS   r   &django.contrib.contenttypes.managementr   django.corer   	django.dbr   r   r   r
   rD   rL   rg    r   r   <module>ro      s         + + + + + + 7 7 7 7 7 7 F F F F F F " " " " " " . . . . . . . .@ @ @  $ 
	J3 J3 J3 J3Z   #'1A . . . . . .r   