
    Bh                     V    d dl Z d dlmZ d dlmZ d Z G d d      Zd Zd Zd	 Z	d
 Z
y)    N)	force_str)get_current_timezone_namec                      y)Npage )objs    A/home/dcms/DCMS/lib/python3.12/site-packages/cms/utils/helpers.pyfind_placeholder_relationr
      s        c                       e Zd ZdZd Zd Zy)classpropertya  Like @property, but for classes, not just instances.

    Example usage:

        >>> from cms.utils.helpers import classproperty
        >>> class A():
        ...     @classproperty
        ...     def x(cls):
        ...         return 'x'
        ...     @property
        ...     def y(self):
        ...         return 'y'
        ...
        >>> A.x
        'x'
        >>> A().x
        'x'
        >>> A.y
        <property object at 0x2939628>
        >>> A().y
        'y'

    c                     || _         y Nfget)selfr   s     r	   __init__zclassproperty.__init__#   s	    	r   c                 $    | j                  |      S r   r   )r   
owner_self	owner_clss      r	   __get__zclassproperty.__get__&   s    yy##r   N)__name__
__module____qualname____doc__r   r   r   r   r	   r   r      s    .$r   r   c                 n    t        j                  dd|       }|j                         j                  d      S )a  
    Converts camel-case style names into underscore separated words. Example::

        >>> normalize_name('oneTwoThree')
        'one_two_three'
        >>> normalize_name('FourFiveSix')
        'four_five_six'

    taken from django.contrib.formtools
    z&(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))z_\1_)resublowerstrip)namenews     r	   normalize_namer$   *   s.     &&964
HC99;S!!r   c                     t        j                  ddt        |             j                         }|dv s|j	                  d      r|S d| S )z
    Returns "HTTP_HEADER_NAME" for "header-name" or "Header-Name", etc.
    Won't add "HTTP_" to input that already has it or for CONTENT_TYPE or
    CONTENT_LENGTH.
    z\W+r   )CONTENT_LENGTHCONTENT_TYPEHTTP_)r   r   r   upper
startswith)r"   uc_names     r	   get_header_namer,   9   sK     ffVS)D/288:G448J8J78S7)r   c                      t        t               d      } | j                  dd      j                  d      j	                  dd      S )a  
    This returns a cross-platform compatible timezone name suitable for
    embedding into cache-keys. Its inclusion into cache-keys enables, but does
    not guarantee by itself, that dates are display correctly for the client's
    timezone. In order to complete this the project should use middleware or
    some other mechanism to affect's Django's get_current_timezone_name().
    ignore)errorsascii r   )r   r   encodedecodereplace)tz_names    r	   get_timezone_namer6   E   s=     13HEG>>'8,33G<DDS#NNr   c                     ddl m} ddlm} ddlm} | j                  j                         D ]  }|j                  |k(  s y 	 |j                  j                  |    }t        ||      S # t        $ r Y yw xY w)a/  
    Return True if the model_class is editable.
    Checks whether the model_class has any relationships with Placeholder.
    If not, checks whether the model_class has an admin class
    and is inherited by FrontendEditableAdminMixin.
    :param model_class: The model class
    :return: Boolean
    r   )admin)FrontendEditableAdminMixin)PlaceholderTF)django.contribr8   cms.admin.placeholderadminr9   cms.models.placeholdermodelr:   _meta
get_fieldsrelated_modelsite	_registryKeyError
isinstance)model_classr8   r9   r:   fieldadmin_classs         r	   is_editable_modelrH   U   s{     %E7 ""--/ +-jj**;7 k#=>>  s   A) )	A54A5)r   django.utils.encodingr   django.utils.timezoner   r
   r   r$   r,   r6   rH   r   r   r	   <module>rK      s2    	 + ;$ $>"	O ?r   