HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/django/contrib/auth/management/__pycache__/__init__.cpython-310.pyc
o

�a�@s�dZddlZddlZddlmZddlmZddlm	Z	ddl
mZddlm
Z
mZdd	�Zd
d�Zdd
e
efdd�Zdd�Zd
e
fdd�ZdS)zC
Creates permissions for all installed apps that need permissions.
�N)�apps)�get_permission_codename)�create_contenttypes)�
exceptions)�DEFAULT_DB_ALIAS�routercCsgt|��|j�S)zH
    Return (codename, name) for all permissions in the given opts.
    )�_get_builtin_permissions�permissions)�opts�r�I/usr/lib/python3/dist-packages/django/contrib/auth/management/__init__.py�_get_all_permissionssr
cCs2g}|jD]}|�t||�d||jff�q|S)z�
    Return (codename, name) for all autogenerated permissions.
    By default, this is ('add', 'change', 'delete', 'view')
    z	Can %s %s)�default_permissions�appendr�verbose_name_raw)r
�perms�actionrrrrs
�r�Tcs8|jsdSt|f||||d�|��|j}z|�|�}|�dd�}|�dd��Wn
ty2YdSwt�|��s;dSg}t�}	|�	�D]!}
|j
�|�j|
dd�}|	�
|�t|
j�D]	}|�||f�q[qDt�j
�|�j|	d��d	d
�����fdd�|D�}
�j
�|��|
�|d
kr�|
D]
}td|�q�dSdS)N)�	verbosity�interactive�usingr�contenttypes�ContentType�auth�
PermissionF)�for_concrete_model)�content_type__in�content_type�codenamecs0g|]\}\}}|j|f�vr�|||d��qS))r�namer)�pk)�.0�ctrr�r�	all_permsrr�
<listcomp>Ns

�z&create_permissions.<locals>.<listcomp>rzAdding permission '%s')�
models_moduler�label�get_app_config�	get_model�LookupErrorr�allow_migrate_model�set�
get_models�objects�
db_manager�
get_for_model�addr
�_metarr�filter�values_list�bulk_create�print)�
app_configrrrr�kwargs�	app_labelr�searched_perms�ctypes�klass�ctype�permrrr#r�create_permissions#sJ
�
������r?c	Cs(zt��}W|SttfyYdSw)zt
    Return the current system user's username, or an empty string if the
    username could not be determined.
    �)�getpass�getuser�ImportError�KeyError)�resultrrr�get_system_usernameYs
��rFcCs�ddlm}|jjjr
dSt�}zt�d|��dd��	d��
dd���}Wn
ty/YdSwz|jj�
d��|�WntjyGYdSw|rg|rgz|jj�|�j|d	�WdS|jjyfY|Sw|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)�modelsr@�NFKD�ascii�ignore� �username)rL)�django.contrib.authrG�Userr2�swappedrF�unicodedata�	normalize�encode�decode�replace�lower�UnicodeDecodeError�	get_field�run_validatorsr�ValidationError�_default_managerr/�get�DoesNotExist)�check_db�database�auth_app�default_usernamerrr�get_default_usernamehs8

������ra)�__doc__rArP�django.appsr�global_appsrMr�&django.contrib.contenttypes.managementr�django.corer�	django.dbrrr
rr?rFrarrrr�<module>s6