
    BhD                         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
 d dlmZmZ d dlmZ d dlmZ d d	lmZ  ee      Z G d
 de	      Z G d de
      Zy)    )Iterable)cached_property)	getLogger)ImproperlyConfigured)CMSAppConfigCMSAppExtension)cms_page_wizardcms_subpage_wizard)PageContent)render_pagecontent)Wizardc                   $    e Zd ZdZeegZeedfgZ	y)CMSCoreConfigTpageN)
__name__
__module____qualname__cms_enabledr	   r
   cms_wizardsr   r   cms_toolbar_enabled_models     >/home/dcms/DCMS/lib/python3.12/site-packages/cms/cms_config.pyr   r      s#    K"$67K#.0BF"K!Lr   r   c                   J    e Zd Zd Zd Zedeeef   fd       Z	d Z
d Zd Zy)	CMSCoreExtensionsc                 <    g | _         i | _        i | _        g | _        y N)lazy_wizardstoolbar_enabled_modelsmodel_grouperstoolbar_mixins)selfs    r   __init__zCMSCoreExtensions.__init__   s"    &(#  r   c                     t        |j                  t              st        d      | j                  j                  |j                         y)zx
        Adds all registered wizards from apps that define them to the
        wizards dictionary on this class
        zcms_wizards must be iterableN)
isinstancer   r   r   r   appendr"   
cms_configs     r   configure_wizardsz#CMSCoreExtensions.configure_wizards   s:    
 *00(;&'EFF  !7!78r   returnc                     i }| j                   D ][  }|D ci c]  }|j                  | }}t        d |j                         D        d      x}rt	        dt        |             ||z  }] |S c c}w )a  
        Returns a dictionary of wizard instances keyed by their unique IDs.
        Iterates over all iterables in `self.lazy_wizards`, filters out objects that are instances
        of the `Wizard` class, and constructs a dictionary where each key is the wizard's `id`
        and the value is the corresponding `Wizard` instance.
        Returns:
            dict: A dictionary mapping wizard IDs to `Wizard` instances.
        c              3   B   K   | ]  }t        |t              r|  y wr   )r%   r   ).0wizards     r   	<genexpr>z,CMSCoreExtensions.wizards.<locals>.<genexpr>5   s     k&PZ[aciPjvks   Nz6cms_wizards must be iterable of Wizard instances, got )r   idnextvaluesr   type)r"   wizardsiterabler.   new_wizardss        r   r4   zCMSCoreExtensions.wizards'   s     )) 	#H;CD699f,DKDkK4F4F4Hkmqrrvr*LTRX\N[  {"G	#  Es   A/c                    t        |j                  t              st        d      |j                  D ]Q  ^}}}|| j                  v rt
        j                  d| d       .|| j                  |<   |s@|d   | j                  |<   S y )Nz+cms_toolbar_enabled_models must be iterablezModel z* already registered for frontend renderingr   )r%   r   r   r   r   loggerwarningr    )r"   r(   modelrender_funcgroupers        r    configure_toolbar_enabled_modelsz2CMSCoreExtensions.configure_toolbar_enabled_models=   s    *??J&'TUU,6,Q,Q 	<(E;333UG#MN 6A++E218D''.	<r   c                     t        |j                  t              st        d      | j                  j                  |j                         y )Nzcms_toolbar_mixin must be class)
issubclasscms_toolbar_mixinobjectr   r!   r&   r'   s     r   configure_toolbar_mixinz)CMSCoreExtensions.configure_toolbar_mixinJ   s8    *66?&'HII"":#?#?@r   c                     t        |d      r| j                  |       t        |d      r| j                  |       t        |d      r| j                  |       y y )Nr   r   r@   )hasattrr)   r=   rB   r'   s     r   configure_appzCMSCoreExtensions.configure_appO   sS     :}-"":.:;<11*=:23((4 4r   N)r   r   r   r#   r)   r   dictstrr   r4   r=   rB   rE   r   r   r   r   r      s@    !9 c6k*  *<A
5r   r   N)collections.abcr   	functoolsr   loggingr   django.core.exceptionsr   cms.app_baser   r   cms.cms_wizardsr	   r
   
cms.modelsr   cms.page_renderingr   cms.wizards.wizard_baser   r   r8   r   r   r   r   r   <module>rQ      sF    $ %  7 6 ? " 1 *	8	ML MA5 A5r   