o
    ["<f                     @   sh   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 G dd dejd	ZG d
d deZdS )z7
Module where grappelli dashboard classes are defined.
    )forms)reverse)gettext_lazy)modules)get_admin_site_namec                   @   s<   e Zd ZdZed ZdZdZdZdd Z	dd Z
d	d
 ZdS )	Dashboarda  
    Base class for dashboards.
    The Dashboard class is a simple python list that has three additional
    properties:

    ``title``
        The dashboard title, by default, it is displayed above the dashboard
        in a ``h2`` tag. Default value: 'Dashboard'.

    ``template``
        The template to use to render the dashboard.
        Default value: 'admin_tools/dashboard/dashboard.html'

    ``columns``
        An integer that represents the number of columns for the dashboard.
        Default value: 2.

    If you want to customize the look of your dashboard and it's modules, you
    can declare css stylesheets and/or javascript files to include when
    rendering the dashboard (these files should be placed in your
    media path), for example::

        from admin_tools.dashboard import Dashboard

        class MyDashboard(Dashboard):
            class Media:
                css = {
                    'all': (
                        'css/mydashboard.css',
                        'css/mystyles.css',
                    ),
                }
                js = (
                    'js/mydashboard.js',
                    'js/myscript.js',
                )

    Here's an example of a custom dashboard::

        from django.urls import reverse
        from django.utils.translation import gettext_lazy as _
        from admin_tools.dashboard import modules, Dashboard

        class MyDashboard(Dashboard):

            # we want a 3 columns layout
            columns = 3

            def __init__(self, **kwargs):
                super(MyDashboard, self).__init__(**kwargs)

                # append an app list module for "Applications"
                self.children.append(modules.AppList(
                    title=_('Applications'),
                    exclude=('django.contrib.*',),
                ))

                # append an app list module for "Administration"
                self.children.append(modules.AppList(
                    title=_('Administration'),
                    models=('django.contrib.*',),
                ))

                # append a recent actions module
                self.children.append(modules.RecentActions(
                    title=_('Recent actions'),
                    limit=5
                ))

    z"grappelli/dashboard/dashboard.html   Nc                 K   s6   |D ]}t | j|rt| |||  q| jpg | _d S )N)hasattr	__class__setattrchildren)selfkwargskey r   U/var/www/html/kck/venv/lib/python3.10/site-packages/grappelli/dashboard/dashboards.py__init__\   s
   zDashboard.__init__c                 C      dS )a  
        Sometimes you may need to access context or request variables to build
        your dashboard, this is what the ``init_with_context()`` method is for.
        This method is called just before the display with a
        ``django.template.RequestContext`` as unique argument, so you can
        access to all context variables and to the ``django.http.HttpRequest``.
        Nr   )r   contextr   r   r   init_with_contextb   s   zDashboard.init_with_contextc                 C   r   )zV
        Internal method used to distinguish different dashboards in js code.
        zgrp-dashboardr   )r   r   r   r   get_idl   s   zDashboard.get_id)__name__
__module____qualname____doc___titletemplatecolumnsr   r   r   r   r   r   r   r   r      s    G
r   )	metaclassc                   @   s   e Zd ZdZdd ZdS )DefaultIndexDashboardad  
    The default dashboard displayed on the admin index page.
    To change the default dashboard you'll have to type the following from the
    commandline in your project root directory::

        python manage.py customdashboard

    And then set the `GRAPPELLI_INDEX_DASHBOARD`` settings variable to
    point to your custom index dashboard class.
    c                 C   s  t |}| jtjtddtddgtdtd| gtdtd| ggd	 | jtjtd
dd | jtjtddd | jttdd | jtj	tdddd | jtjtdtdddddtdddddtddddgd d S ) NzQuick linksFzReturn to site/zChange passwordz%s:password_changezLog outz	%s:logout)collapsibler   Applications)zdjango.contrib.*)excludeAdministration)modelszRecent actions   zLatest Django Newsz(http://www.djangoproject.com/rss/weblog/)feed_urllimitSupportzDjango documentationzhttp://docs.djangoproject.com/T_blank)r   urlexternaltargetz"Django "django-users" mailing listz+http://groups.google.com/group/django-userszDjango irc channelzirc://irc.freenode.net/django)r   r,   r-   )r   )
r   r   appendr   LinkListr   r   AppListRecentActionsFeed)r   r   	site_namer   r   r   r      sV   






z'DefaultIndexDashboard.init_with_contextN)r   r   r   r   r   r   r   r   r   r    s   s    r    N)r   djangor   django.urlsr   django.utils.translationr   r   grappelli.dashboardr   grappelli.dashboard.utilsr   MediaDefiningClassr   r    r   r   r   r   <module>   s   d