
    BhЀ                         d dl mZ d dlmZ d dlm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  G d d	e      Z G d
 de      Z G d de      Zy)    )model_to_dict)override_settings
add_plugin)	CMSPluginPlaceholderUserSettings)Example1)CMSTestCase)override_placeholder_confc                   2    e Zd Zd Z	 ddZddZddZd Zy)	AppAdminTestCasec                 .    | j                         | _        y N)_get_example_obj_objselfs    T/home/dcms/DCMS/lib/python3.12/site-packages/cms/tests/test_placeholder_app_admin.pysetUpzAppAdminTestCase.setUp   s    ))+	    c                 B    ddidddddid}t        |||fi ||   }|S )	Ntag_typedivA Linkhttps://www.django-cms.orgnameexternal_linkr   Content)StylePlugin
LinkPluginPlaceholderPluginr   )r   placeholderplugin_typelanguageplugin_dataplugins         r   _add_plugin_to_placeholderz+AppAdminTestCase._add_plugin_to_placeholder   sO     '.#+>Z["()!4

 
 +&	
 r   Nc                     	 |j                   }	 |j                   }|d||j                   |d}|S # t        $ r d}Y .w xY w# t        $ r d}Y 2w xY w)N en)placeholder_idtarget_languagetarget_position	plugin_idplugin_parent)pkAttributeError)r   r(   positionr$   parentr-   	parent_iddatas           r   _get_move_datazAppAdminTestCase._get_move_data   sl    	 (^^N			I
 -#'&
   	 N	 
  	I	s   / A  == AAc                 V    | j                  | j                  j                  ||      }|S )N)r$   r%   r&   )get_add_plugin_urir   r$   )r   r%   r&   uris       r   _get_add_plugin_uriz$AppAdminTestCase._get_add_plugin_uri3   s1    %%		--# & 

 
r   c                 L    t         j                  j                  dddd      }|S )Nonetwotreefour)char_1char_2char_3char_4)r
   objectscreate)r   objs     r   r   z!AppAdminTestCase._get_example_obj;   s0    %%	 & 
 
r   )r"   r,   )NN)__name__
__module____qualname__r   r)   r8   r<   r    r   r   r   r      s"    , GK(r   r   c                   B    e Zd ZdddddiiZd Zd Zd Zd	 Zd
 Zd Z	y)AppAdminTestr$   limits      )globalr!   c                 x   | j                         }| j                         }| j                  |      5  t        | j                        5  ddd}| j
                  j                  ||      }| j                  |j                  d       | j
                  j                  ||      }| j                  |j                  d       | j
                  j                  ||      }| j                  |j                  d       | j                  |j                  d       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	zv
        Ensures placeholder global plugin limit is respected
        when adding plugins to the placeholder.
        CMS_PLACEHOLDER_CONFr   r   r        ?   This placeholder already has the maximum number of plugins (2).N
get_superuserr<   login_user_contextr   placeholderconfclientpostassertEqualstatus_codecontentr   	superuserendpointr7   responses        r   test_global_limit_on_plugin_addz,AppAdminTest.test_global_limit_on_plugin_addN   s   
 &&(	++-$$Y/ 	*@T@TU  (;WX;;++Hd;  !5!5s;;;++Hd;  !5!5s;;;++Hd;  !5!5s;  $$V	 	 	 	s$   D0	C
D$D0$D-	)D00D9c                    | j                         }| j                  j                  }| j                         j                  }| j	                  |      }| j	                  |      }| j	                  |      }| j                  |      5  t        | j                        5  | j                  |d|      }| j                  |      }| j                  j                  ||      }	| j                  |	j                  d       | j                  |d|      }| j                  |      }| j                  j                  ||      }	| j                  |	j                  d       | j                  |d|      }| j                  |      }| j                  j                  ||      }	| j                  |	j                  d       | j                  |	j                  d       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	zv
        Ensures placeholder global plugin limit is respected
        when moving plugins to the placeholder.
        rQ   r4   r$   rV   rP      rW   rX   NrZ   r   r$   r   r)   r[   r   r\   r8   get_move_plugin_urir]   r^   r_   r`   ra   )
r   rc   source_placeholdertarget_placeholderplugin_1plugin_2plugin_3r7   rd   re   s
             r    test_global_limit_on_plugin_movez-AppAdminTest.test_global_limit_on_plugin_moved   s   
 &&(	!YY22!224@@223EF223EF223EF$$Y/ 	*4+?+?@ **8aM_*`33H=;;++Hd;  !5!5s;**8aM_*`33H=;;++Hd;  !5!5s;**8aM_*`33H=;;++Hd;  !5!5s;  $$V	 	 	 	s%   G,D4G G, G)	%G,,G5c                    | j                         }| j                  j                  }| j                  |      }| j                  |      }| j	                  |      5  t        | j                        5  | j                  |d      }| j                  |      }| j                  j                  ||      }| j                  |j                  d       | j                  |d      }| j                  |      }| j                  j                  ||      }| j                  |j                  d       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)zo
        Ensures no global limit exception is raised
        when moving plugins inside a placeholder.
        rQ   r4   rV   rP   NrZ   r   r$   r)   r[   r   r\   r8   rk   r]   r^   r_   r`   )r   rc   rl   rn   ro   r7   rd   re   s           r   0test_no_global_limit_check_same_placeholder_movez=AppAdminTest.test_no_global_limit_check_same_placeholder_move   s1   
 &&(	!YY22223EF223EF$$Y/ 		<*4+?+?@ <**8a*@33H=;;++Hd;  !5!5s;**8a*@33H=;;++Hd;  !5!5s;<		< 		<< <		< 		<s%   E0B9D:)E:E	?EEc                    | j                         }| j                  d      }| j                  |      5  t        | j                        5  ddi}| j
                  j                  ||      }| j                  |j                  d       | j
                  j                  ||      }| j                  |j                  d       | j                  |j                  d       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	zt
        Ensures placeholder plugin type limit is respected
        when adding plugins to the placeholder.
        r!   rT   r   r   rV   rW   M   This placeholder already has the maximum number (1) of allowed Style plugins.NrY   rb   s        r   test_type_limit_on_plugin_addz*AppAdminTest.test_type_limit_on_plugin_add   s    
 &&(	++M:$$Y/ 	*@T@TU 
"E*;;++Hd;  !5!5s;;;++Hd;  !5!5s;  $$D
	 	
 
	 	s$   C8
BC,C8,C5	1C88Dc                    | j                         }| j                  j                  }| j                         j                  }| j	                  |d      }| j	                  |d      }| j                  |      5  t        | j                        5  | j                  |d|      }| j                  |      }| j                  j                  ||      }| j                  |j                  d       | j                  |d|      }| j                  |      }| j                  j                  ||      }| j                  |j                  d       | j                  |j                  d       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	zt
        Ensures placeholder plugin type limit is respected
        when moving plugins to the placeholder.
        r!   rT   rQ   rh   rV   rW   rw   Nrj   )	r   rc   rl   rm   rn   ro   r7   rd   re   s	            r   test_type_limit_on_plugin_movez+AppAdminTest.test_type_limit_on_plugin_move   ss   
 &&(	!YY22!224@@223E}U223E}U$$Y/ 	s*@T@TU 
s**8aM_*`33H=;;++Hd;  !5!5s;**8aM_*`33H=;;++Hd;  !5!5s;  !1!1!qs
s	s 	s
s 
s	s 	ss%   6FCE5$F5E>	:FF
c                    | j                         }| j                  j                  }| j                  |d      }| j	                  |      5  t        | j                        5  | j                  |d      }| j                  |      }| j                  j                  ||      }| j                  |j                  d       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)zw
        Ensures no plugin type limit exception is raised
        when moving plugins inside of a placeholder.
        r!   rT   rQ   rs   rV   Nrt   )r   rc   rl   rn   r7   rd   re   s          r   .test_no_type_limit_check_same_placeholder_movez;AppAdminTest.test_no_type_limit_check_same_placeholder_move   s    
 &&(	!YY22223E}U$$Y/ 	<*@T@TU <**8a*@33H=;;++Hd;  !5!5s;	<	< 	<< <	< 	<s%   
C!AC>CC	CC$N)
rI   rJ   rK   r\   rf   rq   ru   rx   rz   r|   rL   r   r   rN   rN   E   s?    $
' O,@<,*s2<r   rN   c                   ~    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)AppAdminPermissionsTestc                 X    | j                         | _        | j                         | _        y r   )r   r   "get_staff_user_with_no_permissions_staff_userr   s    r   r   zAppAdminPermissionsTest.setUp   s#    ))+	BBDr   c                    | j                   }| j                  j                  }|j                  d      j	                  d      }| j                         }| j                  |d       | j                  |d       | j                  |      5  ddd}| j                  j                  ||      }| j                  |j                  d	       | j                  |j                         d
       ddd       y# 1 sw Y   yxY w)z
        User can add a new plugin if he has change permissions
        on the model attached to the placeholder and he has
        add permissions on the plugin model.
        r,   r"   r%   change_example1add_linkr   r   r   rV   rQ   N)r   r   r$   get_pluginsfilterr<   add_permissionr[   r]   r^   r_   r`   countr   
staff_userr$   pluginsrd   r7   re   s          r   test_user_can_add_pluginz0AppAdminPermissionsTest.test_user_can_add_plugin   s     %%
ii++))$/66<6P++-J(9:J
3$$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	1 	1s   	AC00C9c                 j   | j                   }| j                  j                  }|j                  d      j	                  d      }| j                         }| j                  |d       | j                  |d       | j                  |d       | j                  |      5  ddd	}| j                  j                  ||      }| j                  |j                  d
       | j                  |j                         d       ddd       | j                  |d       | j                  |d       | j                  |      5  ddd	}| j                  j                  ||      }| j                  |j                  d
       | j                  |j                         d       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)z
        User can't add a new plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have add permissions on the plugin model.
        r,   r"   r   add_example1delete_example1r   r   r   r     r   Nr   )r   r   r$   r   r   r<   r   r[   r]   r^   r_   r`   r   remove_permissionr   s          r   test_user_cant_add_pluginz1AppAdminPermissionsTest.test_user_cant_add_plugin   s    %%
ii++))$/66<6P++-J7J(9:J
3$$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	J(9:z:6$$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	1	1 	1	1 	1s   AF6AF)F&)F2c                    | j                   }| j                  j                  }| j                  |      }| j	                  |      }| j                  |d       | j                  |d       | j                  |      5  t        |ddg      }d|d<   | j                  j                  ||      }| j                  |j                  d       |j                          | j                  |j                  |d          ddd       y# 1 sw Y   yxY w)	z
        User can edit a plugin if he has change permissions
        on the model attached to the placeholder and he has
        change permissions on the plugin model.
        r   change_linkr   r   fieldsA link 2rV   N)r   r   r$   r)   get_change_plugin_urir   r[   r   r]   r^   r_   r`   refresh_from_dbr   r   r   r$   r(   rd   r7   re   s          r   test_user_can_edit_pluginz1AppAdminPermissionsTest.test_user_can_edit_plugin  s     %%
ii++00=--f5J(9:J6$$Z0 	8 0IJD%DL{{''$7HX1137""$V[[$v,7	8 	8 	8s   :A<C??Dc                    | j                   }| j                  j                  }| j                  |      }| j	                  |      }| j                  |d       | j                  |d       | j                  |d       | j                  |      5  t        |ddg      }d|d<   | j                  j                  ||      }| j                  |j                  d       |j                          | j                  |j                  |d          d	d	d	       | j                  |d
       | j                  |d       | j                  |      5  t        |ddg      }d|d<   | j                  j                  ||      }| j                  |j                  d       |j                          | j                  |j                  |d          d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)z
        User can't edit a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have change permissions on the plugin model.
        r   r   r   r   r   r   r   r   Nr   )r   r   r$   r)   r   r   r[   r   r]   r^   r_   r`   r   assertNotEqualr   r   r   s          r   test_user_cant_edit_pluginz2AppAdminPermissionsTest.test_user_cant_edit_plugin)  s    %%
ii++00=--f5J7J(9:J6$$Z0 	; 0IJD%DL{{''$7HX1137""$T&\:	; 	J(9:z=9$$Z0 	; 0IJD%DL{{''$7HX1137""$T&\:	; 	;	; 	;	; 	;s   A<G
A<G
GGc                    | j                   }| j                  j                  }| j                  |      }| j	                  |      }| j                  |d       | j                  |d       | j                  |      5  ddi}| j                  j                  ||      }| j                  |d       | j                  t        j                  j                  |j                        j                                ddd       y# 1 sw Y   yxY w)z
        User can delete a plugin if he has change permissions
        on the model attached to the placeholder and he has
        delete permissions on the plugin model.
        r   delete_linkr^   Tz<div class="success"></div>r2   N)r   r   r$   r)   get_delete_plugin_urir   r[   r]   r^   assertContainsassertFalser   rF   r   r2   existsr   s          r   test_user_can_delete_pluginz3AppAdminPermissionsTest.test_user_can_delete_pluginM  s     %%
ii++00=--f5J(9:J6$$Z0 	ND>D{{''$7H*GHY..555CJJLM	N 	N 	Ns   :A:C==Dc                    | j                   }| j                  j                  }| j                  |      }| j	                  |      }| j                  |d       | j                  |d       | j                  |d       | j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  t        j                  j                  |j                        j!                                ddd       | j                  |d	       | j#                  |d       | j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  t        j                  j                  |j                        j!                                ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)
z
        User can't delete a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have delete permissions on the plugin model.
        r   r   r   r^   Tr   r   Nr   )r   r   r$   r)   r   r   r[   r]   r^   r_   r`   
assertTruer   rF   r   r2   r   r   r   s          r   test_user_cant_delete_pluginz4AppAdminPermissionsTest.test_user_cant_delete_pluginb  s    %%
ii++00=--f5J7J(9:J6$$Z0 	MD>D{{''$7HX1137OOI--44		4BIIKL	M 	J(9:z=9$$Z0 	MD>D{{''$7HX1137OOI--44		4BIIKL	M 	M	M 	M	M 	Ms   BGBG&G#&G/c                    | j                   }| j                  j                  }| j                         j                  }| j	                  |      }| j                  |d|      }| j                  |d       | j                  |d       | j                  |      5  | j                  |      }| j                  j                  ||      }| j                  |j                  d       | j                  |j                  d      j                  |j                                | j#                  |j                  d      j                  |j                                ddd       y# 1 sw Y   yxY w)	z
        User can move a plugin if he has change permissions
        on the model attached to the placeholder and he has
        change permissions on the plugin model.
        rQ   rh   r   r   rV   r,   r   N)r   r   r$   r   r)   r8   r   r[   rk   r]   r^   r_   r`   r   r   r   r2   r   r   r   rl   rm   r(   r7   rd   re   s           r   test_user_can_move_pluginz1AppAdminPermissionsTest.test_user_can_move_plugin  s7    %%
!YY22!224@@001CD""6ACU"VJ(9:J6$$Z0 	X//7H{{''$7HX1137OO.::4@GG699GUV/;;DAHHFIIHVW	X 	X 	Xs   B>EE'c                    | j                   }| j                  j                  }| j                         j                  }| j	                  |      }| j                  |d|      }| j                  |d       | j                  |d       | j                  |d       | j                  |      5  | j                  |      }| j                  j                  ||      }| j                  |j                  d       | j                  |j                  d      j                  |j                                | j#                  |j                  d      j                  |j                                d	d	d	       | j                  |d
       | j%                  |d       | j                  |      5  | j                  j                  |      }| j                  |j                  d       | j                  |j                  d      j                  |j                                | j#                  |j                  d      j                  |j                                d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)z
        User can't move a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have change permissions on the plugin model.
        rQ   rh   r   r   r   r   r,   r   Nr   )r   r   r$   r   r)   r8   r   r[   rk   r]   r^   r_   r`   r   r   r   r2   r   r   r   s           r   test_user_cant_move_pluginz2AppAdminPermissionsTest.test_user_cant_move_plugin  s    %%
!YY22!224@@001CD""6ACU"VJ7J(9:J6$$Z0 	W//7H{{''$7HX1137/;;DAHHFIIHVWOO.::4@GG699GUV	W 	J(9:z=9$$Z0 	W{{''$7HX1137/;;DAHHFIIHVWOO.::4@GG699GUV		W 	W	W 	W	W 	Ws   )B>I$B-I&I#&I/c                 \   | j                   }| j                  j                  }| j                  |      }| j	                  |      }|j                  }| j                         j                  }|j                  |j                  |j                  d|j                  d}| j                  |d       | j                  |d       | j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  |j                  d      j!                  |j                        j#                                | j                  |j                  d      j!                  |j$                        j#                                ddd       y# 1 sw Y   yxY w)	z
        User can copy a plugin if he has change permissions
        on the model attached to the placeholder and he has
        add permissions on the plugin model.
        r,   source_plugin_idsource_placeholder_idsource_languager.   target_placeholder_idr   r   rV   r   r   N)r   r   r$   r)   get_copy_plugin_urir   r2   r&   r   r[   r]   r^   r_   r`   r   r   r   r   r%   	r   r   r$   r(   rd   rl   rm   r7   re   s	            r   test_user_can_copy_pluginz1AppAdminPermissionsTest.test_user_can_copy_plugin  sb    %%
ii++00=++F3#//!224@@ !'		%7%:%:%#%7%:%:
 	J(9:J
3$$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_OO"T"F$6$67				 		 		s   C	F""F+c                    | j                   }| j                  j                  }| j                  |      }| j	                  |      }|j                  }| j                         j                  }|j                  |j                  |j                  d|j                  d}| j                  |d       | j                  |d       | j                  |d       | j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  |j                  d      j!                  |j                        j#                                | j%                  |j                  d      j!                  |j&                        j#                                d	d	d	       | j                  |d
       | j)                  |d       | j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  |j                  d      j!                  |j                        j#                                | j%                  |j                  d      j!                  |j&                        j#                                d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)z
        User can't copy a plugin if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have add permissions on the plugin model.
        r,   r   r   r   r   r   r   r   Nr   )r   r   r$   r)   r   r   r2   r&   r   r[   r]   r^   r_   r`   r   r   r   r   r   r%   r   r   s	            r   test_user_cant_copy_pluginz2AppAdminPermissionsTest.test_user_cant_copy_plugin  sR    %%
ii++00=++F3#//!224@@ !'		%7%:%:%#%7%:%:
 	J7J(9:J
3$$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_"T"F$6$67				 	J(9:z:6$$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_"T"F$6$67				 				 				 		s   "C	J:(C	K:KKc                 N   | j                   }| j                  j                  }| j                  |      }| j	                  |d       | j                  |      5  | j                  j                  |ddi      }| j                  |j                  d       ddd       y# 1 sw Y   yxY w)z}
        User can clear a placeholder if he has change permissions
        on the model attached to the placeholder.
        r   testr   rV   N)
r   r   r$   get_clear_placeholder_urlr   r[   r]   r^   r_   r`   r   r   r$   rd   re   s        r   %test_user_can_clear_empty_placeholderz=AppAdminPermissionsTest.test_user_can_clear_empty_placeholder  s    
 %%
ii++11+>J(9:$$Z0 	8{{''61+>HX1137	8 	8 	8s   ;BB$c                 *   | j                   }| j                  j                  }| j                  |      }| j	                  |      5  | j
                  j                  |ddi      }| j                  |j                  d       ddd       y# 1 sw Y   yxY w)z
        User can't clear a placeholder if he does not have
        change permissions on the model attached to the placeholder.
        r   r   r   N)	r   r   r$   r   r[   r]   r^   r_   r`   r   s        r   &test_user_cant_clear_empty_placeholderz>AppAdminPermissionsTest.test_user_cant_clear_empty_placeholder  s    
 %%
ii++11+>$$Z0 	8{{''61+>HX1137	8 	8 	8s   ;B		Bc                 Z   | j                   }| j                  j                  }| j                  |d      | j                  |d      g}|d   j                  }| j	                  |      }| j                  |d       | j                  |d       | j                  |d       | j                  |      5  | j                  j                  |ddi      }| j                  |j                  d       | j                  |j                  d	      j                         d       d
d
d
       y
# 1 sw Y   y
xY w)z
        User can clear a placeholder with plugins if he has
        change permissions on the model attached to the placeholder
        and delete permissions on the plugin model.
        r!   r"   r   delete_styler   r   r   rV   r,   Nr   r   r$   r)   r   r   r[   r]   r^   r_   r`   r   r   r   r   r$   r   rd   re   s         r   )test_user_can_clear_non_empty_placeholderzAAppAdminPermissionsTest.test_user_can_clear_non_empty_placeholder+  s    %%
ii++++KG++KF
 aj,,11+>J7J6J(9:$$Z0 	G{{''61+>HX1137[44T:@@BAF	G 	G 	Gs   .A*D!!D*c                 6   | j                   }| j                  j                  }| j                  |d      | j                  |d      g}|d   j                  }| j	                  |      }| j                  |d       | j                  |d       | j                  |      5  | j                  j                  |ddi      }| j                  |j                  d       | j                  |j                  d      j                         d	       d
d
d
       y
# 1 sw Y   y
xY w)z
        User can't clear a placeholder with plugins if he does not have
        change permissions on the model attached to the placeholder
        and/or does not have delete permissions on the plugin model.
        r!   r"   r   delete_textr   r   r   r,   rP   Nr   r   s         r   *test_user_cant_clear_non_empty_placeholderzBAppAdminPermissionsTest.test_user_cant_clear_non_empty_placeholderC  s    %%
ii++++KG++KF
 aj,,11+>J6J6$$Z0 	G{{''61+>HX1137[44T:@@BAF	G 	G 	Gs   A*DDc                    | j                   }| j                  j                  }| j                  |      }| j	                  |d       | j	                  |d       t
        j                  j                  d|t        j                  j                               }| j                  |d       | j                  |d       d|j                  dd|j                  j                  d}| j                  |      5  | j                  j                  ||      }| j                  |j                   d	       d
d
d
       |j                  j#                         }| j%                  |j'                  d      j)                                | j                  t+        |      d       |d   j-                         d   }|j.                  }	| j                  |	j#                         j1                         d       y
# 1 sw Y   xY w)z
        User can copy a placeholder to the clipboard
        if he has add permissions on the plugin models
        being copied.
        r!   r"   r,   r&   user	clipboardr   	add_styler+   r   rV   Nr#   r   rQ   r   rP   )r   r   r$   get_copy_placeholder_urir)   r	   rF   rG   r   r   r2   r   r[   r]   r^   r_   r`   r   r   r   r   lenget_plugin_instanceplaceholder_refr   )
r   r   rl   rd   user_settingsr7   re   clipboard_pluginsplaceholder_pluginref_placeholders
             r   +test_user_can_copy_placeholder_to_clipboardzCAppAdminPermissionsTest.test_user_can_copy_placeholder_to_clipboardZ  s    %%
!YY22001CD''(:MJ''(:LI$,,33!))002 4 
 	J
3J4 !#%7%:%:##%2%<%<%?%?
 $$Z0 	8{{''$7HX1137	8
 *33??A 	)00=P0QXXZ[./3.q1EEGJ,<< 	446<<>B!	8 	8s   19G''G0c                 0   | j                   }| j                  j                  }| j                  |      }| j	                  |d       | j	                  |d       t
        j                  j                  d|t        j                  j                               }| j                  |d       | j                  |d       | j                  |d       | j                  |d       d	|j                  dd|j                  j                  d
}| j                  |      5  | j                  j                  ||      }ddd       | j                  j                   d       |j                  j#                         }| j                  t%        |      d       y# 1 sw Y   [xY w)z
        User cant copy a placeholder to the clipboard if he does not
        have add permissions on the plugin models being copied.
        r!   r"   r,   r   r   r   change_styler   r+   r   Nr   r   )r   r   r$   r   r)   r	   rF   rG   r   r   r2   r   r[   r]   r^   r_   r`   r   r   )r   r   rl   rd   r   r7   re   r   s           r   ,test_user_cant_copy_placeholder_to_clipboardzDAppAdminPermissionsTest.test_user_cant_copy_placeholder_to_clipboard  so   
 %%
!YY22001CD''(:MJ''(:LI$,,33!))002 4 
 	J6J6J7J7 !#%7%:%:##%2%<%<%?%?
 $$Z0 	8{{''$7H	8 	--s3)33??A./3	8 	8s   FFc           
      8   | j                   }| j                  j                  }| j                  |d       | j                  |d       t        j
                  j                  d|t        j
                  j                               }| j                  |j                  d      }|j                  }| j                  |       | j                  |       | j                  |      5  |j                  |j                  ddd|j                  dd	
      d}| j                  |      }| j                  j!                  ||      }| j#                  |j$                  d       | j#                  |j'                  d      j)                         d       ddd       y# 1 sw Y   yxY w)z
        User can paste plugins from the clipboard if he has
        change permissions on the model attached to the target
        placeholder and he has add permissions on the plugin models
        being copied.
        r   r   r,   r   r#   r+   frTlastinsert_orderr-   r0   r1   r.   move_a_copyr/   rV   rP   N)r   r   r$   r   r	   rF   rG   r   r)   r   r   r[   r2   get_next_plugin_positionrk   r]   r^   r_   r`   r   r   	r   r   rm   r   r   r   r7   rd   re   s	            r   "test_user_can_paste_from_clipboardz:AppAdminPermissionsTest.test_user_can_paste_from_clipboard  s~    %%
!YY22J(9:J
3$,,33!))002 4 
 "<<##
 -<<''8''8$$Z0 	N #5"7"7/22!##'##5#N#Ntbh#N#iD //0BCH{{''$7HX1137/;;DAGGI1M	N 	N 	Ns    B'FFc           
         | j                   }| j                  j                  }| j                  |d       | j                  |d       | j                  |d       t        j
                  j                  d|t        j
                  j                               }| j                  |j                  d      }|j                  }| j                  |       | j                  |       | j                  |      5  |j                  |j                  ddd	|j                  dd
      d}| j                  |      }| j                  j!                  ||      }| j#                  |j$                  d       | j#                  |j'                  d      j)                         d       ddd       | j                  |d       | j+                  |d       | j                  |      5  |j                  |j                  ddd	|j                  dd
      d}| j                  j!                  |      }| j#                  |j$                  d       | j#                  |j'                  d      j)                         d       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)z
        User cant paste plugins from the clipboard if he does not have
        change permissions on the model attached to the target placeholder
        and/or does not have add permissions on the plugin models
        being copied.
        r   r   r   r,   r   r#   r+   r   Tr   r   r   r   r   Nr   )r   r   r$   r   r	   rF   rG   r   r)   r   r   r[   r2   r   rk   r]   r^   r_   r`   r   r   r   r   s	            r   #test_user_cant_paste_from_clipboardz;AppAdminPermissionsTest.test_user_cant_paste_from_clipboard  si    %%
!YY22J7J(9:J
3$,,33!))002 4 
 "<<##
 -<<''8''8$$Z0 	N #5"7"7/22!##'##5#N#Ntbh#N#iD //0BCH{{''$7HX1137/;;DAGGI1M	N  	J(9:z:6$$Z0 	N #5"7"7/22!##'##5#N#Ntbh#N#iD {{''$7HX1137/;;DAGGI1M	N 	N'	N 	N&	N 	Ns   2B'I5BJ5I>J
N)rI   rJ   rK   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rL   r   r   r~   r~      ss    E1(1<8.";HN*M@X.WB!F0d88G0G..C`'4R*NX=Nr   r~   N)django.forms.modelsr   django.test.utilsr   cms.apir   
cms.modelsr   r   r	   ,cms.test_utils.project.placeholderapp.modelsr
   cms.test_utils.testcasesr   $cms.test_utils.util.context_managersr   r   rN   r~   rL   r   r   <module>r      sK    - /  ; ; A 0 J7{ 7tR<# R<jB	N. B	Nr   