
    &g#                         d Z ddlmZ ddlZddlmZmZ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d	lmZmZ  G d
 de      Z G d de      Zy)aQ  
Custom dashboards for Django applications.

This package defines the following classes:

* :class:`FluentIndexDashboard`
* :class:`FluentAppIndexDashboard`

These classes need to be linked in ``settings.py`` to be loaded by `django-admin-tools`.
Off course, you can also extend the classes, and use those names in the settings instead.
    )LooseVersionN)AppIndexDashboard	Dashboardmodules)Group)settings)gettext_lazy)get_application_groups	get_class)CacheStatusGroupPersonalModulec                   Z     e Zd ZdZ G d d      Z fdZd Zd Zd Zd Z	d	 Z
d
 Z xZS )FluentIndexDashboarda  
    A custom home screen for the Django admin interface.

    It displays the application groups based on with :ref:`FLUENT_DASHBOARD_APP_GROUPS` setting.
    To activate the dashboard add the following to your settings.py::

        ADMIN_TOOLS_INDEX_DASHBOARD = 'fluent_dashboard.dashboard.FluentIndexDashboard'

    The dashboard modules are instantiated by the following functions, which can be overwritten:

    * :func:`get_personal_module`
    * :func:`get_application_modules`
    * :func:`get_recent_actions_module`
    * :func:`get_rss_modules`
    * :func:`get_cache_status_modules`

    To have a menu which is consistent with the application groups displayed by this module,
    use the :class:`~fluent_dashboard.menu.FluentMenu` class to render the `admin_tools` menu.

    When overwriting this class, the elements can either be added in
    the :func:`__init__` method, or the :func:`init_with_context` method.
    For more information, see the `django-admin-tools` documentation.
    c                   P    e Zd Z eej
                         ed      k  rdZyddiZy)FluentIndexDashboard.Mediaz0.6)zfluent_dashboard/dashboard.cssallN)__name__
__module____qualname__r   admin_toolsVERSIONcss     S/var/www/html/djangosite/lib/python3.12/site-packages/fluent_dashboard/dashboard.pyMediar   1   s*    ++,|E/BB5C=>Cr   r   c                    t        |   di | | j                  j                  | j	                                | j                  j                  | j                                | j                  j                  | j                                y )Nr   )super__init__childrenappendget_personal_moduleextendget_application_modulesget_recent_actions_module)selfkwargs	__class__s     r   r   zFluentIndexDashboard.__init__8   sd    "6"T5578T99;<T;;=>r   c                     |d   }dt         j                  v rT| j                  j                  | j	                                | j                  j                  | j                  |             y y )Nrequestdashboardmods)r   INSTALLED_APPSr    r#   get_rss_modulesget_cache_status_modules)r&   contextr*   s      r   init_with_contextz&FluentIndexDashboard.init_with_context>   sW    )$h555MM  !5!5!78MM  !>!>w!GH 6r   c                      t        dddd      S )zm
        Instantiate the :class:`~fluent_dashboard.modules.PersonalModule` for use in the dashboard.
        inlineF)layout	draggable	deletablecollapsible)r   r&   s    r   r"   z(FluentIndexDashboard.get_personal_moduleD   s     X%]bccr   c                     g }t               }|D ]8  \  }}t        |j                  d            } |j                   ||fi |       : |S )a  
        Instantiate all application modules (i.e.
         :class:`~admin_tools.dashboard.modules.AppList`,
         :class:`~fluent_dashboard.modules.AppIconList` and
         :class:`~fluent_dashboard.modules.CmsAppIconList`)
         for use in the dashboard.
        module)r
   r   popr!   )r&   r   	appgroupstitler'   AppListClasss         r   r$   z,FluentIndexDashboard.get_application_modulesJ   s[     *,	& 	:ME6$

8$L GNN<889		:
 r   c                 F    t        j                  t        d      ddd      S )zx
        Instantiate the :class:`~admin_tools.dashboard.modules.RecentActions` module for use in the dashboard.
        Recent Actions   F)enabledr6   )r   RecentActions_r7   s    r   r%   z.FluentIndexDashboard.get_recent_actions_module[   s"     $$Q'7%8!UX]^^r   c                 H    |j                   j                  sg S t               gS )aT  
        Instantiate the :class:`~fluent_dashboard.modules.CacheStatusGroup` module for use in the dashboard.

        This module displays the status of Varnish and Memcache,
        if the :ref:`dashboardmods` package is installed and the caches are configured.
        By default, these modules are only shown for the superuser.
        )useris_superuserr   )r&   r*   s     r   r.   z-FluentIndexDashboard.get_cache_status_modulesa   s"     ||((I "##r   c                 R    dt         j                  vrg S ddl}|j                         S )z
        Instantiate the RSS modules for use in the dashboard.
        This module displays the RSS feeds of the :ref:`dashboardmods` package, if it is installed, and configured.
        r+   r   N)r   r,   r+   get_rss_dash_modules)r&   r+   s     r   r-   z$FluentIndexDashboard.get_rss_modulesn   s)    
 ("9"99I1133r   )r   r   r   __doc__r   r   r0   r"   r$   r%   r.   r-   __classcell__r(   s   @r   r   r      s8    0? ??Id"_$	4r   r   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )FluentAppIndexDashboarda  
    A custom application index page for the Django admin interface.

    This dashboard is displayed when one specific application is opened via the breadcrumb.
    It displays the models and recent actions of the specific application.
    To activate the dashboards add the following to your settings.py::

        ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'fluent_dashboard.dashboard.FluentAppIndexDashboard'
     c                     t        |   ||fi | | xj                  | j                         | j	                         fz  c_        y )N)r   r   r    get_model_list_moduler%   )r&   	app_titlemodelsr'   r(   s       r   r   z FluentAppIndexDashboard.__init__   sB    F5f5&&(**,
 	
r   c                 V    t        j                  | j                  | j                        S )z
        Instantiate a standard :class:`~admin_tools.dashboard.modules.ModelList` class
        to display the models of this application.
        )r   	ModelListrQ   rR   r7   s    r   rP   z-FluentAppIndexDashboard.get_model_list_module   s    
   ==r   c                 d    t        j                  t        d      | j                         ddd      S )z
        Instantiate the :class:`~admin_tools.dashboard.modules.RecentActions` module
        for use in the appliation index page.
        r?   r@   F)include_listlimitrA   r6   )r   rB   rC   get_app_content_typesr7   s    r   r%   z1FluentAppIndexDashboard.get_recent_actions_module   s5    
 $$335
 	
r   )	r   r   r   rI   r<   r   rP   r%   rJ   rK   s   @r   rM   rM   z   s     E
>
r   rM   )rI   distutils.versionr   r   admin_tools.dashboardr   r   r   admin_tools.dashboard.modulesr   django.confr   django.utils.translationr	   rC   fluent_dashboard.appgroupsr
   r   fluent_dashboard.modulesr   r   r   rM   r   r   r   <module>r`      sC   
 +  G G /   6 H E_49 _4D'
/ '
r   