U
    mh                     @   s$   d Z ddlmZ G dd deZdS )a  
Adtlas Accounts App Configuration

This module configures the accounts app for the Adtlas DAI Management System.
It handles user authentication, role-based permissions, and user management.

Features:
    - Custom user model with email-based authentication
    - Dynamic role and permission system
    - User profile management
    - Activity tracking and audit logging
    - Session management and security

Author: Adtlas Development Team
Version: 2.0.0
Last Updated: 2025-07-08
    )	AppConfigc                   @   s,   e Zd ZdZdZdZdZdd Zdd Zd	S )
AccountsConfigz
    Configuration class for the accounts app.
    
    This class defines the configuration for the accounts application,
    including the app name, default auto field type, and any signals
    or initialization code.
    zdjango.db.models.BigAutoFieldzapps.accountszUser Accounts & Authenticationc                 C   s2   zddl m} W n tk
r$   Y nX |   dS )z
        Initialize the app when Django starts.
        
        This method is called when the app is ready and can be used
        to register signals, perform initialization, or set up
        any app-specific configurations.
           )signalsN) r   ImportErrorcreate_default_roles)selfr    r
   ./var/www/html/Adtlas/src/apps/accounts/apps.pyready$   s
    	zAccountsConfig.readyc           	      C   s   zddl m} ddlm} ddlm} dddd	dd
dddddd	dd
dddddd	dd
dddddd	dd
dddddd	dd
d
dg}|D ]0}|jj|d |d\}}|rtd|j	  qW n" t
k
r } zW 5 d }~X Y nX d S )!z
        Create default system roles if they don"t exist.
        
        This method creates the basic role structure needed for
        the application to function properly.
        r   )
Permission)ContentTyper   )RolezSuper AdministratorZsuper_adminz'Full system access with all permissionssystemTF)namecodedescriptionZ	role_typelevel	is_activeZ
is_defaultZAdministratoradminz&Administrative access to most features   Managermanagerz,Management access to campaigns and analytics   Operatoroperatorz/Operational access to create and manage content   ZViewerZviewerz)Read-only access to view data and reports   r   )r   defaultszCreated default role: N)django.contrib.auth.modelsr   "django.contrib.contenttypes.modelsr   modelsr   objectsget_or_createprintr   	Exception)	r	   r   r   r   Zdefault_rolesZ	role_datarolecreateder
   r
   r   r   5   sl    



1
z#AccountsConfig.create_default_rolesN)	__name__
__module____qualname____doc__default_auto_fieldr   verbose_namer   r   r
   r
   r
   r   r      s   r   N)r-   django.appsr   r   r
   r
   r
   r   <module>   s   