
    Bh                          d dl 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 Z G d	 d
ej                        Zy)    N)get_permission_codename)Site)ValidationError)models)gettext_lazy)PlaceholderFieldc                     | j                   S )zW
    Returns a string to be used as the slot
    for the static placeholder field.
    )code)instances    M/home/dcms/DCMS/lib/python3.12/site-packages/cms/models/static_placeholder.pystatic_slotnamer      s    
 ==    c            	          e Zd ZdZdZe ed      fe ed      ffZ ej                   ed      ddd ed	      
      Z	 ej                   ed      dd ed            Z
 ee ed      d      Z eedd      Z ej                  dd      Z ej                   ed      eedd      Z ej$                  eej(                  dd      Z G d d      Zd Zd Z ed      e_        d Zd Zd Zy )!StaticPlaceholdertemplater
   zby templatezby codezstatic placeholder name   T zMDescriptive name to identify this static placeholder. Not displayed to users.)verbose_name
max_lengthblankdefault	help_textzplaceholder codez.To render the static placeholder in templates.)r   r   r   r   zplaceholder contentstatic_draft)r   related_nameFstatic_public)editabler   )r   r   creation_method   )r   choicesr   r   r   )	on_deletenullr   c                   4    e Zd Z ed      Z ed      ZdZdZy)StaticPlaceholder.Metazstatic placeholderzstatic placeholderscms))r
   siteN)__name__
__module____qualname___r   verbose_name_plural	app_labelunique_together r   r   Metar#   *   s#    -. 56	-r   r.   c                 "    | j                         S N)get_nameselfs    r   __str__zStaticPlaceholder.__str__0   s    }}r   c                 d    | j                   xs# | j                  xs t        | j                        S r0   )namer
   strpkr2   s    r   r1   zStaticPlaceholder.get_name3   s"    yy5DII5TWW5r   c                 \   | j                   sdt        j                         z  | _         | j                  sxt        j
                  j                  | j                   d      }| j                  r|j                  | j                        }|j                         rt        t        d            y y )Nz	static-%sT)r
   site__isnull)r8   z?A static placeholder with the same site and code already exists)r
   uuiduuid4r%   r   objectsfilterr8   excludeexistsr   r)   )r3   placeholderss     r   cleanzStaticPlaceholder.clean7   s    yy#djjl2DIyy,44;;Y];^Lww+33tww3?""$%a(i&jkk %	 r   c                     |j                   j                  ry| j                  }|j                   j                  |j                  dz   t        d|      z         S )NT.changeuseris_superuser_metahas_permr+   r   r3   requestoptss      r   has_change_permissionz'StaticPlaceholder.has_change_permissionB   sH    <<$$zz||$$T^^c%9<ST\^b<c%cddr   c                    |j                   j                  ry| j                  }|j                   j                  |j                  dz   t        d|      z         xr+ |j                   j                  |j                  dz   dz         S )NTrD   rE   publish_pagerF   rK   s      r   has_publish_permissionz(StaticPlaceholder.has_publish_permissionH   sq    <<$$zz||$$T^^c%9<ST\^b<c%cd ILL!!$..3"6"GH	Ir   N)r&   r'   r(   CREATION_BY_TEMPLATECREATION_BY_CODEr)   CREATION_METHODSr   	CharFieldr6   r
   r   r   draftpublicBooleanFielddirtyr   
ForeignKeyr   CASCADEr%   r.   r4   r1   short_descriptionrB   rN   rQ   r-   r   r   r   r      s8   %	q/0	1Y<( 601cWYcdfD 6)*s$DEGD _1=R;SbpqEoO\FF>E&f&&()3C RtO 6TV^^$dSD. .6!"#<!=H	leIr   r   )r;   django.contrib.authr   django.contrib.sites.modelsr   django.core.exceptionsr   	django.dbr   django.utils.translationr   r)   cms.models.fieldsr   r   Modelr   r-   r   r   <module>rd      s1     7 , 2  6 .9I 9Ir   