o
    UdhV5                     @   s   d 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 ddlmZ ddlmZ d	d
lmZmZmZ eje eeG dd dejZG dd dejZdS )z
Accounts Admin Configuration

This module configures the Django admin interface for the accounts app,
providing a professional and user-friendly interface for managing users,
roles, and user profiles.

Author: Senior Django Developer
Date: 2024
    )admin)	UserAdmin)Group)gettext_lazy)format_html)reverse)	mark_safe   )UserRoleProfilec                   @   s   e Zd ZdZg dZg dZddgZddgZeddd	ifed
ddifeddddfeddddffZ	g dZ
dgZddgZdd Zede_dd Zede_dd Zede_dd Zed e_d!S )"	RoleAdminz
    Admin configuration for Role model.
    
    Provides comprehensive management interface for roles including
    permissions management, priority settings, and user assignments.
    )namepriority	is_activepermissions_countusers_count
created_at
updated_at)r   r   r   r   r   descriptionz	-priorityzBasic Informationfields)r   r   r   Statusr   Permissions)permissions)wide)r   classesMetadata)r   r   
created_by
updated_by)collapser   activate_rolesdeactivate_rolesc                 C   s&   |j  }td|dkrd|S d|S )z
        Display the number of permissions assigned to the role.
        
        Args:
            obj: Role instance
            
        Returns:
            str: Formatted count of permissions
        z-<span style="color: {}">{} permissions</span>r   greenredN)r   countr   )selfobjr%    r(   GC:\Users\vibe-look\OneDrive\Desktop\Adtlas_V\src\apps\accounts\admin.pyr   `   s   


zRoleAdmin.permissions_countc                 C   s:   |j  }|dkrtdd|j  }td||S tdS )z
        Display the number of users assigned to the role.
        
        Args:
            obj: Role instance
            
        Returns:
            str: Formatted count of users
        r   zadmin:accounts_user_changelistz?roles__id__exact=z.<a href="{}" style="color: green">{} users</a>z'<span style="color: red">0 users</span>N)user_setr%   r   idr   )r&   r'   r%   urlr(   r(   r)   r   r   s   

zRoleAdmin.users_countUsersc                 C   &   |j dd}| |t| d dS )z
        Admin action to activate selected roles.
        
        Args:
            request: HTTP request object
            queryset: Selected role objects
        Tr   z# roles were successfully activated.Nupdatemessage_user_r&   requestquerysetupdatedr(   r(   r)   r!      
   zRoleAdmin.activate_roleszActivate selected rolesc                 C   r.   )z
        Admin action to deactivate selected roles.
        
        Args:
            request: HTTP request object
            queryset: Selected role objects
        Fr   z% roles were successfully deactivated.Nr/   r3   r(   r(   r)   r"      r7   zRoleAdmin.deactivate_roleszDeactivate selected rolesN)__name__
__module____qualname____doc__list_displaylist_filtersearch_fieldsorderingr2   	fieldsetsreadonly_fieldsfilter_horizontalactionsr   short_descriptionr   r!   r"   r(   r(   r(   r)   r      sD    	


r   c                   @   sR   e Zd ZdZeZdZdZedZ	edddifeddd	ifed
ddiffZ
dS )ProfileInlinez
    Inline admin for Profile model.
    
    This allows editing user profile information directly
    from the user admin page.
    userFzProfile InformationzPersonal Informationr   )bioavatar
birth_datezSocial Links)websitezPrivacy & Notifications)is_profile_publicemail_notificationssms_notificationsN)r8   r9   r:   r;   r   modelfk_name
can_deleter2   verbose_name_pluralr@   r(   r(   r(   r)   rE      s     rE   N)r;   Zdjango.contribr   Zdjango.contrib.auth.adminr   ZBaseUserAdmindjango.contrib.auth.modelsr   django.utils.translationr   r2   django.utils.htmlr   django.urlsr   django.utils.safestringr   modelsr
   r   r   site
unregisterregister
ModelAdminr   StackedInlinerE   r(   r(   r(   r)   <module>   s    