
    Bh^                        d dl Z d dlZ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 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 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'm(Z( d dl)m*Z* d dl+m,Z,m-Z- d dl.m/Z/ d dl0m1Z1 d dl2m3Z3m4Z4 d dl5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z<m=Z= d dl>m?Z?m@Z@mAZA d dlBmCZC d dlDmEZEmFZF d dlGmHZH d dlImJZJ d d lKmLZL d d!lMmNZN  G d" d#e      ZO G d$ d%e      ZP G d& d'e=      ZQ G d( d)eQ      ZR G d* d+eQ      ZS G d, d-eQ      ZT ed./       G d0 d1eT             ZU ed./       G d2 d3eT             ZV ed4/       G d5 d6eT             ZW ed78       G d9 d:e=             ZXy);    N)
skipUnless)settings)admin)Site)cache)model_to_dict)HttpRequestHttpResponse)HTMLParseErrorParser)override_settings)clear_url_caches)	force_str)now)override)	constants)PageContentAdmin)
add_plugincreate_pagecreate_page_content)clear_app_resolvers)get_permission_cacheset_permission_cache)CurrentUserMiddleware)PageContent)PagePageUrl)PagePermission)	CMSPlugin)SampleAppConfig)URL_CMS_PAGE_MOVECMSTestCase)LanguageOverrideUserLoginContextoverride_placeholder_conf)get_object_edit_url)
DJANGO_4_2
DJANGO_5_1)installed_apps)get_cms_setting)get_page_from_request)admin_reversec                       e Zd Zd Zy)PageTreeLiParserc                 @    |dk(  rg }t        j                  | ||       y )Nlir   handle_starttagselftagattrss      I/home/dcms/DCMS/lib/python3.12/site-packages/cms/tests/test_page_admin.pyr2   z PageTreeLiParser.handle_starttag.   s"     $;EtS%0    N__name__
__module____qualname__r2    r8   r7   r.   r.   ,   s    1r8   r.   c                       e Zd Zd Zy)PageTreeOptionsParserc                 b    |dk(  r|r|d   d   dk(  r|d   g}t        j                  | ||       y )Nr0   r   zdata-coloptionsr1   r3   s      r7   r2   z%PageTreeOptionsParser.handle_starttag;   s:     $;5U2Yq\5F%F2YKEtS%0r8   Nr9   r=   r8   r7   r?   r?   9   s    1r8   r?   c                   b    e Zd ZdZdddddiiZddZdd	Zdd
Zd ZddZ		 	 ddZ
d ZddZy)PageTestBasezq
    The purpose of this class is to provide some basic functionality
    to test methods of the Page admin.
    bodylimits      )global
TextPluginc                 ~    ddidddd}|j                  |      j                  d      }t        |||fi ||   }|S )NrD   z<p>text</p>A Linkhttps://www.django-cms.orgnameexternal_link)rI   
LinkPluginslot)get_placeholdersgetr   )r4   pageplugin_typelanguagepublishplugin_dataplaceholderplugins           r7   _add_plugin_to_pagez PageTestBase._add_plugin_to_pageP   sW    !=1#+>Z[
 ++H599v9FKh[+kBZ[r8   Nc                     |sd}t         j                  j                  |      }|r|j                  |      }|j                         S )Npermissions-de)page__urls__slugtitle)r   objectsfilterexists)r4   slugra   lookups       r7   _translation_existsz PageTestBase._translation_existsY   sB    #D$$++T+B]]]/F}}r8   c                 p    |j                  |      j                  d      }| j                  |d|      }|S )NrD   rQ   rP   rZ   rV   rW   )rS   rT   get_add_plugin_uri)r4   rU   rW   rZ   uris        r7   _get_add_plugin_uriz PageTestBase._get_add_plugin_uric   sE    ++H599v9F%%#$ & 

 
r8   c                     t         j                  j                         }ddd|j                  dd} |j                  di | |S )Npermissionsennav_playground.html)ra   re   rW   sitetemplater=   )r   rb   get_currentpkupdate)r4   kwargsrq   datas       r7   _get_page_datazPageTestBase._get_page_datal   sF    ||'')"!GG-
 	fr8   c                     	 |j                   }	 |j                   }|d||j                   |d}|S # t        $ r d}Y .w xY w# t        $ r d}Y 2w xY w)N ro   )placeholder_idtarget_languagetarget_position	plugin_idplugin_parent)rt   AttributeError)r4   r[   positionrZ   parentr{   	parent_idrw   s           r7   _get_move_datazPageTestBase._get_move_datax   sl    	 (^^N			I
 -#'&
   	 N	 
  	I	s   / A  == AAc                 8    | j                         }t        di |S Nr=   )get_new_page_data_dbfieldsr   )r4   r   rq   rW   rr   	page_datas         r7   get_pagezPageTestBase.get_page   s    335	'Y''r8   c                 &    | j                  |      S )N)	post_data)get_request)r4   rw   s     r7   get_post_requestzPageTestBase.get_post_request   s    $//r8   c                 :    t        |xs | j                  ddfi |S )Nrp   ro   )r   _testMethodName)r4   ra   rv   s      r7   r   zPageTestBase.create_page   s,    58D$8$80$B:@B 	Br8   )rP   ro   T)NN)ro   )NNNrp   N)r:   r;   r<   __doc__placeholderconfr\   rg   rl   rx   r   r   r   r   r=   r8   r7   rC   rC   C   sW     
  O
( *.)>(
0Br8   rC   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d Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z  e!d       d!        Z" e!d       d"        Z# e!d       d#        Z$ e!d       d$        Z% e!d%d&gd'      d(        Z&d) Z'd* Z(d+ Z)d, Z*d- Z+d. Z,d/ Z-d0 Z.d1 Z/ e0d2e1jd                  jg                  d3      jg                  d4      ji                         v d5       e!d6d67      d8               Z5y9):PageTestc                 ,    t        j                          y r   )r   clearr4   s    r7   tearDownzPageTest.tearDown   s    r8   c                 $   | j                         }| j                  |      5  | j                  j                  | j	                  d            }| j                  |j                  d       | j                  |dd       ddd       y# 1 sw Y   yxY w)zO
        Test that the add admin page could be displayed via the admin
        ro      z<title>Add a page</title>ThtmlN)get_superuserlogin_user_contextclientrT   get_page_add_uriassertEqualstatus_codeassertContains)r4   	superuserresponses      r7   test_add_pagezPageTest.test_add_page   s     &&(	$$Y/ 	R{{t'<'<T'BCHX1137*EDQ	R 	R 	Rs   ABBc                    | j                         }| j                         }| j                  |      5  | j                  t        j
                  j                         j                         d       | j                  t        j
                  j                         j                         d       | j                  j                  | j                  d      |      }| j                  || j                  d             t        j
                  j                  |d         }| j                  |j                   j#                         |d          | j                  |j                   j%                  d      |d          | j                  |j                   j'                  d      j                         d       ddd       y# 1 sw Y   yxY w)z?
        Test that a page can be created via the admin
        r   ro   re   re   ra   rF   N)get_new_page_datar   r   r   r   rb   allcountr   r   postr   assertRedirectsget_pages_admin_list_urir   rT   rU   	get_titleget_slugrS   )r4   r   r   r   page_urls        r7   test_create_page_adminzPageTest.test_create_page_admin   s[    **,	&&(	$$Y/ 
	N[00446<<>BT\\--/557;{{''(=(=d(CYOH  4+H+H+NO**	&0A*BHX]]446	'8JKX]]33D99V;LMX]];;DAGGI1M
	N 
	N 
	Ns   E<F77G c                 0   ddl m} ddlm}  |       }| j	                         }t
        j                  j                  ddd       |j                  t        | |       j                        t        | |       j                               | j                  t        j                  j                         j                         d       | j                  t        j                  j                         j                         d       | j!                  d      5  | j#                  d	      }|j%                  || j'                               }| j)                  || j+                  d
             | j                  t        j                  j-                  d      j                         d       | j                  t        j                  j-                  d
      j                         d       ddd       |j%                  | j+                         ddi       | j#                  d	      }|j%                  || j'                               }| j)                  || j+                  d
             | j                  t        j                  j-                  d      j                         d       | j                  t        j                  j-                  d
      j                         d       t
        j                  j/                          |j1                          y# 1 sw Y   )xY w)z
        Test that a page can be created via the admin
        with the request language pointing to a language
        not configured for the current site
        r   )get_user_model)ClientrF   example-2.com)idrN   domain)usernamepasswordSITE_IDro   derq   rG   rW   Nrq   )django.contrib.authr   django.testr   r   r   rb   createlogingetattrUSERNAME_FIELDr   r   r   r   r   r   r   r   r   r   r   rc   clear_cachelogout)r4   r   r   r   r   endpointr   s          r7   +test_create_page_with_unconfigured_languagez4PageTest.test_create_page_with_unconfigured_language   sY    	7&&&(	qOY(8(G(GHY(8(G(GH 	 	
 	,,00288:A>))+113Q7]]1]% 	S,,T2H {{8T-C-C-EFH  4+H+H+NOT\\00a08>>@!D[00777FLLNPQR	S 	D113fa[A ((.;;x)?)?)ABXt'D'DT'JK,,!,4::<a@,,33T3BHHJAN  "-	S 	Ss   CLLc                    | j                         }| j                         }| j                  |      5  | j                  j	                  | j                  d      |      }| j                  || j                  d             t        j                  j                  |d         }| j                  |j                  j                        }| j                  |j                  j                        }| j                  |j                  j                        }| j                  j	                  | j                  d      |      }| j                  || j                  d             | j                  j	                  | j                  d      |      }| j                  || j                  d             t        j                  j                  |d         }| j                  d      }	| j                  j	                  |	d|j                  j                  z  z   |      }| j                  || j                  d             ddd       y# 1 sw Y   yxY w)z?
        Test that a tree can be created via the admin
        ro   re   r   )r   z&target=%s&amp;position=rightN)r   r   r   r   r   r   r   r   r   rb   rT   rU   rt   )
r4   page_1r   r   home_urlpage_2page_3page_4	page2_urladd_endpoints
             r7   test_create_tree_adminzPageTest.test_create_tree_admin   s    '')&&(	$$Y/ 	P{{''(=(=d(CVLH  4+H+H+NO**v*?H++hmm6F6F+GF++hmm6F6F+GF++hmm6F6F+GF{{''(=(=d(CVLH  4+H+H+NO{{''(=(=d(CVLH  4+H+H+NO+++@I006L{{''7VYbYgYgYjYj7j(jlrsH  4+H+H+NO)	P 	P 	Ps   HI  I	c                 (   | j                         }| j                         }| j                  |      5  | j                  d      }| j                  j                  ||      }| j                  || j                  d             | j                  j                  ||      }| j                  || j                  d             | j                  j                  ||      }t        j                  j                  d      j                  d      }t        r"dj                  | j                  d|            }n!dj                  | j                  d|            }| j                  |j                   d       | j#                  ||       ddd       y# 1 sw Y   yxY w)'
        Test a slug collision
        ro   r   z<ul class="errorlist"><li>Page <a href="{}" target="_blank">test page 1</a> has the same url 'test-page-1' as current page.</li></ul>z<ul class="errorlist" id="id_slug_error"><li>Page <a href="{}" target="_blank">test page 1</a> has the same url 'test-page-1' as current page.</li></ul>r   N)r   r   r   r   r   r   r   r   r   rb   onlylatestr(   formatget_page_change_urir   r   r   )r4   r   r   r   r   new_pageexpected_errors          r7   test_slug_collisionzPageTest.test_slug_collision  s]    **,	&&(	$$Y/ 	:006L{{''i@H  4+H+H+NO{{''i@H  4+H+H+NO{{''i@H||((.55d;HR &11$AB	 R &11$AB	 
 X1137.91	: 	: 	:s   EFFc                    t        ddd      }t        ddd      }t        ddd|      }t        ddd|      }|j                          | j                         }| j                  d      }| j	                  |      5  | j                  d      5  | j                  |j                        }d|d	<   | j                  j                  ||      }t        r"d
j                  | j                  d|            }	n!dj                  | j                  d|            }	| j                  |j                  d       | j                  ||	       ddd       | j                  d      5  | j                         }d|d	<   | j                  j                  ||      }t        r"dj                  | j                  d|            }	n!dj                  | j                  d|            }	| j                  |j                  d       | j                  ||	       ddd       | j                  d      5  | j                         }d|d	<   | j                  j                  ||      }t        r"dj                  | j                  d|            }	n!dj                  | j                  d|            }	| j                  |j                  d       | j                  ||	       ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   +xY w# 1 sw Y   yxY w)r   homerp   ro   rU   subpager   
child-pagez7Slug collision between two child pages of the same nodere   z<ul class="errorlist"><li>Page <a href="{}" target="_blank">subpage</a> has the same url 'page/subpage' as current page.</li></ul>z<ul class="errorlist" id="id_slug_error"><li>Page <a href="{}" target="_blank">subpage</a> has the same url 'page/subpage' as current page.</li></ul>r   NzHSlug collision between page with no parent and a child page of home-pagez<ul class="errorlist"><li>Page <a href="{}" target="_blank">child-page</a> has the same url 'child-page' as current page.</li></ul>z<ul class="errorlist" id="id_slug_error"><li>Page <a href="{}" target="_blank">child-page</a> has the same url 'child-page' as current page.</li></ul>z*Slug collision between two top-level pageszw<ul class="errorlist"><li>Page <a href="{}" target="_blank">page</a> has the same url 'page' as current page.</li></ul>z<ul class="errorlist" id="id_slug_error"><li>Page <a href="{}" target="_blank">page</a> has the same url 'page' as current page.</li></ul>)r   set_as_homepager   r   r   subTestr   rt   r   r   r(   r   r   r   r   r   )
r4   rootrU   sub_page
child_pager   r   r   r   expected_markups
             r7   test_child_slug_collisionz"PageTest.test_child_slug_collision%  s    6#8$?6#8$?y*?dS /DdSWX
&&(	,,T2$$Y/ ;	?WX ? 22477;	$-	&!;;++L)DW fT55dHEF	 $W fT55dHEF	 $   !5!5s;##Ho>%?( hi ? 224	$0	&!;;++L)DU fT55dJGH	 $U fT55dJGH	 $   !5!5s;##Ho>%?( JK ? 224	$*	&!;;++L)DO fT55dDAB	 $O fT55dDAB	 $   !5!5s;##Ho>%?S;	? ;	?? ?(? ?(? ?S;	? ;	?sW   ;K;B4KK;B)K#K;B)K/K;K 	K;#K,	(K;/K8	4K;;Lc                    | j                         }| j                  |      5  | j                         }| j                  d      }| j                  j                  ||       t        j                  j                  |d         }| j                  j                  | j                  d|            }| j                  |j                  d       | j                  |dd       d|d	<   |j                  d      |d
<   | j                  j                  | j                  d|      |      }|j                          | j                  || j!                  d             | j                  |j#                         d       ddd       y# 1 sw Y   yxY w)z;
        Test that a page can edited via the admin
        ro   re   
urls__slugr   z<title>Change a page</title>Tr   changed titlera   rr   N)r   r   r   r   r   r   r   rb   rT   r   r   r   r   get_template_clear_internal_cacher   r   r   )r4   r   r   r   rU   r   s         r7   test_edit_pagezPageTest.test_edit_pagem  sR    &&(	$$Y/ 	@..0I,,T2HKKXy1<<##y/@#AD{{t'?'?d'KLHX1137*HtT!0Ig$($5$5d$;Ij!{{''(@(@t(LiXH&&(  4+H+H+NOT^^-?	@ 	@ 	@s   EE==Fc                    | j                         }| j                         }| j                  |      5  | j                  j	                  | j                  d      |       d d d        t        j                  j                  |d         }|j                  |d<   | j                  d|      }| j                  d      }t        rd}nd}| j                  d      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||       d d d        d d d        | j                  d
      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||       d d d        d d d        | j                  d      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||       d d d        d d d        | j                  d      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||       d d d        d d d        | j                  d      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||       d d d        d d d        | j                  d      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||d       d d d        d d d        | j                  d      5  | j                  |      5  d|d	<   | j                  j	                  ||      }| j                  ||d       d d d        d d d        y # 1 sw Y   @xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   AxY w# 1 sw Y   FxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   ZxY w# 1 sw Y   _xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nro   re   r   rr   z6<ul class="errorlist"><li>Enter a valid URL.</li></ul>zM<ul class="errorlist" id="id_redirect_error"><li>Enter a valid URL.</li></ul>z-Test that a redirect to the root page (valid)/redirectz;Test that a redirect to a page with an absolute URL (valid)z/hellozOTest that a redirect to a page with an absolute URL ending with a slash (valid)z/hello/z:Test that a redirect to a page with a relative URL (valid)z../hellozNTest that a redirect to a page with a relative URL ending with a slash (valid)z	../hello/z?Test that a redirect to a page with a javascript: URL (invalid)zjavascript:alert(1)Tr   z?Test that a redirect to a page with script tag as URL (invalid)z<script>alert("test")</script>)r   r   r   r   r   r   r   rb   rT   rr   r   r   r(   r   r   r   )r4   r   rw   rU   r   redirect_tovalidation_errorr   s           r7   #test_page_redirect_field_validationz,PageTest.test_page_redirect_field_validation  s"   &&(	%%'$$Y/ 	@KKT2248$?	@ ||4<8==Z++D$733D9Wn\\IJ 	<((3 <#&Z ;;++Hd;$$X{;<	< \\WX 	<((3 <#+Z ;;++Hd;$$X{;<	< \\kl 	<((3 <#,Z ;;++Hd;$$X{;<	< \\VW 	<((3 <#-Z ;;++Hd;$$X{;<	< \\jk 	<((3 <#.Z ;;++Hd;$$X{;<	< \\[\ 	K((3 K#8Z ;;++Hd;##H.>T#J	K	K \\[\ 	K((3 K#CZ ;;++Hd;##H.>T#J	K	K 	Kc	@ 	@< <	< 	<< <	< 	<< <	< 	<< <	< 	<< <	< 	<K K	K 	KK K	K 	Ks  ,NN6)4N)N6>O4OO%O*74O+O*P4O7P3P4P9PP8,6P+"P8Q6QQN&)N3	.N66O O	OOO'	"O**O47P	<PPP	PP(+P5	0P88QQ	
QQc                    | j                         }| j                  |      5  | j                         }d|d<   | j                  j	                  | j                  d      |       t        j                  j                  |d         }| j                  j                  | j                  d|            }| j                  |j                  d       |j                  d      |d<   d|d<   | j                  j	                  | j                  d|      |      }| j                  || j                  d             t        j                  j                  |d         }| j                  |j                         d       d	d	d	       y	# 1 sw Y   y	xY w)
zR
        Test that description and keywords tags can be set via the admin
        I am a pagemeta_descriptionro   re   r   r   rr   zI am a duckN)r   r   r   r   r   r   r   rb   rT   r   r   r   r   r   r   get_meta_description)r4   r   r   rU   r   s        r7   'test_meta_description_fields_from_adminz0PageTest.test_meta_description_fields_from_admin  sU    &&(	$$Y/ 	I..0I,9I()KKT2248)D<<##y/@#AD{{t'?'?d'KLHX1137$($5$5d$;Ij!,9I(){{''(@(@t(LiXH  4+H+H+NO<<##y/@#ADT668-H	I 	I 	Is   EE??Fc           	      z   ddl m} | j                         }| j                  |      5  | j	                         }d|d<   d|d<   | j
                  j                  | j                  d      |       t        j                  j                  |d   	      }| j
                  j                  | j                  d|      |       |j                  d
      }t               }|j                          ||_        i |_        | j#                  |j%                  |j'                  d|i            d       d d d        y # 1 sw Y   y xY w)Nr   rr   Hellora   r   r   ro   re   r   zS{% load cms_tags %}{% page_attribute title %} {% page_attribute meta_description %}requestzHello I am a page)djangorr   r   r   r   r   r   r   r   rb   rT   r   Templater	   savecurrent_pageGETr   renderContext)r4   rr   r   r   rU   treqs          r7   (test_meta_description_from_template_tagsz1PageTest.test_meta_description_from_template_tags  s   #&&(	$$Y/ 	`..0I!(Ig,9I()KKT2248)D<<##y/@#ADKKT55dDA9M!!egA-CIIK#CCGQXXh&6&6	37G&HIK^_	` 	` 	`s   D D11D:c                    ddl m} | j                         }| j                  |      5  | j	                         }t        |      }t               t        j                  d      z   }| j                  j                  | j                  d      |       t        j                  j                  |d         }| j                  j                  | j                  d|      |       |j!                  d      }t#               }|j%                          t               }	||_        i |_        |j+                  |j-                  d	|i            }
| d
|
dd   }t        j                  j/                  |
dd  d      j1                  t2        j4                  rt        j6                  j8                  nd       }| j;                  |
|       | j=                  ||       | j=                  ||	       d d d        y # 1 sw Y   y xY w)Nr   r   rA   )secondsro   re   r   z{% load cms_tags %}{% page_attribute changed_by %} changed on {% page_attribute changed_date as page_change %}{{ page_change|date:'Y-m-d\TH:i:s' }}r   z changed on iz%Y-%m-%dT%H:%M:%S)tzinfo)r   rr   r   r   r   strtz_nowdatetime	timedeltar   r   r   r   rb   rT   r   r   r	   r   r  r  r  r  strptimereplacer   USE_TZtimezoneutcr   assertLessEqual)r4   rr   r   r   change_userbefore_changerU   r  r  after_changeactual_resultdesired_result	save_times                r7   ,test_page_obj_change_data_from_template_tagsz5PageTest.test_page_obj_change_data_from_template_tags  s   #&&(	$$Y/ 	:..0Ii.K #Hx'9'9"'EEMKKT2248)D<<##y/@#ADKKT55dDA9M!!9A
 -CIIK!8L#CCGHHX%5%5y#6F%GHM +}Lst9L8MNN ))22cd## ghooX..224gP 
 ]N;   	:  L9?	: 	: 	:s   F9G**G3c                 B   | j                         }t        ddd      }t        ddd|       t        ddd|      }t        ddd|       | j                  t        d|j                        }|gt        |j                               z   }d	}| j                  |      5  | j                  j                  |      }|D ]N  }|j                  j                  d
      j                         }	|t        |	      z  }
| j                  ||
d       P 	 d d d        y # 1 sw Y   y xY w)Npage_arp   ro   page_a_ar   page_a_b
page_a_b_adeletez<li>%s</li>r   Tr   )r   r   get_admin_urlr   rt   listget_descendant_pagesr   r   rT   urlsrc   firstr  r   )r4   r   r  r  r   	page_tree
row_markupr   rU   r   page_markups              r7   test_delete_page_confirmationz&PageTest.test_delete_page_confirmation  s   &&(	X'<dCJ 5tFKz+@$vVL"7hO%%dHfii@HtF$?$?$ABB	"
$$Y/ 	F{{x0H! F99++T+:@@B(3x=8##Hk#EF	F 	F 	Fs   A/DDc                    t        ddd      }|j                          t        ddd|      }t        ddd|      }|df|df|dfg}|D ]6  \  }}|j                          | j                  |j	                  d      |       8 y )Nr   rp   ro   child-1rW   r   child-2rz   )r   r   r   r   get_path)r4   homepagepending_child_1pending_child_2expected_treerU   url_paths          r7   test_homepage_with_childrenz$PageTest.test_homepage_with_children  s    v'<dC  "%!	
 &!	
 rNi(i(
 , 	<ND(&&(T]]40(;	<r8   c                    t        ddd      }t        ddd|d      }t        ddd|       t        d	dd      }t        d
dd|      }t        j                  j                         }| j	                         }| j                  |      5  | j                  ||       ddd       | j                  t        j                  j                         |z
  d       y# 1 sw Y   ;xY w)>
        Test that a page can be copied via the admin
        r  rp   ro   r  hello)r   
reverse_id
page_a_a_ar   page_bpage_b_bN   )r   r   rb   r   r   r   	copy_pager   )r4   r  r  r;  page_b_ar   r   s          r7   test_copy_pagezPageTest.test_copy_page3  s     X'<dCz+@$&,BL"7hOX'<dCz+@$&,. ""$&&(	$$Y/ 	-NN68,	- 	++-5q9	- 	-s   CCc                     t        ddd      }|j                          t        ddd      }| j                  | j                               5  | j	                  ||       ddd       y# 1 sw Y   yxY w)zT
        Users should be able to copy a page and paste under the home page.
        r   rp   ro   zroot-aN)r   r   r   r   r>  )r4   r0  root_page_as      r7   test_copy_page_under_homez"PageTest.test_copy_page_under_homeH  sh     v'<dC  "!(,A4H$$T%7%7%9: 	2NN;1	2 	2 	2s   
A&&A/c                 H   t        ddd      }|j                  d      j                  d      }t        |dddj	                  d      d	       | j                  | j                               5  | j                  ||d
      }|j                  d      j                  d      }ddd       | j                  j                  d      j                                |j                  d      d   j                         }| j                  |j                  d       y# 1 sw Y   vxY w)z
        Copying a page with plugins should copy all plugins for the translation
        being copied into the respective translation in the new page.
        	page_a_enrp   ro   rD   rQ   rP   zLink {}rL   )rV   rW   rN   rO   rG   r   Nr   zLink en)r   rS   rT   r   r   r   r   r>  
assertTrueget_pluginsrd   get_bound_pluginr   rN   )r4   cms_pagerZ   r   new_placeholderr[   s         r7   test_copy_page_with_pluginsz$PageTest.test_copy_page_with_pluginsT  s   
 {,A4H//599v9F$!!$'6	
 $$T%7%7%9: 	O~~h1~EH&77=AAvANO	O 	33D9@@BC ,,T215FFHi0	O 	Os   -6DD!c                    ddddd}| j                         }t        ddd      }| j                  |      5  | j                  t        d|j
                        }| j                  j                  ||      }| j                  |j                  d	       d
d
d
       |j                  d      dz   }|j                  d      dz   }| j                  t        j                  j                  ||      j                         d       y
# 1 sw Y   qxY w)zt
        When a page is copied and its slug matches that of another page,
        add "-copy-2" at the end.
        rF   rG   onr   source_sitecopy_permissionscopy_moderationr  rp   ro   r>  r   Nz-copy-2)re   path)r   r   r   r"  r   rt   r   r   r   r   r/  r   r   rb   rc   r   )r4   rw   r   rJ  r   r   new_slugnew_paths           r7   test_copy_page_to_rootzPageTest.test_copy_page_to_rootj  s      $#	
 &&(	x)>E$$Y/ 	8))$X[[IH{{''$7HX1137	8
 $$T*Y6$$T*Y6OO""x"@FFH	
	8 	8s   AD  D	c                    | j                         }t        j                  j                  ddd      }t	        ddd      }t	        ddd|      }t	        d	dd||
      }t	        ddd||
      }t	        ddd||
      }| j                  |      5  | j                  ||d      }d d d        | j                  |      5  | j                  ||d      }	d d d        |dfdf|df|df	df|dff}
|
D ]M  \  }}|j                          | j                  |j                  |       | j                  |j                  d       O y # 1 sw Y   xY w# 1 sw Y   |xY w)NrF   r   r   r   rN   site 1 rootrp   r   r   r   
child-0002)rr   rW   r   rq   
child-0003
child-0005r   rF  r=  00020002000100020002000200030002000400020005)r   r   rb   r   r   r   r>  refresh_from_dbr   rS  site_id)r4   r   site_2site_1_rootsite_2_parent
child_0002
child_0003
child_0005
child_0001
child_0004treerU   rS  s                r7    test_copy_page_to_different_sitez)PageTest.test_copy_page_to_different_site  s   &&(	$$/$X!-1FM#H.CTPVW * 

 !* 

 !* 

 $$Y/ 	P ]QOJ	P
 $$Y/ 	P ]QOJ	P F#$$$$$
  	.JD$  "TYY-T\\1-	.'	P 	P
	P 	Ps   E>EEEc           	         ddddd}| j                         }t        j                  j                  ddd      }t	        dd	d
      }ddd}| j                  d      5  | j                  |      5  | j                  t        d|j                        }|d|j                  z  z  }| j                  j                  |      }| j                  |j                  d       | j                  t        d|j                        }| j                  j                  ||      }| j                  |j                  d       | j!                  t        j                  j#                         |       | j                  t%        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)Nr   rG   rN  rO  rF   r   rX  rY  rp   ro     zgError! The page you're pasting is not translated in any of the languages configured by the target site.)statuscontentr   get_copy_dialog?source_site=%sr   r>  r   utf8)r   r   rb   r   r   r   r   r"  r   rt   rd  r   rT   r   r   r   assertObjectDoesNotExistr   jsonloadsrr  decode)r4   rw   r   re  rf  expected_responser   r   s           r7   =test_copy_page_to_different_site_fails_with_untranslated_pagezFPageTest.test_copy_page_to_different_site_fails_with_untranslated_page  s    $#	
 &&(	$$/$X!-1FMM
 ]]1]% 	((3 --d4E{~~V-0C0CCC;;??84  !5!5s;  --dKP;;++Hd;  !5!5s;--dll.>.>.@v-N  JJx//66v>?%	 	 	 	s%   F>0D1F2!F>2F;	7F>>Gc                    ddddd}| j                         }t        j                  j                  ddd      }t	        dd	d
      }| j                  d      5  | j                  |      5  | j                  t        d|j                        }|d|j                  z  z  }| j                  j                  |      }| j                  |j                  d       | j                  t        d|j                        }| j                  j                  ||      }| j                  |j                  d       d d d        d d d        | j!                  t        j                  j#                         |      }|df|dff}|D ]1  \  }	}
|	j%                          | j                  |	j&                  |
       3 y # 1 sw Y   xY w# 1 sw Y   xY w)Nr   rG   rN  rO  rF   r   rX  rY  rp   r   r   rs  rt  r   r>  r   0001r]  )r   r   rb   r   r   r   r   r"  r   rt   rd  r   rT   r   r   r   assertObjectExistr   rc  rS  )r4   rw   r   re  rf  r   r   site_2_rootrm  rU   rS  s              r7   .test_copy_page_to_different_site_with_no_pagesz7PageTest.test_copy_page_to_different_site_with_no_pages  s    $#	
 &&(	$$/$X!-1FM]]1]% 	<((3 <--d4E{~~V-0C0CCC;;??84  !5!5s;  --dKP;;++Hd;  !5!5s;<	< ,,T\\-=-=-?f,M &!&!

  	.JD$  "TYY-	.)< <	< 	<s%   F9+CF-/F9-F6	2F99Gc                 .   | j                         }t        ddd      }t        ddd|      }t        ddd|      }t        ddd|      }t        ddd      }| j                  |      5  | j                  ||d	
      }ddd       | j                  |      5  | j                  ||d
      }ddd       |dfdf|df|df|df|dff}|D ]1  \  }	}
|	j	                          | j                  |	j                  |
       3 y# 1 sw Y   xY w# 1 sw Y   `xY w)z}
        User should be able to copy a single page and paste it
        in a specific location on another page tree.
        r   rp   ro   rZ  r   r[  r\  
child-0004r   rF  Nr=  r}  0001000100010002000100030001000400010005)r   r   r   r>  rc  r   rS  )r4   r   r   rh  ri  rj  rl  rk  rm  rU   rS  s              r7   #test_copy_page_to_explicit_positionz,PageTest.test_copy_page_to_explicit_position  sL   
 &&(	X'<dC /DdSYZ
 /DdSYZ
 /DdSYZ
 /DdK
$$Y/ 	H
FQGJ	H $$Y/ 	H
FQGJ	H
 V$$$$$
  	.JD$  "TYY-	.#	H 	H	H 	Hs   )C?D?DDc                    | j                         }t        ddd      }t        ddd|      }t        ddd|      }t        ddd|      }t        ddd|       t        d	dd|       t        d
dd|       t        ddd      }t        ddd|       t        ddd|       t        ddd|       | j                  |      5  | j                  ||d      }t	        |j                               }|d   }	|d   }
|d   }ddd       | j                  |      5  | j                  ||d      }t	        |j                               }|d   }|d   }|d   }ddd       |dfdf	df
dfdf|df|df|dfdfdfdf|d ff}|D ]1  \  }}|j                          | j                  |j                  |       3 y# 1 sw Y   xY w# 1 sw Y   rxY w)!z
        User should be able to copy a page with descendants and paste it
        in a specific location on another page tree.
        r   rp   ro   rZ  r   r[  r\  zchild-00050001zchild-00050002zchild-00050003r  zchild-00040001zchild-00040002zchild-00040003r   rF  rG   rF   Nr=  r}  r  000100010001000100010002000100010003r  r  r  000100040001000100040002000100040003r  )	r   r   r   r>  r#  get_child_pagesrc  r   rS  )r4   r   r   rh  ri  rj  rl  rk  child_pageschild_00010001child_00010002child_00010003child_00040001child_00040002child_00040003rm  rU   rS  s                     r7   (test_copy_page_tree_to_explicit_positionz1PageTest.test_copy_page_tree_to_explicit_position   s0   
 &&(	X'<dC /DdSYZ
 /DdSYZ
 /DdSYZ
$&;T*U$&;T*U$&;T*U /DdK
$&;T*U$&;T*U$&;T*U$$Y/ 	,
FQGJz99;<K(^N(^N(^N	, $$Y/ 	,
FQGJz99;<K(^N(^N(^N	, V$^,^,^,$$$^,^,^,$
  	.JD$  "TYY-	.?	, 	,	, 	,s   =F;=G;GGc                 V   t        ddd      }t        ddd|      }t        ddd|      }| j                  | j                               5  | j                  ||d       d	d	d	       | j	                  t
        j                  j                         j                         d
       | j	                  |j                         j                         d       |j                         d   }|j                         d   }| j	                  |j                  d       | j	                  |j                  d       |j                          |j                          | j                  | j                               5  | j                  ||       d	d	d	       |j                          | j	                  |j                         j                         d       | j	                  |j                         j                         d       t        |j                         j                  dd            }|j                         j                          t
        j                  j!                  |      j                          | j	                  t
        j                  j                         j                         d       |j#                         }|j#                         }| j                  | j                               5  | j                  ||d       d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y	xY w)r7  r  rp   ro   r;  r   page_crG   rF  N   rF   r   r  0001000100020001rt   T)flat)pk__inr=  )r   r   r   r>  r   r   rb   r   r   r  rS  r!  rc  r#  r$  values_listrc   reload)r4   r  r;  r  page_dpage_epage_idss          r7   test_copy_self_pagezPageTest.test_copy_self_pageU  s{    X'<dCX'<d6RX'<d6R$$T%7%7%9: 	7NN66AN6	7))+113Q7//17791='')!,'')!,n5&89$$T%7%7%9: 	+NN66*	+ //17791=//17791=335AA$TARS##%,,.8,335))+113Q7$$T%7%7%9: 	7NN66AN6	7 	7+	7 	7	+ 	+	7 	7s$   L/L'LLLL(c                 l
   | j                         }| j                  d      }| j                  |      5  | j                         }| j                  j                  ||       | j                         }| j                  j                  ||       | j                         }| j                  j                  ||       | j                         }| j                  j                  ||       t        t        j                  j                  d            }|d   }|d   }	|d   }
|d   }| j                  j                  t        |j                  z  |
j                  dd      }| j                  |j                  d	       t        j                  j                  |j                  
      }| j                  j                  t        |
j                  z  |	j                  dd      }| j                  |j                  d	       t        j                  j                  |
j                  
      }
| j                  |
j                  d      |d   dz   |d   z          | j                  |
j!                         | j#                         |d   z   dz   |d   z   dz          t        j                  j                  |j                  
      }| j                  |j                  d      |d   dz   |d   z   dz   |d   z          | j                  |j!                         | j#                         |d   z   dz   |d   z   dz   |d   z   dz          |j%                          |	j'                          | j                  |	j                  d      d       t        j                  j                  |
j                  
      }
t        j                  j                  |j                  
      }| j                  j                  t        |
j                  z  ddi      }| j                  |j                  d	       t        j                  j                  |	j                  
      }	| j                  |	j                  d      d       t        j                  j                  |
j                  
      }
| j)                  |
j*                         | j                  |
j                  d      |d          t        j                  j                  |j                  
      }| j                  |j                  d      |d   dz   |d   z          d d d        y # 1 sw Y   y xY w)Nro   rS  r   rG   rF   r=  0)targetr   r   rt   re   r   rz   r   )r   r   r   r   r   r   r#  r   rb   order_byr!   rt   r   r   rT   r/  get_absolute_urlget_pages_rootr!  r   assertFalseis_home)r4   r   r   	page_home
page_data1
page_data2
page_data3pagesr   page1page2page3r   s                r7   test_move_pagezPageTest.test_move_paget  sd   &&(	,,T2$$Y/ :	b..0IKK\95//1JKK\:6//1JKK\:6//1JKK\:6..v67E8D!HE!HE!HE {{''(9EHH(DQVQYQYgjFklHX1137LL$$$1E{{''(9EHH(DQVQYQYgjFklHX1137LL$$$1EU^^D1:f3E3KjY_N`3`a&&(##%
6(::S@:fCUUX[[
 LL$$$1Et$j&83&>FAS&SVY&Y\fgm\n&n &&(##%
6(::S@:fCUUX[[^hio^ppsvv KKM !!#U^^D126LL$$$1ELL$$$1E{{''(9EHH(D)3S(9;HX1137LL$$$1EU^^D126LL$$$1EU]]+U^^D1:f3EFLL$$$1EU^^D1:f3E3KjY_N`3`au:	b :	b :	bs   S.T**T3c                    t        ddd      }|j                          t        ddd      }|j                  d|d}| j                  | j	                               5  | j                  t        d|j                        }| j                  j                  ||      }| j                  |j                  d       | j                  |j                         j                  d	d
      d
       ddd       y# 1 sw Y   yxY w)zi
        Users should not be able to move the home-page
        inside another node of the tree.
        r   rp   ro   root-1r   )r   r   r  	move_pager   rq  rp  N)r   r   rt   r   r   r"  r   r   r   r   r   rw  rT   )r4   r0  home_sibling_1payloadr   r   s         r7   test_user_cant_nest_home_pagez&PageTest.test_user_cant_nest_home_page  s    
 v'<dC  "$X/DdK!!~N$$T%7%7%9: 	F))$X[[IH{{''':HX1137X]]_003?E	F 	F 	Fs   B
C--C6c                    t        ddd      }|j                          t        ddd|      }t        ddd|      }t        ddd      }|ddf|d	d
f|ddf|ddfg}| j                  | j                               5  |j                  dd}| j                  t        d|j                        }| j                  j                  ||      }| j                  |j                  d       |D ]c  \  }	}
}|	j                          |	j                          | j                  |	j                  |
       | j                  |	j                  d      |       e 	 ddd       y# 1 sw Y   yxY w)zf
        Users should be able to move the home-page
        anywhere on the root of the tree.
        r   rp   ro   r,  r-  r.  r  r]  0003rz   0003000100030002rG   )r   r   r  r   N)r   r   r   r   rt   r"  r   r   r   r   r   r   rc  rS  r/  )r4   r0  home_child_1home_child_2r  r3  rw   r   r   rU   	page_pathr4  s               r7   test_move_home_pagezPageTest.test_move_home_page  sp   
 v'<dC  ""!	
 #!	
 %X/DdK VX.vr":y1:y1
 $$T%7%7%9: 	@"++15D))$X[[IH{{''$7HX1137-: @)i**,$$&  I6  t!4h?	@	@ 	@ 	@s   :CEEc                    | j                         }| j                  |      5  | j                         }| j                  j	                  | j                  d      |       t        ddd      }t        dt        j                  d|       t        dt        j                  d|       t        ddd      }t        ddd      }|j                  |j                  d	d
}| j                  j	                  t        |j                  z  |      }| j                  |j                  d       |j                  |j                  d	d
}| j                  j	                  t        |j                  z  |      }| j                  |j                  d       |j                         }|j                         }| j                  |j                         j                         d       d d d        y # 1 sw Y   y xY w)Nro   Parentzcol_three.htmlzChild 1)rr   rW   r   zChild 2zChild 3zChild 4r  )r   r  r   r      )r   r   r   r   r   r   r   r   TEMPLATE_INHERITANCE_MAGICrt   r!   r   r   r  get_descendantsr   )r4   r   r  	page_rootpage_child_3page_child_4rw   r   s           r7   test_move_page_integrityz!PageTest.test_move_page_integrity  s   &&(	$$Y/ 7	E..0IKKT2248)D $H.>EI "== 	 "== 	 'y2BDIL&y2BDIL
 #oo#,,D
 {{''!LOO3H X1137 #oo#,,D
 {{''!LOO3H X1137!((*I'..0L Y668>>@!Do7	E 7	E 7	Es   F1GG%c                 P   | j                  t        j                  j                         j	                         d       t        j                  j                  ddd      }| j                         }|j                  |d<   d|d<   | j                  |j                  d       t        d      |j                     d	   d
   }||d<   | j                         }| j                  |      5  | j                  j                  | j                  d      |      }| j                  || j                  d             t         j                  j#                  |d         }t%        |      5  | 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)z
        Test that a page can edited via the admin when your current site is
        different from the site you are editing and the language isn't available
        for the current site.
        rG   	otherlangrF   )r   rN   rt   rq   r   ra   	LANGUAGESr   coderW   ro   re   r   N)r   r   rb   r   r   r   r   rt   r*   r   r   r   r   r   r   r   r   rT   r#   r   )r4   rq   r   TESTLANGr   r   rU   s          r7   &test_edit_page_other_site_and_languagez/PageTest.test_edit_page_other_site_and_language*  sq    	))+113Q7||""+KA"N**,	 GG	&,	'!$";/8;FC (	*&&(	$$Y/ 	D{{''(=(=d(CYOH  4+H+H+NO<<##y/@#AD!(+ D  !1?CD		D 	DD D		D 	Ds%   #A;F!F?FF	FF%c                     d}| j                  t        dd            }||_        t        |      }| j	                  ||       y )Nzhello worldsampleapp_category_change)rG   args)r   r,   _current_page_cacher+   r   )r4   	mock_pager   rU   s       r7   !test_get_page_from_request_cachedz*PageTest.test_get_page_from_request_cachedA  sF    !	""5DA
 '0#$W-y)r8   FCMS_PERMISSIONc                 b   | j                         }t        ddd      }|j                  dd      }t        rdnd}| j	                         }| j                  d|      }| j                  |      5  |j                  |j                  d      d|j                  d	}| j                  j                  ||      }| j                  ||       d d d        | j                  |      5  | j                  j                  |      }| j                  ||d
       d d d        y # 1 sw Y   SxY w# 1 sw Y   y xY w)NrU   rp   ro   Ffallbackz`<input id="id_overwrite_url" maxlength="255" value="new-url" name="overwrite_url" type="text" />z<input type="text" name="overwrite_url" value="new-url" maxlength="255" aria-describedby="id_overwrite_url_helptext" id="id_overwrite_url">	/new-url/ra   re   overwrite_urlrr   Tr   )r   r   get_content_objr'   r   r   r   ra   r   rr   r   r   r   rT   r   	r4   r   rJ  translationexpected
changelistr   r   r   s	            r7   test_set_overwrite_urlzPageTest.test_set_overwrite_urlJ  s1   &&(	v'<dC..te.D B%	 	 224
++D(;$$Y/ 	7$** ))$/!,'00	I {{'')<H  :6	7 $$Y/ 	?{{x0H(>	? 	?	7 	7	? 	?s   .AD 0D%D"%D.c                    | j                         }t        ddd       t        ddd      }t        ddd      }|j                  dd      }t        r"dj	                  | j                  d|            }n!d	j	                  | j                  d|            }| j                  |      5  | j                  d|      }|j                  |j                  d      d
|j                  d}| j                  j                  ||      }| j                  |j                  d       | j                  ||d       d d d        y # 1 sw Y   y xY w)Nr   rp   ro   boohooFr  z{<ul class="errorlist"><li>Page <a href="{}" target="_blank">boo</a> has the same url 'boo' as current page "hoo".</li></ul>z<ul class="errorlist" id="id_overwrite_url_error"><li>Page <a href="{}" target="_blank">boo</a> has the same url 'boo' as current page "hoo".</li></ul>z/boo/r  r   Tr   )r   r   r  r(   r   r   r   ra   r   rr   r   r   r   r   r   )	r4   r   r  r  r  r   r   r   r   s	            r7   test_set_existing_overwrite_urlz(PageTest.test_set_existing_overwrite_urlh  sA   &&(	F148%!6=%!6=))$)?L fT--dC89	 L fT--dC89	  $$Y/ 
	E//c:H$**T*!('00	I {{'')<HX1137.tD
	E 
	E 
	Es   %B	D77E c                    | j                         }t        dddd      }|j                  dd      }t        rdnd	}| j	                         }| j                  d|      }| j                  |j                  j                  d
      j                                | j                  |      5  |j                  |j                  d      d|j                  d}| j                  j                  ||      }| j!                  ||       d d d        | j                  |      5  | j                  j#                  |      }| j%                  ||d       d d d        y # 1 sw Y   SxY w# 1 sw Y   y xY w)NrU   rp   ro   r  )rW   r  Fr  zP<input id="id_overwrite_url" maxlength="255" name="overwrite_url" type="text" />z{<input type="text" name="overwrite_url" maxlength="255" aria-describedby="id_overwrite_url_helptext" id="id_overwrite_url">znew-url)rS  rz   r  Tr   )r   r   r  r'   r   r   rG  r%  rc   rd   r   ra   r   rr   r   r   r   rT   r   r  s	            r7   test_remove_overwrite_urlz"PageTest.test_remove_overwrite_url  sc   &&(	!%	
 ..te.D 2R	 	 224
++D(; 	,,),<CCEF$$Y/ 	7$** ))$/!#'00	I {{'')<H  :6	7 $$Y/ 	?{{x0H(>	? 	?	7 	7	? 	?s   )AE0E E E)c                 *   | j                         }t        ddd      }t        j                  j	                  |j
                        }| j                         }| j                  t        d|j
                        }ddddd	}| j                  |      5  | j                  j                  ||      }| j                  ||       | j                  |j	                  dd
      j                         d       d d d        | j                  |      5  d|d<   d|d<   | j                  j                  ||      }| j                  ||       | j                  |j	                  dd 
      j                         d       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Napprp   ro   r  advancedrz   	SampleApp	sampleapp)r9  navigation_extendersapplication_urlsapplication_namespacer  r  rG   r  r  )r   r   r   rb   rc   rt   r   r"  r   r   r   r   r   r   )r4   r   rJ  	cms_pagesr   r   r   r   s           r7   #test_advanced_settings_form_apphookz,PageTest.test_advanced_settings_form_apphook  s   &&(	u&;TBLL''8;;'7	335%%dJD$& +%0	
	 $$Y/ 
	{{'')<H  ;7  %0*5 !  %'	
	 $$Y/ 	,.I()13I-.{{'')<H  ;7  %'*. !  %'	 	
	 
		 	s   A E=
A*F	=F	Fz3cms.test_utils.project.sampleapp.cms_apps.SampleAppz=cms.test_utils.project.sampleapp.cms_apps.SampleAppWithConfig)CMS_APPHOOKSr  c                 j   t                t                dt        j                  v rt        j                  d= | j	                          | j                         }t        j                  j                  d      }t        ddd      }t        j                  j                  |j                        }| j                         }| j                  t        d|j                        }d	d	d
|j                  dd}| j                  |      5  | j                   j#                  ||      }| j%                  ||       | j'                  |j                  d
|j(                        j+                         d       d d d        | j                  |      5  d|d<   d|d<   | j                   j#                  ||      }| j%                  ||       | j'                  |j                  dd      j+                         d       d d d        | j                  |      5  d
|d<   d|d<   | j                   j#                  ||      }| j%                  ||       | j'                  |j                  d
|j(                        j+                         d       d d d        | j                  |      5  d}	d|d<   | j                   j#                  ||      }| j'                  |j,                  d       | j/                  ||	       | j'                  |j                  d
|j(                        j+                         d       d d d        | j                  |      5  d	|d<   d	|d<   | j                   j#                  ||      }| j%                  ||       | j'                  |j                  d	d       j+                         d       d d d        t                t                dt        j                  v rt        j                  d= | j	                          y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w)Nz)cms.test_utils.project.sampleapp.cms_appssample)	namespacer  rp   ro   r  r  rz   SampleAppWithConfigr  )r9  r  r  application_configsr  r  rG   r  r  r  zD<ul class="errorlist"><li>Invalid application config value</li></ul>2r  r   )r   r   sysmodulesapphook_clearr   r    rb   r   r   r   rc   rt   r   r"  r   r   r   r   r   r  r   r   r   )
r4   r   
app_configrJ  r  r   r   r   r   r   s
             r7   *test_advanced_settings_form_apphook_configz3PageTest.test_advanced_settings_form_apphook_config  s    	6#++EGH&&(	$,,33h3G
u&;TBLL''8;;'7	335%%dJD$& 5#-==%0
	 $$Y/ 
	{{'')<H  ;7  %:*4*>*> !  %'	
	 $$Y/ 	,7I()1<I-.{{'')<H  ;7  %0*5 !  %'	 $$Y/ 	,AI()1<I-.{{'')<H  ;7  %:*4*>*> !  %'	 $$Y/ 	cN/2I+,{{'')<HX1137.9  %:*4*>*> !  %'	 $$Y/ 	,.I()13I-.{{'')<H  ;7  %'*. !  %'	 	6#++EGHS
	 
		 		 		 		 	sA   A*O6A*P	A4PBP<A*P)6P PPP&)P2c                 f   ddl m} | j                         }t        ddd      }|j	                  d      }| j                  t        d|j                        }| j                  |      5  | j                  j                  |      }ddd       | j                   ||d             y# 1 sw Y   $xY w)	zrAdvanced Page Settings `View on Site` object tool links to the Page's current language
        content preview urlr   )get_object_preview_urlr  rp   ro   r   r  N)cms.toolbar.utilsr  r   r   r  r"  r   rt   r   r   rT   r   )r4   r  r   rJ  cms_page_contentr   r   s          r7   #test_advanced_settings_view_on_sitez,PageTest.test_advanced_settings_view_on_site?  s     	=&&(	u&;TB#33T3B%%dJD$$Y/ 	1{{x0H	1 	H&<=MX\&]^	1 	1s   (B''B0c                 "   | j                         }| j                  |      5  t        t        t        j
                        }| j                         }| j                  |d      }| j                  d|      }| j                         }t        d       } ||       |j                  |t        |j                        |      }| j                  d|j                  v        | j!                  |j                  d   |       d d d        y # 1 sw Y   y xY w)Nro   c                     t        d      S )Nrz   )r
   )r  s    r7   <lambda>z4PageTest.test_form_url_page_change.<locals>.<lambda>V  s    <;K r8   )form_urlr  )r   r   r   r   r   rq   r   get_pagecontent_objr   r   r   change_viewr  rt   rG  context_datar   )	r4   r   content_adminrU   rr  r  r   
middlewarer   s	            r7   test_form_url_page_changez"PageTest.test_form_url_page_changeM  s    &&(	$$Y/ 	J,[%**EM==?D..tT:G//d;H&&(G./KLJw$00WZZ! 1 H OOJ(*?*??@X22:>I	J 	J 	Js   CDDc                    |j                   }|j                  |j                        }fd}	  ||      }|S # t        $ rH}dj	                  d|j
                        }| j                  | j                  d |             Y d }~S d }~ww xY w)Nc                            }|j                  |        |j                          |j                  }|j                          t	        |j
                        dk(  r,t        |j
                  d   t              s|j
                  d   }|S )NrG   r   )feedcloser   finalizelenchildren
isinstancer  )r   parserdocumentparser_classs      r7   _parse_htmlz.PageTest._parse_page_tree.<locals>._parse_htmlc  sq    !^FKKLLN{{H8$$%*!("3"3A"6<'003HOr8   z{}
{}z$Response's content is not valid HTML)rr  ry  charsetr   r   msgfail_formatMessage)r4   r   r  rr  r   domestandardMsgs     `     r7   _parse_page_treezPageTest._parse_page_tree_  s    ""..!1!12
		>g&C 
  	>"//*PRSRWRWXKIId))$<==
	>s   9 	B
=BB
c                    | j                         }t        ddd       t        ddd      }t        ddd|       t        ddd       | j                  |      5  t        d      5  | j	                  t
        d	      }| j                  j                  |      }| j                  |j                  d
       | j                  |t              }t        |      }| j                  d|       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NHomerp   ro   AlphaBetar   Gammar   get_treer   r  u+   (Shift-Klick für erweiterte Einstellungen))r   r   r   force_languager"  r   r   rT   r   r   r(  r?   r   assertIn)r4   r   alphar   r   parsedrr  s          r7   test_page_tree_regression_5892z'PageTest.test_page_tree_regression_5892v  s    &&(	F148G%:DAF14FG2D9$$Y/ 	V% V--k:F;;??84  !5!5s;..xF[.\#F+KWUV	V 	VV V	V 	Vs%   D$BC7&D7D 	<DDc                    | j                         }| j                  t        d      }t        ddd       t        ddd      }t        ddd|       t        ddd       d	}| j	                  |      5  | j
                  j                  |      }| j                  |j                  d
       | j                  |t              }t        |      }| j                  ||       | j                  d|       d d d        y # 1 sw Y   y xY w)Nr.  r*  rp   ro   r+  r,  r   r-  z/<li>
Home
</li><li>
Alpha
</li><li>
Gamma
</li>r   r/  <li>
Beta
</li>)r   r"  r   r   r   r   rT   r   r   r(  r.   r   r1  assertNotIn)r4   r   r   r2  rm  r   r3  rr  s           r7    test_page_get_tree_endpoint_flatz)PageTest.test_page_get_tree_endpoint_flat  s    &&(	%%k:>F148G%:DAF14FG2D9! 	 $$Y/ 	;{{x0HX1137**8BR*SF'GMM$(0':	; 	; 	;s   0A>C77D c                 R   | j                         }| j                  t        d      }t        ddd       t        ddd      }t        ddd|       t        ddd      }t        d	dd|       t        d
dd       d}d|j                  |j                  gi}| j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  |t              }t        |      }	| j                  ||	       d d d        y # 1 sw Y   y xY w)Nr.  r*  rp   ro   r+  r,  r   r-  DeltaThetazt<li>
Home
</li><li>
Alpha<ul>
<li>
Beta
</li>
</ul>
</li><li>
Gamma<ul>
<li>
Delta
</li>
</ul>
</li><li>
Theta
</li>openNodes[]rw   r   r/  )r   r"  r   r   rt   r   r   rT   r   r   r(  r.   r   r1  )
r4   r   r   r2  gammarm  rw   r   r3  rr  s
             r7   "test_page_get_tree_endpoint_nestedz+PageTest.test_page_get_tree_endpoint_nested  s   &&(	%%k:>F148G%:DAF14FG%:DAG2DGG2D9! 	 EHHehh/
 $$Y/ 	){{xd;HX1137**8BR*SF'GMM$(	) 	) 	)s   &A.DD&c                 F   | j                         }| j                         }t        ddd       t        ddd      }t        ddd|       t        ddd       | j                  |      5  | j                  j                  |dd	i
      }| j                  |j                  d       | j                  |t              }t        |      }| j                  d|       | j                  d|       | j                  d|       | j                  d|       d d d        y # 1 sw Y   y xY w)Nr*  rp   ro   r+  r,  r   r-  qr2  r=  r   r/  z<li>
Alpha
</li>z<li>
Home
</li>r6  z<li>
Gamma
</li>)r   r   r   r   r   rT   r   r   r(  r.   r   r1  r7  )r4   r   r   r2  r   r3  rr  s          r7   test_page_changelist_searchz$PageTest.test_page_changelist_search  s   &&(	002F148G%:DAF14FG2D9$$Y/ 	<{{xsGnEHX1137**8BR*SF'GMM.80':0':17;	< 	< 	<s   (B&DD c                    | j                         }| j                         }|j                  d      j                  d      }|j                  d      j                  d      }|ddd}t	        di |}t	        di |}t	        di |}t        | |      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)Nro   right-columnrQ   rD   rP   ri   rG   r   rZ   r   rF   r=  rp  s?   This placeholder already has the maximum number of plugins (2).r=   r   r   rS   rT   r   r$   r%   r   r   get_move_plugin_urir   r   r   r   rr  )r4   r   rJ  source_placeholdertarget_placeholderrw   plugin_1plugin_2plugin_3r   r   s              r7    test_global_limit_on_plugin_movez)PageTest.test_global_limit_on_plugin_move  s   &&(	==?%66t<@@n@U%66t<@@f@M-'

 %%%%%%dI. 	w*4+?+?@ w**8aM_*`33H=;;++Hd;  !5!5s;**8aM_*`33H=;;++Hd;  !5!5s;**8aM_*`33H=;;++Hd;  !5!5s;  !1!13uvw	w 	ww w	w 	ws%   G=,D4G1 G=1G:	6G==Hc                 B   | j                         }| j                         }|j                  d      j                  d      }|j                  d      j                  d      }|ddd}t	        di |}t	        di |}t        | |      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)Nro   rD  rQ   rD   rI   ri   rG   rE  r   rF   rp  sL   This placeholder already has the maximum number (1) of allowed Text plugins.r=   rF  )
r4   r   rJ  rH  rI  rw   rJ  rK  r   r   s
             r7   test_type_limit_on_plugin_movez'PageTest.test_type_limit_on_plugin_move  s   &&(	==?%66t<@@n@U%66t<@@f@M-'

 %%%%dI. 	r*4+?+?@ 
r**8aM_*`33H=;;++Hd;  !5!5s;**8aM_*`33H=;;++Hd;  !5!5s;  !1!1!pr
r	r 	r
r 
r	r 	rs%   F!CF	8F	F	FFsqlitedefaultENGINEzThis test only works in SQLITET)USE_THOUSAND_SEPARATORUSE_L10Nc                    ddl m} | j                         }t        ddd|      }|j	                         5 }|j                  d       d d d        t        ddd||d	      }t        d
dd||d
	      }| j                  |j                  dkD         | j                  |j                  dkD         | j                  |j                  dkD         | j                  |j                  dkD         | j                  |      5  |j                  |j                  gdd}| j                  t        d      }| j                  j                  ||      }	| j                  |	j                  d       | j!                  |	d|j                  d       | j#                  |	d|j                          d d d        | j                  |      5  |j                  |j                  dgdd}| j                  t        d      }| j                  j                  ||      }	| j                  |	j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr   )
connectionr   rp   fr
created_byz;UPDATE SQLITE_SEQUENCE SET seq = 1001 WHERE name="cms_page"r   )rY  r   re   zgrand-child-page  )r<  rW   r.  r=  r   zpage=,zparent_page=)	django.dbrV  r   r   cursorexecuterG  r   r   rt   r"  r   r   rT   r   r   assertNotContainsr   )
r4   rV  
admin_userr   crU   r   rw   r   r   s
             r7   (test_page_tree_render_localized_page_idsz1PageTest.test_page_tree_render_localized_page_ids	  s+    	) '')
)4J
   	UAIIST	U !!
 !!#
 	$'d*+$'d*+ $$Z0 	D$(GGTWW#54HD))+zBH{{xd;HX1137""8uTWWQK-@AL	*BC	D $$Z0 	8$(GG{#<$OD))+zBH{{xd;HX1137		8 	8S	U 	U8	D 	D	8 	8s%   H4;B*I>A-I4H>I
IN)6r:   r;   r<   r   r   r   r   r   r   r   r   r   r   r  r  r*  r5  r@  rC  rL  rV  rn  r{  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r
  r  r(  r4  r8  r?  rB  rM  rO  r   r   	DATABASESrT   lowerrb  r=   r8   r7   r   r      s   	RN&)VP::BF?P@(:KxI&`&#:JF$<2:*
21,
61.f!F".H.B3.j7>=b~F$(@T9EvD.* e,? -?: e,E -E@ e,"? -"?H e,% -%N AK
 ``D_J$.V(;.)><&w:r2 H&&**9599(CIIKK( dTB88 C	
88r8   r   c                       e Zd Zd Zd Zd Zy)PageActionsTestCasec                     | j                         | _        t        j                  j	                  d      | _        t        dddd| j
                  | j                        | _        y )NrG   r  zMy Pagerp   ro   ok)re   rq   rY  )r   r   r   rb   rT   rq   r   rU   r   s    r7   setUpzPageActionsTestCase.setUpJ  sO    '')
LL$$$*	,dtzz3	r8   c                 D   | j                  | j                        5  dddddd}| j                  t        j                  j                         j                         d       | j                  j                  | j                  t        d      |      }t        t        j                  j                  d	            }| j                  |d
| d       | j                  t        j                  j                         j                         d       ddd       y# 1 sw Y   yxY w)zWhen adding the edit parameter to the add page form, the user should be redirected to the edit endpoint
        of the new page.another pagetype1rp   ro   rG   ra   re   rr   rW   editaddr=  r`   zhref=""rF   N)r   r   r   r   rb   r   r   r   r   r"  r   r&   rT   r   r4   r   r   redirect_urls       r7   test_add_page_redirectz*PageActionsTestCase.test_add_page_redirectR  s     $$TZZ0 	< (F[ I
 T\\--/557;{{''"";6 ( H /{/B/B/F/F^/F/\]LF<.*BCT\\--/557;	< 	< 	<s   C1DDc                    | j                  | j                        5  dddddd}| j                  t        j                  j                         j                         d       | j                  j                  | j                  t        d      |	      }| j                  t        d
      dz   }| j                  ||       | j                  t        j                  j                         j                         d       d d d        y # 1 sw Y   y xY w)Nrk  rl  rp   ro   r   rm  rG   ro  r=  r  ?language=enrF   )r   r   r   r   rb   r   r   r   r   r"  r   r   rq  s       r7   test_add_page_no_redirectz-PageActionsTestCase.test_add_page_no_redirecte  s    $$TZZ0 	< (F[ I
 T\\--/557;{{''"";6 ( H  --k<H>YL  <8T\\--/557;	< 	< 	<s   CDDN)r:   r;   r<   ri  rs  rv  r=   r8   r7   rf  rf  I  s    3<&<r8   rf  c                   8    e Zd Zd Zd Zd Zd	dZd Zd Zd Z	y)
PermissionsTestCasec                 t    	 | j                  |dd       y # t        $ r | j                  |dd       Y y w xY w)NzR<h2 id="pagepermission_set-2-heading" class="inline-heading">Page permissions</h2>Tr   <h2>Page permissions</h2>)r   AssertionErrorr4   r   s     r7   assertContainsPermissionsz-PermissionsTestCase.assertContainsPermissionsx  sM    		Rd   
  	R*EDQ	R    77c                 t    	 | j                  |dd       y # t        $ r | j                  |dd       Y y w xY w)NzR<h2 id="pagepermission_set-1-heading" class="inline-heading">Page permissions</h2>Tr   rz  )r_  r{  r|  s     r7   assertNotContainsPermissionsz0PermissionsTestCase.assertNotContainsPermissions  sM    		U""d # 
  	U""8-Ht"T	Ur~  c                 B    t        dd|j                         dd      }|S )Nr   r^   rp   )re   rr   )r   r  )r4   rU   r  s      r7   _add_translation_to_pagez,PermissionsTestCase._add_translation_to_page  s)    )KKM!*
 r8   Nc                 f    |sd}t         j                  j                  |      j                         S )Nrn   r9  )r   rb   rc   rd   )r4   r9  s     r7   _page_existsz PermissionsTestCase._page_exists  s+    &J||""j"9@@BBr8   c                 \    t        j                  j                  di |j                         S r   )r   rb   rc   rd   )r4   rv   s     r7   _page_permission_existsz+PermissionsTestCase._page_permission_exists  s%    %%,,6v6==??r8   c                     d|v rd}nd}i ddddddd	dd
dddd|dddddddddddddddddd}d}|j                         D ]  \  }}||vrd| }|||<    |S )Nr   rG   r   rW   ro   limit_visibility_in_menurz   pagepermission_set-TOTAL_FORMS pagepermission_set-INITIAL_FORMS pagepermission_set-MAX_NUM_FORMS pagepermission_set-2-TOTAL_FORMS"pagepermission_set-2-INITIAL_FORMS"pagepermission_set-2-MIN_NUM_FORMS"pagepermission_set-2-MAX_NUM_FORMSrZ  zpagepermission_set-2-0-idzpagepermission_set-2-0-pagezpagepermission_set-2-0-userzpagepermission_set-2-0-groupz!pagepermission_set-2-0-can_changerN  z-pagepermission_set-2-0-can_change_permissionszpagepermission_set-2-0-grant_onr  rW   r  zpagepermission_set-2-0-itemsr4   rv   initialrw   
non_inlineattrvalues          r7   _get_page_permissions_dataz.PermissionsTestCase._get_page_permissions_data  s   6>GG

&
 -a
 /	

 /
 /
 1'
 1!
 1$
 (
 *2
 *2
 +B
 0
 <T
  .q!
& >
!<<> 	KD%:%07DJ	 r8   c                     d|v rd}nd}i ddddddd	|d
ddddddddddddddddddddddd}d}|j                         D ]  \  }}||vrd| }|||<    |S )Nr   rG   r   rW   ro   r  rz   r  r  z pagepermission_set-MIN_NUM_FORMSr  rZ  zpagepermission_set-0-idzpagepermission_set-0-pagezpagepermission_set-0-userzpagepermission_set-0-groupzpagepermission_set-0-can_viewrN  zpagepermission_set-0-grant_onr  r  r  r  r  r  zpagepermission_set-0-r  r  s          r7    _get_page_view_restrictions_dataz4PermissionsTestCase._get_page_view_restrictions_data  s   6>GG

&
 -a
 /	

 /
 /
 &r
 (
 (
 )"
 ,T
 ,Q
 /
 1!
 1!
  1$!
& >
!<<> 	KD%:%.tf5DJ	 r8   r   )
r:   r;   r<   r}  r  r  r  r  r  r  r=   r8   r7   rx  rx  w  s*    
R
UC
@Br8   rx  Tr  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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)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d. Z0d/ Z1d0 Z2d1 Z3d2 Z4d3 Z5y4)5PermissionsOnGlobalTestz
    Tests all user interactions with the page admin
    while permissions are set to True and user has
    global permissions.
    c                 F   t        ddg      }| j                         }| j                  |d       | j                  |d       | j	                  |      5  | j
                  j                  |      }| j                  |j                  d       | j                  |dd	       d
d
d
       | j                         }| j	                  |      5  | j
                  j                  |      }| j                  |j                  d       d
d
d
       y
# 1 sw Y   kxY w# 1 sw Y   y
xY wz
        User can see the "Pages" section the admin
        if he has change permissions on the Page model
        and he has global change permissions.
        app_listcmsr  change_pageT
can_changer   z6<a href="/en/admin/cms/pagecontent/">Page contents</a>r   N)r,   "get_staff_user_with_no_permissionsadd_permissionadd_global_permissionr   r   rT   r   r   r   r   r4   r   
staff_userr   s       r7   test_pages_in_admin_indexz1PermissionsOnGlobalTest.test_pages_in_admin_index  s
    !5':<<>
J6"":$"?$$Z0 	{{x0HX1137H   	 002$$Z0 	8{{x0HX1137	8 	8	 		8 	8s   AD
8DDD c                    t        ddg      }| j                         }| j                  |d       | j                  |d       | j	                  |      5  | j
                  j                  |      }| j                  |j                  d       ddd       | j                         }| j	                  |      5  | j
                  j                  |      }| j                  |j                  d	       ddd       y# 1 sw Y   kxY w# 1 sw Y   yxY w
z
        User can't see the "Pages" section the admin
        if he does not have change permissions on the Page model
        and/or does not have global change permissions.
        r  r  r  r  Fr  i  N  )
r,   r  r  r  r   r   rT   r   r   r   r  s       r7   test_pages_not_in_admin_indexz5PermissionsOnGlobalTest.test_pages_not_in_admin_index  s     !5':<<>
J6"":%"@$$Z0 	8{{x0HX1137	8 002$$Z0 	8{{x0HX1137	8 	8	8 	8	8 	8s   8C768D7D Dc                    | j                         }| j                  d|      }| j                         }| j                         }| j	                  d      }| j                  |d       | j                  |d       | j                  |      5  | j                  j                  ||      }| j                  ||       | j                  | j                  d             ddd       y# 1 sw Y   yxY wz
        User can edit page settings if he has change permissions
        on the Page model and and he has global change permissions.
        ro   permissions-2r   r  Tr  N)get_permissions_test_pager   r   r  rx   r  r  r   r   r   r   rG  rg   r4   rU   r   r   r  rw   r   s          r7    test_user_can_edit_page_settingsz8PermissionsOnGlobalTest.test_user_can_edit_page_settings  s    
 --/++D$7335<<>
"""8J6"":$"?$$Z0 	L{{''$7H  ;7OOD44/4JK	L 	L 	Ls   AC$$C-c                 *   | j                         }| j                  d|      }| j                         }| j                  d      }| j	                  |d       | j                  |d      }| j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  | j                  d             ddd       | j                  |d       d	|_        |j                  d
g       | j                  |      5  | 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 edit page settings if he does not
        have change permissions on the Page model and/or
        does not have global change permissions.
        ro   r  r   r  Fr  r  NTr  update_fields)r  r   r  rx   r  r  r   r   r   r   r   r  rg   remove_permissionr  r   r4   rU   r   r  rw   gpr   s          r7   !test_user_cant_edit_page_settingsz9PermissionsOnGlobalTest.test_user_cant_edit_page_settings2  sw    --/++D$7<<>
"""8J6''
u'E$$Z0 	M{{''$7HX1137T55?5KL	M
 	z=9
|n-$$Z0 	M{{''$7HX1137T55?5KL	M 	M	M 	M	M 	Ms   ;AE=AF	=F	Fc                     | j                         }| j                  t        d|j                        }| j	                         }| j                         }| j                  d      }| j                  |d       | j                  |dd       | j                  |      5  | j                  j                  ||      }| j                  ||       | j                  | j                  d             ddd       y# 1 sw Y   yxY wz
        User can edit advanced page settings if he has change permissions
        on the Page model, global change permissions and
        global change advanced settings permissions.
        r  r  r  r  Tr  can_change_advanced_settingsN)r  r"  r   rt   r   r  rx   r  r  r   r   r   r   rG  r  r  s          r7   )test_user_can_edit_advanced_page_settingszAPermissionsOnGlobalTest.test_user_can_edit_advanced_page_settingsO  s     --/%%dJ@335<<>
""o">J6"")- 	# 	
 $$Z0 	K{{''$7H  ;7OOD---IJ	K 	K 	Ks   AC44C=c                 J   | j                         }| j                  t        d|j                        }| j	                         }| j                  d      }| j                  |d       | j                  |dd      }| j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  | j                  d             d	d	d	       | j                  |d       d|_        |j#                  d
g       | j                  |      5  | 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 edit advanced page settings if he does not
        have change permissions on the Page model,
        does not have global change permissions and/or
        does not have global change advanced settings permissions.
        r  r  r  r  TFr  r  Nr  r  )r  r"  r   rt   r  rx   r  r  r   r   r   r   r   r  r  r  r  r   r  s          r7   *test_user_cant_edit_advanced_page_settingszBPermissionsOnGlobalTest.test_user_cant_edit_advanced_page_settingsh  s    --/%%dJ@<<>
""o">J6''). ( 
 $$Z0 	L{{''$7HX1137T../.JK	L
 	z=9
|n-$$Z0 	L{{''$7HX1137T../.JK	L 	L	L 	L	L 	Ls   AF*AFFF"c                    | j                         }| j                  t        d|j                        }| j	                         }| j                         }| j                  |d       | j                  |d       | j                  |dd       | j                  |      5  ddi}| j                  j                  ||d      }| j                  ||       | j                  | j                                d	d	d	       y	# 1 sw Y   y	xY w)
z
        User can delete an empty page if he has delete & change permissions
        on the Page model and he has global delete & change permissions.
        r!  r  delete_pageTr  
can_deleter   yesfollowN)r  r"  r   rt   r   r  r  r  r   r   r   r   r  r  r  s          r7   test_user_can_delete_empty_pagez7PermissionsOnGlobalTest.test_user_can_delete_empty_page  s    
 --/%%dHdgg>335<<>
J6J6"":$4"P$$Z0 	2E?D{{''$t'DH   ;7T..01	2 	2 	2s   AC88Dc                 .   | j                         }| j                  t        d|j                        }| j	                         }| j                  |d       | j                  |dd      }| j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  | j                                d	d	d	       | j                  |d       d|_        |j!                  d
g       | j                  |      5  ddi}| 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)
        User can't delete an empty page if he does not
        have delete permissions on the Page model and/or
        does not have global delete permissions.
        r!  r  TFr  r   r  r  Nr  r  )r  r"  r   rt   r  r  r  r   r   r   r   r   rG  r  r  r  r   r4   rU   r   r  r  rw   r   s          r7    test_user_cant_delete_empty_pagez8PermissionsOnGlobalTest.test_user_cant_delete_empty_page  sh    --/%%dHdgg><<>
J6''
tPU'V$$Z0 	1E?D{{''$7HX1137OOD--/0	1 	z=9
|n-$$Z0 	1E?D{{''$7HX1137OOD--/0	1 	1	1 	1	1 	1s   9AE?AF?FFc                 N   | j                         }| j                  t        d|j                        }| j	                         }| j                         }| j                  |       | j                  |d       | j                  |d       | j                  |d       | j                  |dd       | j                  |      5  ddi}| j                  j                  ||d	      }| j                  ||       | j                  | j                                d
d
d
       y
# 1 sw Y   y
xY w)z
        User can delete a page with plugins if he has delete & change permissions
        on the Page model, delete permissions on the plugins in the page
        translations and global delete & change permissions.
        r!  r  r  delete_linkTr  r   r  r  N)r  r"  r   rt   r   r  r\   r  r  r   r   r   r   r  r  r  s          r7   #test_user_can_delete_non_empty_pagez;PermissionsOnGlobalTest.test_user_can_delete_non_empty_page  s	    --/%%dHdgg>335<<>
  &J6J6J6"":$4"P$$Z0 	2E?D{{''$t'DH   ;7T..01	2 	2 	2s   >ADD$c                 t   | j                         }| j                  t        d|j                        }| j	                         }| j                  |       | j                  |d       | j                  |d       | j                  |dd      }| j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  | j                                d	d	d	       | j                  |d       d|_        |j#                  d
g       | j                  |      5  ddi}| 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)  
        User can't delete a page with plugins if he
        does not have delete permissions on the Page model,
        does not have delete permissions on the plugins
        in the page translations, and/or does not have
        global delete permissions.
        r!  r  r  Tr  r   r  r  Nr  r  )r  r"  r   rt   r  r\   r  r  r  r   r   r   r   r   rG  r  r  r   r  s          r7   $test_user_cant_delete_non_empty_pagez<PermissionsOnGlobalTest.test_user_cant_delete_non_empty_page  s    --/%%dHdgg><<>
  &J6z=9''
tPT'U$$Z0 	1E?D{{''$7HX1137OOD--/0	1 	z=9
|n-$$Z0 	1E?D{{''$7HX1137OOD--/0	1 	1	1 	1	1 	1s   AF"=AF."F+.F7c                 :   | j                         }| j                  |      }| j                  t        d|j                        }| j                         }| j                         }| j                  |d       | j                  |d       | j                  |dd       | j                  |      5  d|j                  i}| j                  j                  ||      }| j                  ||       | j                  | j                                ddd       y# 1 sw Y   yxY w)z
        User can delete an empty translation if he has
        delete & change permissions on the Page model and he has
        global delete & change permissions.
        r!  r  r  Tr  rW   N)r  r  r"  r   rt   r   r  r  r  r   rW   r   r   r   r  rg   r4   rU   r  r   r   r  rw   r   s           r7   &test_user_can_delete_empty_translationz>PermissionsOnGlobalTest.test_user_can_delete_empty_translation  s     --/33D9%%k8[^^L335<<>
J6J6"":$4"P$$Z0 	9 4 45D{{''$7H  ;7T5578	9 	9 	9s   ,ADDc                    | j                         }| j                  |      }| j                  t        d|j                        }| j                         }| j                  |d       | j                  |d       | j                  |dd      }| j                  |      5  d|j                  i}| j                  j                  ||      }| j                  |j                  d       | j                  | j                                d	d	d	       | j!                  |d       d|_        |j%                  d
g       | j                  |      5  d|j                  i}| 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)
        User can't delete an empty translation if he does not
        have delete permissions on the Page model and/or
        does not have global delete permissions.
        r!  r  r  TFr  rW   r  Nr  r  )r  r  r"  r   rt   r  r  r  r   rW   r   r   r   r   rG  rg   r  r  r   )r4   rU   r  r   r  r  rw   r   s           r7   'test_user_cant_delete_empty_translationz?PermissionsOnGlobalTest.test_user_cant_delete_empty_translation  s    --/33D9%%k8[^^L<<>
J6J6''
tPU'V$$Z0 	8 4 45D{{''$7HX1137OOD4467	8 	z=9
|n-$$Z0 	8 4 45D{{''$7HX1137OOD4467	8 	8	8 	8	8 	8s   A&F6A&G6F?Gc                    | j                         }| j                  |      }| j                  t        d|j                        }| j                         }| j                         }| j                  ||j                         | j                  |d       | j                  |d       | j                  |d       | j                  |dd       | j                  |      5  d|j                  i}| j                  j                  ||      }| j                  ||       | j                  | j!                                d	d	d	       y	# 1 sw Y   y	xY w)
z
        User can delete a translation with plugins if he has delete & change permissions
        on the Page model, delete permissions on the plugins in the translation
        and global delete & change permissions.
        r!  r   r  r  r  Tr  rW   N)r  r  r"  r   rt   r   r  r\   rW   r  r  r   r   r   r   r  rg   r  s           r7   *test_user_can_delete_non_empty_translationzBPermissionsOnGlobalTest.test_user_can_delete_non_empty_translation5  s$    --/33D9%%k8[^^L335<<>
  0D0D EJ6J6J6"":$4"P$$Z0 	9 4 45D{{''$7H  ;7T5578	9 	9 	9s   AE  E	c                 h   | j                         }| j                  |      }| j                  t        d|j                        }| j                         }| j                  ||j                         | j                  |d       | j                  |d       | j                  |dd       | j                  |      5  d|j                  i}| j                  j                  ||      }| j                  |j                  d       | j!                  | j#                                d	d	d	       y	# 1 sw Y   y	xY w)
  
        User can't delete a translation with plugins if he
        does not have delete permissions on the Page model,
        does not have delete permissions on the plugins in the translation,
        and/or does not have global delete permissions.
        r!  r   r  r  Tr  rW   r  N)r  r  r"  r   rt   r  r\   rW   r  r  r  r   r   r   r   r   rG  rg   r4   rU   r  r   r  rw   r   s          r7   +test_user_cant_delete_non_empty_translationzCPermissionsOnGlobalTest.test_user_cant_delete_non_empty_translationO  s
    --/33D9%%k8[^^L<<>
  0D0D EJ6z=9"":$4"P$$Z0 	8 4 45D{{''$7HX1137OOD4467	8 	8 	8s   9A&D((D1c                    | j                         }| j                         }| j                  d|      }| j                  |d       | j	                  |dd       | j                  |      5  |j                          ddi}| j                  j                  ||      }| j                  |d       | j                  |j                         d       ddd       y# 1 sw Y   yxY w)	z
        User can change a page's template if he
        has change permissions on the Page model and both
        global change and change advanced settings permissions.
        ro   r  Tr  rr   simple.htmlz%The template was successfully changedN)r  r  get_page_change_template_urir  r  r   r   r   r   r   r   r   r4   rU   r  r   rw   r   s         r7   test_user_can_change_templatez5PermissionsOnGlobalTest.test_user_can_change_templateh  s     --/<<>
44T4@J6"":$]a"b$$Z0 	A&&(.D{{''$7H*QRT..0-@	A 	A 	As   *A#CCc                    | j                         }| j                         }| j                  d|      }| j                  |d       | j	                  |d       | j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  |j                         d       d	d	d	       y	# 1 sw Y   y	xY w)
z
        User can't change a page's template if he
        does not have change permissions on the Page model,
        global change permissions and/or global change advanced settings
        permissions.
        ro   r  Tr  rr   r  r  rp   N)r  r  r  r  r  r   r   r   r   r   r   r  s         r7   test_user_cant_change_templatez6PermissionsOnGlobalTest.test_user_cant_change_template|  s     --/<<>
44T4@J6"":$"?$$Z0 	I.D{{''$7HX1137T..02GH		I 	I 	Is   )ACCc                 r   | j                         }| j                  t        d|j                        }| j	                         }| j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  |dd       ddd       y# 1 sw Y   yxY w)	zM
        All staff users can see the permissions summary for a page.
        get_permissionsr   truer   z,<p>Page doesn't inherit any permissions.</p>Tr   N)r  r"  r   rt   r  r   r   r   r   r   r   )r4   rU   r   r  rw   r   s         r7   +test_user_can_view_page_permissions_summaryzCPermissionsOnGlobalTest.test_user_can_view_page_permissions_summary  s     --/%%d,=twwG<<>
$$Z0 		F#D{{''$7HX1137>   		 		 		s   AB--B6c                 t   | j                         }| j                  t        d|j                        }| j	                         }| j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  |d|z         ddd       y# 1 sw Y   yxY w)zO
        Non staff users can't see the permissions summary for a page.
        r  r   r  .  z/en/admin/login/?next=%sN)r  r"  r   rt   get_standard_userr   r   r   r   r   r   )r4   rU   r   non_staff_userrw   r   s         r7   ,test_user_cant_view_page_permissions_summaryzDPermissionsOnGlobalTest.test_user_cant_view_page_permissions_summary  s     --/%%d,=twwG//1$$^4 	RF#D{{''$7HX1137  +E+PQ	R 	R 	Rs   AB..B7c                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  |d	d	d	
       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                   d       | j#                  ||       | j%                  | j'                  |             ddd       y# 1 sw Y   yxY wz
        User can add page permissions if he has
        change permissions on the Page model,
        add permissions on the PagePermission model,
        global change permission and global change permissions permission.
        r  ru  rX  rU   user1	_continuer  add_pagepermissionTr  can_change_permissionsr  r  r  N)r   r  r"  r   rt   r  get_staff_page_userr  r  r  r   r   rT   r}  r   r   r   r   rG  r  r4   r   rU   r   r  staff_user_2rw   r   s           r7   "test_user_can_add_page_permissionsz:PermissionsOnGlobalTest.test_user_can_add_page_permissions  sl    ""$--/%%dJ@>Q<<>
//5/A.. / 
  [J6J(<=""#')-	 	# 	
 $$Z0 	M{{x0H**84{{''$7HX1137  84OOD88l8KL	M 	M 	Ms   BE>>Fc                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  |d	d
d	       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j!                  |             ddd       y# 1 sw Y   yxY wa)  
        User can't add page permissions if he
        does not have change permissions on the Page model,
        does not have add permissions on the PagePermission model,
        does not have global change permission,
        and/or does not have global change permissions permission.
        r  ru  rX  r  r  r  r  r  TFr  r  N)r   r  r"  r   rt   r  r  r  r  r  r   r   rT   r  r   r  r  r  s           r7   #test_user_cant_add_page_permissionsz;PermissionsOnGlobalTest.test_user_cant_add_page_permissions  sF    ""$--/%%dJ@>Q<<>
//5/A.. / 
  [J6J(<=""#()-	 	# 	
 $$Z0 	N{{x0H--h7KKXt,T99|9LM		N 	N 	Ns   A*EEc                 V   | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||d      }| j                  |j                  |j                  |j                  d      }d|d	<   | j                  |d
       | j                  |d       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | 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 page permissions if he has
        change permissions on the Page model,
        change permissions on the PagePermission model,
        global change permission and global change permissions permission.
        r  ru  rX  Tr  rU   r  FrU   r  r   r  r  r  r  change_pagepermissionr  r  r  r  N)r   r  r"  r   rt   r  r  add_page_permissionr  r  r  r   r   rT   r}  r   r   r   r   rG  r  	r4   r   rU   r   r  r  
permissionrw   r   s	            r7   #test_user_can_edit_page_permissionsz;PermissionsOnGlobalTest.test_user_can_edit_page_permissions  s    ""$--/%%dJ@>Q<<>
//5/A--#' . 

 ..}}#(	 / 
  [J6J(?@""#')-	 	# 	
 $$Z0 	{{x0H**84{{''$7HX1137  84OO,,%+0 - 	 	 	s   =BFF(c                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||d      }| j                  |j                  |j                  |j                  d      }d|d	<   | j                  |d
       | j                  |d       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j!                  | j#                  |d             ddd       y# 1 sw Y   yxY wa-  
        User can't edit page permissions if he
        does not have change permissions on the Page model,
        does not have change permissions on the PagePermission model,
        does not have global change permission,
        and/or does not have global change permissions permission.
        r  ru  rX  Tr  Fr  r  r  r  r  r  r	  N)r   r  r"  r   rt   r  r  r
  r  r  r  r   r   rT   r  r   r  r  r  s	            r7   $test_user_cant_edit_page_permissionsz<PermissionsOnGlobalTest.test_user_cant_edit_page_permissions*	  sw    ""$--/%%dJ@>Q<<>
//5/A--#' . 

 ..}}#(	 / 
  [J6J(?@""#()-	 	# 	
 $$Z0 		{{x0H--h7KKXt,,,%+0 - 			 		 		s   =A+E11E:c                 R   | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||      }| j                  |j                  |j                  |j                  d      }d|d<   | j                  |d	       | j                  |d
       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j!                  |j"                  d       | j%                  ||       | j'                  | j)                  |             ddd       y# 1 sw Y   yxY wz
        User can delete page permissions if he has
        change permissions on the Page model,
        delete permissions on the PagePermission model,
        global change permission and global change permissions permission.
        r  ru  rX  r  rU   rN  rU   r  r   DELETEr  r  r  delete_pagepermissionTr  r  r  N)r   r  r"  r   rt   r  r  r
  r  r  r  r   r   rT   r}  r   r   r   r   r  r  r  s	            r7   %test_user_can_delete_page_permissionsz=PermissionsOnGlobalTest.test_user_can_delete_page_permissionsZ	  s    ""$--/%%dJ@>Q<<>
//5/A--<d-K
..}}	 / 
  [J6J(?@""#')-	 	# 	
 $$Z0 	N{{x0H**84{{''$7HX1137  84T99|9LM	N 	N 	Ns   <BFF&c                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||      }| j                  |j                  |j                  |j                  d      }d|d<   | j                  |d	       | j                  |d
       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j!                  | j#                  |             ddd       y# 1 sw Y   yxY wa/  
        User can't delete page permissions if he
        does not have change permissions on the Page model,
        does not have delete permissions on the PagePermission model,
        does not have global change permission,
        and/or does not have global change permissions permission.
        r  ru  rX  r  rN  r  r  r  r  r  TFr  r  N)r   r  r"  r   rt   r  r  r
  r  r  r  r   r   rT   r  r   rG  r  r  s	            r7   &test_user_cant_delete_page_permissionsz>PermissionsOnGlobalTest.test_user_cant_delete_page_permissions	  sc    ""$--/%%dJ@>Q<<>
//5/A--<d-K
..}}	 / 
  [J6J(?@""#()-	 	# 	
 $$Z0 	M{{x0H--h7KKXt,OOD88l8KL		M 	M 	Ms   <A*E//E8c                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  |d	d	d	
       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                   d       | j#                  ||       | j%                  | j'                  |d	             ddd       y# 1 sw Y   yxY wz
        User can add page view restrictions if he has
        change permissions on the Page model,
        add permissions on the PagePermission model,
        global change permission and global change permissions permission.
        r  ru  rX  r  r  r  r  r  Tr  r  r  can_viewN)r   r  r"  r   rt   r  r  r  r  r  r   r   rT   r}  r   r   r   r   rG  r  r  s           r7   (test_user_can_add_page_view_restrictionsz@PermissionsOnGlobalTest.test_user_can_add_page_view_restrictions	  so    ""$--/%%dJ@>Q<<>
//5/A44 5 
  [J6J(<=""#')-	 	# 	
 $$Z0 	\{{x0H**84{{''$7HX1137  84OOD88lUY8Z[	\ 	\ 	\   BE??Fc                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  |d	d
d	       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j!                  |d	             ddd       y# 1 sw Y   yxY wa/  
        User can't add page view restrictions if he
        does not have change permissions on the Page model,
        does not have add permissions on the PagePermission model,
        does not have global change permission,
        and/or does not have global change permissions permission.
        r  ru  rX  r  r  r  r  r  TFr  r  N)r   r  r"  r   rt   r  r  r  r  r  r   r   rT   r  r   r  r  r  s           r7   )test_user_cant_add_page_view_restrictionszAPermissionsOnGlobalTest.test_user_cant_add_page_view_restrictions	  sI    ""$--/%%dJ@>Q<<>
//5/A44 5 
  [J6J(<=""#()-	 	# 	
 $$Z0 	]{{x0H--h7KKXt,T99|VZ9[\		] 	] 	]   A+EEc                 <   | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||dd      }t        |dg      }d	|d
<    | j                  di |}d|d<   | j                  |d       | j                  |d       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | 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 page view restrictions if he has
        change permissions on the Page model,
        change permissions on the PagePermission model,
        global change permission and global change permissions permission.
        r  ru  rX  TrG   r  rU   r  grant_ongroupexcluder  r(  r  r  r  r  r  r  r  r(  Nr=   )r   r  r"  r   rt   r  r  r
  r   r  r  r  r   r   rT   r}  r   r   r   r   rG  r  r  s	            r7   )test_user_can_edit_page_view_restrictionszAPermissionsOnGlobalTest.test_user_can_edit_page_view_restrictions	  s    ""$--/%%dJ@>Q<<>
//5/A--	 . 

 Z';Z4t44<t<[J6J(?@""#')-	 	# 	
 $$Z0 	{{x0H**84{{''$7HX1137  84OO,,% - 	 	 	s   0BFFc                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||dd      }t        |dg      }d	|d
<    | j                  di |}d|d<   | j                  |d       | j                  |d       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j!                  ||       | j#                  | j%                  |d	             ddd       y# 1 sw Y   yxY wa3  
        User can't edit page view restrictions if he
        does not have change permissions on the Page model,
        does not have change permissions on the PagePermission model,
        does not have global change permission,
        and/or does not have global change permissions permission.
        r  ru  rX  TrG   r'  r)  r*  r  r(  r  r  r  r  Fr  r,  Nr=   )r   r  r"  r   rt   r  r  r
  r   r  r  r  r   r   rT   r  r   r  r  r  s	            r7   *test_user_cant_edit_page_view_restrictionszBPermissionsOnGlobalTest.test_user_cant_edit_page_view_restrictions
  sx    ""$--/%%dJ@>Q<<>
//5/A--	 . 

 Z';Z4t44<t<[J6J(?@""#()-	 	# 	
 $$Z0 		{{x0H--h7KKXt,,,% - 			 		 		s   0A+E$$E-c                 :   | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||d      }t        |dg      }d|d<    | j                  di |}d	|d
<   | j                  |d       | j                  |d       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j!                  ||      }| j#                  |j$                  d       | j'                  ||       | j)                  | j+                  |d             ddd       y# 1 sw Y   yxY wz
        User can delete view restrictions if he has
        change permissions on the Page model,
        delete permissions on the PagePermission model,
        global change permission and global change permissions permission.
        r  ru  rX  Tr  rU   r  r)  r*  r  r  r  r  r  r  r  r  Nr=   )r   r  r"  r   rt   r  r  r
  r   r  r  r  r   r   rT   r}  r   r   r   r   r  r  r  s	            r7   +test_user_can_delete_page_view_restrictionszCPermissionsOnGlobalTest.test_user_can_delete_page_view_restrictionsL
  s    ""$--/%%dJ@>Q<<>
//5/A-- . 

 Z';X4t44<t<[J6J(?@""#')-	 	# 	
 $$Z0 	]{{x0H**84{{''$7HX1137  84T99|VZ9[\	] 	] 	]s   /BFFc                    | j                         }| j                         }| j                  t        d|j                        dz   }| j                         }| j                  |      }| j                  ||d      }t        |dg      }d|d<    | j                  di |}d	|d
<   | j                  |d       | j                  |d       | j                  |ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j!                  ||       | j#                  | j%                  |d             ddd       y# 1 sw Y   yxY wa0  
        User can't delete view restrictions if he
        does not have change permissions on the Page model,
        does not have delete permissions on the PagePermission model,
        does not have global change permission,
        and/or does not have global change permissions permission.
        r  ru  rX  Tr3  r)  r*  r  r  r  r  r  Fr  r  Nr=   )r   r  r"  r   rt   r  r  r
  r   r  r  r  r   r   rT   r  r   rG  r  r  s	            r7   ,test_user_cant_delete_page_view_restrictionszDPermissionsOnGlobalTest.test_user_cant_delete_page_view_restrictionsu
  sn    ""$--/%%dJ@>Q<<>
//5/A-- . 

 Z';X4t44<t<[J6J(?@""#()-	 	# 	
 $$Z0 	\{{x0H--h7KKXt,OOD88lUY8Z[		\ 	\ 	\s   /A+E##E,c                    | j                         }| j                         }| j                  t        d|j                        dz   }t        |d|j                  g       | j                  | j                               5  | j                  |j                  |j                        }d|d<   | j                  j                  ||       ddd       | j                  t        |d             y# 1 sw Y   %xY w)z6
        Permission cache clears on page save
        r  ru  r  r  r  r  N)r  #get_staff_user_with_std_permissionsr"  r   rt   r   r   r   r  r   r   assertIsNoner   )r4   rU   r  r   rw   s        r7   #test_permissions_cache_invalidationz;PermissionsOnGlobalTest.test_permissions_cache_invalidation
  s     --/==?
%%dJ@>QZ	B$$T%7%7%9: 	-22jmm2TD #DKKXt,	- 	.z=IJ		- 	-s   <A	C))C2c                    ddl m} | j                         }| j                         }t	        |d|j
                  g        |d      }|j                          |j                  j                  |       | j                  t        |d             y)a
        Permissions cache is invalidated if the group relationship of a user is changed
        r   Groupr  
test_grouprN   N)django.contrib.auth.modelsr?  r  r9  r   rt   r   groupsro  r:  r   r4   r?  rU   r  r)  s        r7   /test_permission_cache_invalidation_on_group_addzGPermissionsOnGlobalTest.test_permission_cache_invalidation_on_group_add
  sr     	5--/==?
Z	B<(

e$.z=IJr8   c                 T   ddl m} | j                         }| j                         } |d      }|j	                          |j
                  j                  |       t        |d|j                  g       |j                  j                  |       | j                  t        |d             y)r=  r   r>  r@  rA  r  N)rB  r?  r  r9  r   rC  ro  r   rt   user_setremover:  r   rD  s        r7   2test_permission_cache_invalidation_on_group_removezJPermissionsOnGlobalTest.test_permission_cache_invalidation_on_group_remove
  s     	5--/==?
<(

e$Z	Bj).z=IJr8   c                    | j                         }| j                         }| j                  |d       | j                  |d       | j                  |dd       t        j
                  j                         }| j                  |      5  | j                  t        d|j                        }|d|j                  z  z  }| j                  j                  |      }| j                  |j                  d       ddd       | j                  |      5  | j                  ||d	
       ddd       | j                  |d	z   d       y# 1 sw Y   MxY w# 1 sw Y   +xY w)r7  add_pager  T)can_addr  rs  rt  r   NrG   rF  r=  )r  r  r  r  r   rb   r   r   r"  rt   rd  r   rT   r   r   r>  )r4   rU   r  r   r   r   s         r7   test_user_can_copy_pagez/PermissionsOnGlobalTest.test_user_can_copy_page
  s3    --/<<>
J
3J6"" 	# 	
 ""$$$Z0 	8))$0A477KH)DLL88H{{x0HX1137		8 $$Z0 	3NN4N2	3A&	8 	8	3 	3s   A+D?E?EEc                 ^   | j                         }| j                         }|j                  d      j                  d      }|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       y# 1 sw Y   yxY wz
        User can add a plugin if he has change permissions
        on the Page model, add permissions on the plugin model
        and global change permissions.
        ro   rD   rQ   rP   rV   r  add_linkTr  rK   rL   rM   r   rG   Nr  r  rS   rT   rH  rc   rl   r  r  r   r   r   r   r   r   r4   rU   r  rZ   pluginsr   rw   r   s           r7   test_user_can_add_pluginz0PermissionsOnGlobalTest.test_user_can_add_plugin
  s    --/<<>
++D15565B))$/66<6P++D1J6J
3"":$"?$$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	1 	1   <AD##D,c                 ^   | j                         }| j                         }|j                  d      j                  d      }|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       y# 1 sw Y   yxY wz
        User can't add a plugin if he
        does not have change permissions on the Page model,
        does not have add permissions on the plugin model
        and/or does not have global change permissions.
        ro   rD   rQ   rP   rP  r  rQ  Fr  rK   rL   rM   r  r   NrR  rS  s           r7   test_user_cant_add_pluginz1PermissionsOnGlobalTest.test_user_cant_add_plugin  s    --/<<>
++D15565B))$/66<6P++D1J6J
3"":%"@$$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	1 	1rV  c                 8   | 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
       y
# 1 sw Y   y
xY wz
        User can edit a plugin if he has change permissions
        on the Page model, change permissions on the plugin model
        and global change permissions.
        r  change_linkTr  rN   rO   fieldsA link 2r   N)r  r  r\   get_change_plugin_urir  r  r   r   r   r   r   r   rc  rN   r4   rU   r  r[   r   rw   r   s          r7   test_user_can_edit_pluginz1PermissionsOnGlobalTest.test_user_can_edit_plugin  s     --/<<>
))$/--f5J6J6"":$"?$$Z0 	8 0IJD%DL{{''$7HX1137""$V[[$v,7	8 	8 	8   A<DDc                 8   | 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
       y
# 1 sw Y   y
xY wz
        User can't edit a plugin if he
        does not have change permissions on the Page model,
        does not have change permissions on the plugin model
        and/or does not have global change permissions.
        r  r\  Fr  rN   rO   r]  r_  r  N)r  r  r\   r`  r  r  r   r   r   r   r   r   rc  assertNotEqualrN   ra  s          r7   test_user_cant_edit_pluginz2PermissionsOnGlobalTest.test_user_cant_edit_plugin0  s     --/<<>
))$/--f5J6J6"":%"@$$Z0 	; 0IJD%DL{{''$7HX1137""$T&\:	; 	; 	;rc  c                 4   | j                         }| j                         }| j                  |      }| j                  |      }| j	                  |d       | 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 Page model, delete permissions on the plugin model
        and global change permissions.
        r  r  Tr  r   z<div class="success"></div>r  N)r  r  r\   get_delete_plugin_urir  r  r   r   r   r   r  r   rb   rc   rt   rd   ra  s          r7   test_user_can_delete_pluginz3PermissionsOnGlobalTest.test_user_can_delete_pluginI  s     --/<<>
))$/--f5J6J6"":$"?$$Z0 	ND>D{{''$7H*GHY..555CJJLM	N 	N 	Ns   A:DDc                 H   | 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	       y	# 1 sw Y   y	xY w
z
        User can't delete a plugin if he
        does not have change permissions on the Page model,
        does not have delete permissions on the plugin model
        and/or does not have global change permissions.
        r  r  Fr  r   Tr  r  N)r  r  r\   rj  r  r  r   r   r   r   r   rG  r   rb   rc   rt   rd   ra  s          r7   test_user_cant_delete_pluginz4PermissionsOnGlobalTest.test_user_cant_delete_plugin_  s     --/<<>
))$/--f5J6J6"":%"@$$Z0 	MD>D{{''$7HX1137OOI--44		4BIIKL	M 	M 	Ms   BDD!c                    | j                         }| j                         }| j                  |      }| j                  |      }|j                  }|j                  d      j                  d      }| j                  |d|      }| j                  |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   yxY wz
        User can move a plugin if he has change permissions
        on the Page model, change permissions on the plugin model
        and global change permissions.
        ro   rD  rQ   rG   rE  r  r\  Tr  r   r  N)r  r  r\   rG  rZ   rS   rT   r   r  r  r   r   r   r   r   rG  rH  rc   rt   r  	r4   rU   r  r[   r   rH  rI  rw   r   s	            r7   test_user_can_move_pluginz1PermissionsOnGlobalTest.test_user_can_move_pluginv  s_    --/<<>
))$/++F3#//!2248<<.<Q""6ACU"VJ6J6"":$"?$$Z0 	X{{''$7HX1137OO.::4@GG699GUV/;;DAHHFIIHVW		X 	X 	X   B-FFc                    | j                         }| j                         }| j                  |      }| j                  |      }|j                  }|j                  d      j                  d      }| j                  |d|      }| j                  |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   yxY wz
        User can't move a plugin if he
        does not have change permissions on the Page model,
        does not have change permissions on the plugin model
        and/or does not have global change permissions.
        ro   rD  rQ   rG   rE  r  r\  Fr  r  r  N)r  r  r\   rG  rZ   rS   rT   r   r  r  r   r   r   r   r   r  rH  rc   rt   rG  rq  s	            r7   test_user_cant_move_pluginz2PermissionsOnGlobalTest.test_user_cant_move_plugin  s_    --/<<>
))$/++F3#//!2248<<.<Q""6ACU"VJ6J6"":%"@$$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rs  c                    | j                         }| j                         }| j                  |      }| j                  |      }| j	                  |      }|j
                  }|j                  d      j                  d      }|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%                  |j                        j'                  |j*                        j)                                ddd       y# 1 sw Y   yxY w)
        User can copy a plugin if he has change permissions
        on the Page model, add permissions on the plugin model
        and global change permissions.
        ro   rD  rQ   source_plugin_idsource_placeholder_idsource_languager|   target_placeholder_idr  rQ  Tr  r   r  rP  N)r  r  r\   r  get_copy_plugin_urirZ   rS   rT   rt   rW   r  r  r   r   r   r   r   rG  rH  rc   rd   rV   
r4   rU   r  r[   r  r   rH  rI  rw   r   s
             r7   test_user_can_copy_pluginz1PermissionsOnGlobalTest.test_user_can_copy_plugin  s    --/<<>
))$/33D9++F3#//!2248<<.<Q !'		%7%:%:%*33%7%:%:
 	J6J
3"":$"?$$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_OO"[112F$6$67				 		 		   CGG(c                    | j                         }| j                         }| j                  |      }| j                  |      }| j	                  |      }|j
                  }|j                  d      j                  d      }|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%                  |j                        j'                  |j,                        j)                                ddd       y# 1 sw Y   yxY w)
        User can't copy a plugin if he
        does not have change permissions on the Page model,
        does not have add permissions on the plugin model,
        and/or does not have global change permissions.
        ro   rD  rQ   ry  r  rQ  Fr  r  r  rP  N)r  r  r\   r  r~  rZ   rS   rT   rt   rW   r  r  r   r   r   r   r   rG  rH  rc   rd   r  rV   r  s
             r7   test_user_cant_copy_pluginz2PermissionsOnGlobalTest.test_user_cant_copy_plugin  s    --/<<>
))$/33D9++F3#//!2248<<.<Q !'		%7%:%:%*33%7%:%:
 	J6J
3"":%"@$$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_"[112F$6$67				 		 		r  c                 |   | j                         }| j                         }| j                  |d      }| j                  |      }| j	                  t
        d|j                        }| j                  |      | j                  |      | j                  |      | j                  |      g}|d   j                  }|j                         j                  |j                        }d|j                  d}	| j                  |d       | j                  |d       | j                  |d	       | j                  |      5  | j                   j#                  ||	      }
| j%                  |
j&                  d
       |j)                         }| j%                  |j+                         t-        |             ddd       y# 1 sw Y   yxY wz
        User can copy all plugins to another language if he has
        change permissions on the Page model, add permissions on the
        plugins being copied and global change permissions.
        ro   copy_languager   rQ   r|  r|   r  rQ  Tr  r   N)r  r  r  r  r"  r   rt   r\   rZ   rS   rT   rR   rW   r  r  r   r   r   r   r   rH  r   r  r4   rU   r  source_translationtarget_translationr   rT  rH  rI  rw   r   new_pluginss               r7   &test_user_can_copy_plugins_to_languagez>PermissionsOnGlobalTest.test_user_can_copy_plugins_to_language  s    --/<<>
!55dDA!::4@%%k?DVDYDYZ$$T*$$T*$$T*$$T*	
 %QZ33/@@BFFL^LcLcFd  $1::

 	J6J
3"":$"?$$Z0 	@{{''$7HX1137,88:K[..0#g,?		@ 	@ 	@s   7A2F22F;c                    | j                         }| j                         }| j                  |      }| j                  t        d|j
                        }| j                  |      | j                  |      | j                  |      | j                  |      g}|d   j                  }d|j                  d}| j                  |d       | j                  |d       | j                  |d       | j                  |      5  | j                  j                  ||      }| j                  |j                  d	       |j!                  |j                        }	| j                  |	j#                         d       d
d
d
       y
# 1 sw Y   y
xY wz
        User can't copy all plugins to another language if he does have
        change permissions on the Page model, does not have add permissions
        on the plugins being copied and/or does not have global
        change permissions.
        r  r   ro   r  r  rQ  Fr  r  N)r  r  r  r"  r   rt   r\   rZ   rW   r  r  r   r   r   r   r   rH  r   
r4   rU   r  r  r   rT  rZ   rw   r   r  s
             r7   'test_user_cant_copy_plugins_to_languagez?PermissionsOnGlobalTest.test_user_cant_copy_plugins_to_language  s`    --/<<>
33D9%%k?KNNS$$T*$$T*$$T*$$T*	
 aj,,  $*33

 	J6J
3"":%"@$$Z0 	5{{''$7HX1137%11+2F2FGK[..0!4		5 	5 	5s   ;A4E88Fc                    | j                         }| j                         }|j                  d      j                  d      }| j	                  |      }| j                  |d       | 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 an empty placeholder if he has change permissions
        on the Page model and global change permissions.
        ro   rD   rQ   r  Tr  testr   r   Nr  r  rS   rT   get_clear_placeholder_urlr  r  r   r   r   r   r   r4   rU   r  rZ   r   r   s         r7   %test_user_can_clear_empty_placeholderz=PermissionsOnGlobalTest.test_user_can_clear_empty_placeholder;  s    
 --/<<>
++D15565B11+>J6"":$"?$$Z0 	8{{''61+>HX1137	8 	8 	8   	;CCc                    | j                         }| j                         }|j                  d      j                  d      }| j	                  |      }| j                  |d       | 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't clear an empty placeholder if he does not have
        change permissions on the Page model and/or does not have
        global change permissions.
        ro   rD   rQ   r  Fr  r  r   r  Nr  r  s         r7   &test_user_cant_clear_empty_placeholderz>PermissionsOnGlobalTest.test_user_cant_clear_empty_placeholderM  s     --/<<>
++D15565B11+>J6"":%"@$$Z0 	8{{''61+>HX1137	8 	8 	8r  c                 |   | j                         }| j                         }| j                  |d      | j                  |d      g}|d   j                  }| j	                  |      }| j                  |d       | 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 Page model, delete permissions
        on the plugin models in the placeholder and global change permissions.
        rI   rP   r   delete_textr  r  Tr  r  r   ro   Nr  r  r\   rZ   r  r  r  r   r   r   r   r   rH  r   r4   rU   r  rT  rZ   r   r   s          r7   )test_user_can_clear_non_empty_placeholderzAPermissionsOnGlobalTest.test_user_can_clear_non_empty_placeholder`  s&    --/<<>
$$T<8$$T<8
 aj,,11+>J6J6J6"":$"?$$Z0 	G{{''61+>HX1137[44T:@@BAF	G 	G 	G   ?A*D22D;c                 |   | j                         }| j                         }| j                  |d      | j                  |d      g}|d   j                  }| j	                  |      }| j                  |d       | 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a  
        User can't clear a placeholder with plugins if he does not have
        change permissions on the Page model, does not have delete
        permissions on the plugin models in the placeholder and/or
        does not have global change permissions.
        rI   rP   r   r  r  r  Fr  r  r  ro   rF   Nr  r  s          r7   *test_user_cant_clear_non_empty_placeholderzBPermissionsOnGlobalTest.test_user_cant_clear_non_empty_placeholdery  s&    --/<<>
$$T<8$$T<8
 aj,,11+>J6J6J6"":%"@$$Z0 	G{{''61+>HX1137[44T:@@BAF	G 	G 	Gr  N)6r:   r;   r<   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r#  r-  r0  r4  r7  r;  rE  rI  rM  rU  rY  rb  rg  rk  rn  rr  rv  r  r  r  r  r  r  r  r  r=   r8   r7   r  r    s-   868,L(M:K2 LD2,1>24"1H9.8B9482A(I(&R"MH!NF/b.`%NN$ML"\H!]F.`,\']R&\PKK K$':1,1.80;2N,M.X2W4#J$L!@F 5H8$8&G2Gr8   r  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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)d( Z*d) Z+d* Z,d+ Z-d, Z.y-).PermissionsOnPageTestz
    Tests all user interactions with the page admin
    while permissions are set to True and user has
    page permissions.
    c                 .    | j                         | _        y r   )r  _permissions_pager   s    r7   ri  zPermissionsOnPageTest.setUp  s    !%!?!?!Ar8   c                 `   | j                   }t        ddg      }| j                         }| j                  |d       | j	                  ||d       | j                  |      5  | j                  j                  |      }| j                  |j                  d       | j                  |dd	       d
d
d
       | j                         }| j                  |      5  | j                  j                  |      }| j                  |j                  d       d
d
d
       y
# 1 sw Y   kxY w# 1 sw Y   y
xY wr  )r  r,   r  r  r
  r   r   rT   r   r   r   r   r4   rU   r   r  r   s        r7   r  z/PermissionsOnPageTest.test_pages_in_admin_index  s     %% 5':<<>
J6   	! 	
 $$Z0 	{{x0HX1137H   	 002$$Z0 	8{{x0HX1137	8 	8	 		8 	8s   "AD8D$D!$D-c                 8   | j                   }t        ddg      }| j                         }| j                  |d       | j	                  ||d       | j                  |      5  | j                  j                  |      }| j                  |j                  d       ddd       | j                         }| j                  |      5  | j                  j                  |      }| j                  |j                  d	       ddd       y# 1 sw Y   kxY w# 1 sw Y   yxY wr  )r  r,   r  r  r
  r   r   rT   r   r   r   r  s        r7   r  z3PermissionsOnPageTest.test_pages_not_in_admin_index  s    %% 5':<<>
J6   	! 	
 $$Z0 	8{{x0HX1137	8 002$$Z0 	8{{x0HX1137	8 	8	8 	8	8 	8s   "8D8DDDc                    | j                   }| j                  d|      }| j                         }| j                         }| j	                  d      }| j                  |d       | j                  ||d       | j                  |      5  | j                  j                  ||      }| j                  ||       | j                  | j                  d             ddd       y# 1 sw Y   yxY wr  )r  r   r   r  rx   r  r
  r   r   r   r   rG  rg   r  s          r7   r  z6PermissionsOnPageTest.test_user_can_edit_page_settings  s    
 %%++D$7335<<>
"""8J6   	! 	
 $$Z0 	L{{''$7H  ;7OOD44/4JK	L 	L 	Ls   AC!!C*c                 $   | j                   }| j                  d|      }| j                         }| j                  d      }| j	                  |d       | j                  ||d      }| j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  | j                  d             ddd       | j                  |d       d	|_        |j                  d
g       | j                  |      5  | 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r  )r  r   r  rx   r  r
  r   r   r   r   r   r  rg   r  r  r   r4   rU   r   r  rw   	page_permr   s          r7   r  z7PermissionsOnPageTest.test_user_cant_edit_page_settings  s    %%++D$7<<>
"""8J6,, - 
	 $$Z0 	M{{''$7HX1137T55?5KL	M
 	z=9#	l^4$$Z0 	M{{''$7HX1137T55?5KL	M 	M	M 	M	M 	Ms   8AE:AF:FFc                    | j                   }| j                  t        d|j                        }| j	                         }| j                         }| j                  d      }| j                  |d       | j                  ||dd       | j                  |      5  | j                  j                  ||      }| j                  ||       | j                  | j                  d             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r   r  rx   r  r
  r   r   r   r   rG  r  r  s          r7   r  z?PermissionsOnPageTest.test_user_can_edit_advanced_page_settings  s     %%%%dJ@335<<>
""o">J6  )-	 	! 	
 $$Z0 	K{{''$7H  ;7OOD---IJ	K 	K 	Ks   AC11C:c                 D   | j                   }| j                  t        d|j                        }| j	                         }| j                  d      }| j                  |d       | j                  ||dd      }| j                  |      5  | j                  j                  ||      }| j                  |j                  d       | j                  | j                  d             d	d	d	       | j                  |d       d|_        |j#                  d
g       | j                  |      5  | 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r  )r  r"  r   rt   r  rx   r  r
  r   r   r   r   r   r  r  r  r  r   r  s          r7   r  z@PermissionsOnPageTest.test_user_cant_edit_advanced_page_settings-  s    %%%%dJ@<<>
""o">J6,,).	 - 
	 $$Z0 	L{{''$7HX1137T../.JK	L
 	z=9#	l^4$$Z0 	L{{''$7HX1137T../.JK	L 	L	L 	L	L 	Ls   AF
'AF
FFc                    | j                   }| j                  t        d|j                        }t	        d      }| j                         }| j                  |d       | j                  |d       | j                  ||dd       | j                  |      5  ddi}| j                  j                  ||d	      }| j                  ||       | j                  | j                                d
d
d
       y
# 1 sw Y   y
xY w)z
        User can delete an empty page if he has delete & change permissions
        on the Page model and he has page delete & change permissions.
        r!  indexr  r  Tr  r   r  r  N)r  r"  r   rt   r,   r  r  r
  r   r   r   r   r  r  r  s          r7   r  z5PermissionsOnPageTest.test_user_can_delete_empty_pageP  s    
 %%%%dHdgg>#G,<<>
J6J6  	 	! 	
 $$Z0 	2E?D{{''$t'DH  ;7T..01	2 	2 	2s   AC00C9c                 L   | j                   }| j                  t        d|j                        }| j	                         }| j                  |d       | j                  |d       | j                  ||dd      }| j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  | j                                d	d	d	       | j                  |d       d
|_        |j!                  dg       | j                  |      5  ddi}| 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)r  r!  r  r  Fr  r   r  r  NTr  r  )r  r"  r   rt   r  r  r
  r   r   r   r   r   rG  r  r  r  r   r4   rU   r   r  r  rw   r   s          r7   r  z6PermissionsOnPageTest.test_user_cant_delete_empty_pagej  s    %%%%dHdgg><<>
J6J6,,	 - 
	 $$Z0 	1E?D{{''$7HX1137OOD--/0	1 	z=9#	l^4$$Z0 	1E?D{{''$7HX1137OOD--/0	1 	1	1 	1	1 	1s   AF)AFFF#c                 >   | j                   }| j                  t        d|j                        }t	        d      }| j                         }| j                  |       | j                  |d       | j                  |d       | j                  |d       | j                  ||dd       | j                  |      5  dd	i}| j                  j                  ||d
      }| j                  ||       | j                  | j                                ddd       y# 1 sw Y   yxY w)z
        User can delete a page with plugins if he has delete permissions
        on the Page model, delete permissions on the plugins in the page
        translations and page delete & change permissions.
        r!  r  r  r  r  Tr  r   r  r  N)r  r"  r   rt   r,   r  r\   r  r
  r   r   r   r   r  r  r  s          r7   r  z9PermissionsOnPageTest.test_user_can_delete_non_empty_page  s    %%%%dHdgg>#G,<<>
  &J6J6J6  	 	! 	
 $$Z0 	2E?D{{''$t'DH  ;7T..01	2 	2 	2s   6ADDc                 n   | j                   }| j                  t        d|j                        }| j	                         }| j                  |       | j                  |d       | j                  |d       | j                  ||dd      }| j                  |      5  ddi}| j                  j                  ||      }| j                  |j                  d       | j                  | j                                d	d	d	       | j                  |d       d
|_        |j#                  dg       | j                  |      5  ddi}| 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)r  r!  r  r  Fr  r   r  r  NTr  r  )r  r"  r   rt   r  r\   r  r
  r   r   r   r   r   rG  r  r  r  r   r  s          r7   r  z:PermissionsOnPageTest.test_user_cant_delete_non_empty_page  s    %%%%dHdgg><<>
  &J6J6,,	 - 
	 $$Z0 	1E?D{{''$7HX1137OOD--/0	1 	z=9#	l^4$$Z0 	1E?D{{''$7HX1137OOD--/0	1 	1	1 	1	1 	1s   AF:AF+F(+F4c                 4   | j                   }| j                  |      }| j                  t        d|j                        }| j                         }| j                         }| j                  |d       | j                  |d       | j                  ||dd       | j                  |      5  d|j                  i}| j                  j                  ||      }| j                  ||       | j                  | j                                ddd       y# 1 sw Y   yxY w)z
        User can delete an empty translation if he has
        delete permissions on the Page model and he has
        page delete & change permissions.
        r!  r  r  Tr  rW   N)r  r  r"  r   rt   r   r  r  r
  r   rW   r   r   r   r  rg   r  s           r7   r  z<PermissionsOnPageTest.test_user_can_delete_empty_translation  s    %%33D9%%k8[^^L335<<>
J6J6  	 	! 	
 $$Z0 	9 4 45D{{''$7H  ;7T5578	9 	9 	9s   )ADDc                    | j                   }| j                  |      }| j                  t        d|j                        }| j                         }| j                  |d       | j                  |d       | j                  ||dd      }| j                  |      5  d|j                  i}| j                  j                  ||      }| j                  |j                  d       | j                  | j                                ddd       | j!                  |d       d	|_        |j%                  d
g       | j                  |      5  d|j                  i}| 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)r  r!  r  r  Fr  rW   r  NTr  r  )r  r  r"  r   rt   r  r  r
  r   rW   r   r   r   r   rG  rg   r  r  r   )r4   rU   r  r   r  r  rw   r   s           r7   r  z=PermissionsOnPageTest.test_user_cant_delete_empty_translation  s    %%33D9%%k8[^^L<<>
J6J6,,	 - 
	 $$Z0 	8 4 45D{{''$7HX1137OOD4467	8 	z=9#	l^4$$Z0 	8 4 45D{{''$7HX1137OOD4467	8 	8	8 	8	8 	8s   A&F3A&F?3F<?Gc                    | j                   }| j                  |      }| j                  t        d|j                        }| j                         }| j                         }| j                  ||j                         | j                  |d       | j                  |d       | j                  |d       | j                  ||dd       | j                  |      5  d|j                  i}| j                  j                  ||      }| j                  ||       | j                  | j!                                d	d	d	       y	# 1 sw Y   y	xY w)
z
        User can delete a translation with plugins if he has delete permissions
        on the Page model, delete permissions on the plugins in the translation
        and page delete & change permissions.
        r!  r   r  r  r  Tr  rW   N)r  r  r"  r   rt   r   r  r\   rW   r  r
  r   r   r   r   r  rg   r  s           r7   r  z@PermissionsOnPageTest.test_user_can_delete_non_empty_translation  s-    %%33D9%%k8[^^L335<<>
  0D0D EJ6J6J6  	 	! 	
 $$Z0 	9 4 45D{{''$7H  ;7T5578	9 	9 	9s   AD==Ec                 b   | j                   }| j                  |      }| j                  t        d|j                        }| j                         }| j                  ||j                         | j                  |d       | j                  |d       | j                  ||dd       | j                  |      5  d|j                  i}| j                  j                  ||      }| j                  |j                  d	       | j                  | j!                                d
d
d
       y
# 1 sw Y   y
xY w)r  r!  r   r  r  FTr  rW   r  N)r  r  r"  r   rt   r  r\   rW   r  r
  r   r   r   r   r   rG  rg   r  s          r7   r  zAPermissionsOnPageTest.test_user_cant_delete_non_empty_translation6  s    %%33D9%%k8[^^L<<>
  0D0D EJ6J6  	 	! 	
 $$Z0 	8 4 45D{{''$7HX1137OOD4467	8 	8 	8s   6A&D%%D.c                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  ||d	d	d	
       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                  d       | j!                  ||       | j#                  | j%                  |             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r  r  r
  r   r   rT   r}  r   r   r   r   rG  r  r4   rU   r   r  r  rw   r   s          r7   r   z8PermissionsOnPageTest.test_user_can_add_page_permissionsT  s^    %%%%dJ@>Q<<>
//:/F.. / 
  [J6J(<=  #')- 	! 	
 $$Z0 	M{{x0H**84{{''$7HX1137  84OOD88l8KL	M 	M 	Ms   
BE++E4c                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  ||d	d
d	       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j                  |             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r  r  r
  r   r   rT   r  r   r  r  r  s          r7   r  z9PermissionsOnPageTest.test_user_cant_add_page_permissionsx  s8    %%%%dJ@>Q<<>
//:/F.. / 
  [J6J(<=  #()- 	! 	
 $$Z0 	N{{x0H--h7KKXt,T99|9LM		N 	N 	Ns   
A*D==Ec                 0   | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||d      }| j                  |j                  |j                  |j                  d      }d|d	<   | j                  |d
       | j                  |d       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                  d       | j!                  ||       | j#                  | j%                  |d             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r
  r  r  r   r   rT   r}  r   r   r   r   rG  r  r4   rU   r   r  r  r  rw   r   s           r7   r  z9PermissionsOnPageTest.test_user_can_edit_page_permissions  s    %%%%dJ@>Q<<>
//:/F--#' . 

 ..}}#(	 / 
  [J6J(?@  #')- 	! 	
 $$Z0 	{{x0H**84{{''$7HX1137  84OO,,%+0 - 	 	 	s   *BFFc                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||d      }| j                  |j                  |j                  |j                  d      }d|d	<   | j                  |d
       | j                  |d       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j                  |d             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r
  r  r  r   r   rT   r  r   r  r  r  s           r7   r  z:PermissionsOnPageTest.test_user_cant_edit_page_permissions  si    %%%%dJ@>Q<<>
//:/F--#' . 

 ..}}#(	 / 
  [J6J(?@  #()- 	! 	
 $$Z0 		{{x0H--h7KKXt,,,%+0 - 			 		 		s   *A+EE'c                 ,   | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||      }| j                  |j                  |j                  |j                  d      }d|d<   | j                  |d	       | j                  |d
       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                  d       | j!                  ||       | j#                  | j%                  |             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r
  r  r  r   r   rT   r}  r   r   r   r   r  r  r  s           r7   r  z;PermissionsOnPageTest.test_user_can_delete_page_permissions  s    %%%%dJ@>Q<<>
//:/F--<d-K
..}}	 / 
  [J6J(?@  #')- 	! 	
 $$Z0 	N{{x0H**84{{''$7HX1137  84T99|9LM	N 	N 	Ns   )BF

Fc                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||      }| j                  |j                  |j                  |j                  d      }d|d<   | j                  |d	       | j                  |d
       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j                  |             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r
  r  r  r   r   rT   r  r   rG  r  r  s           r7   r  z<PermissionsOnPageTest.test_user_cant_delete_page_permissions#  sU    %%%%dJ@>Q<<>
//:/F--<d-K
..}}	 / 
  [J6J(?@  #()- 	! 	
 $$Z0 	M{{x0H--h7KKXt,OOD88l8KL		M 	M 	Ms   )A*EE%c                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  ||d	d	d	
       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                  d       | j!                  ||       | j#                  | j%                  |d	             ddd       y# 1 sw Y   yxY wr  )r  r"  r   rt   r  r  r  r  r
  r   r   rT   r}  r   r   r   r   rG  r  r  s          r7   r  z>PermissionsOnPageTest.test_user_can_add_page_view_restrictionsI  sa    %%%%dJ@>Q<<>
//:/F44 5 
  [J6J(<=  #')- 	! 	
 $$Z0 	\{{x0H**84{{''$7HX1137  84OOD88lUY8Z[	\ 	\ 	\s   
BE,,E5c                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  |j                  |j                        }d|d<   | j                  |d       | j                  |d       | j                  ||d	d
d	       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j                  |d	             ddd       y# 1 sw Y   yxY wr"  )r  r"  r   rt   r  r  r  r  r
  r   r   rT   r  r   r  r  r  s          r7   r#  z?PermissionsOnPageTest.test_user_cant_add_page_view_restrictionsm  s;    %%%%dJ@>Q<<>
//:/F44 5 
  [J6J(<=  #()- 	! 	
 $$Z0 	]{{x0H--h7KKXt,T99|VZ9[\		] 	] 	]s   
A+D>>Ec                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||dd      }t        |dg      }d	|d
<    | j                  di |}d|d<   | j                  |d       | j                  |d       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                   d       | j#                  ||       | j%                  | j'                  |d	             ddd       y# 1 sw Y   yxY wr&  )r  r"  r   rt   r  r  r
  r   r  r  r   r   rT   r}  r   r   r   r   rG  r  r  s           r7   r-  z?PermissionsOnPageTest.test_user_can_edit_page_view_restrictions  s    %%%%dJ@>Q<<>
//:/F--	 . 

 Z';Z4t44<t<[J6J(?@  #')- 	! 	
 $$Z0 	{{x0H**84{{''$7HX1137  84OO,,% - 	 	 	r   c                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||dd      }t        |dg      }d	|d
<    | j                  di |}d|d<   | j                  |d       | j                  |d       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j!                  |d	             ddd       y# 1 sw Y   yxY wr/  )r  r"  r   rt   r  r  r
  r   r  r  r   r   rT   r  r   r  r  r  s           r7   r0  z@PermissionsOnPageTest.test_user_cant_edit_page_view_restrictions  sj    %%%%dJ@>Q<<>
//:/F--	 . 

 Z';Z4t44<t<[J6J(?@  #()- 	! 	
 $$Z0 		{{x0H--h7KKXt,,,% - 			 		 		r$  c                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||d      }t        |dg      }d|d<    | j                  di |}d	|d
<   | j                  |d       | j                  |d       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||      }| j                  |j                   d       | j#                  ||       | j%                  | j'                  |d             ddd       y# 1 sw Y   yxY wr2  )r  r"  r   rt   r  r  r
  r   r  r  r   r   rT   r}  r   r   r   r   r  r  r  s           r7   r4  zAPermissionsOnPageTest.test_user_can_delete_page_view_restrictions  s    %%%%dJ@>Q<<>
//:/F-- . 

 Z';X4t44<t<[J6J(?@  #')- 	! 	
 $$Z0 	]{{x0H**84{{''$7HX1137  84T99|VZ9[\	] 	] 	]s   BE>>Fc                    | j                   }| j                  t        d|j                        dz   }| j	                         }| j                  |      }| j                  ||d      }t        |dg      }d|d<    | j                  di |}d	|d
<   | j                  |d       | j                  |d       | j                  ||ddd       | j                  |      5  | j                  j                  |      }| j                  |       | j                  j                  ||       | j                  | j!                  |d             ddd       y# 1 sw Y   yxY wr6  )r  r"  r   rt   r  r  r
  r   r  r  r   r   rT   r  r   rG  r  r  s           r7   r7  zBPermissionsOnPageTest.test_user_cant_delete_page_view_restrictions  s`    %%%%dJ@>Q<<>
//:/F-- . 

 Z';X4t44<t<[J6J(?@  #()- 	! 	
 $$Z0 	\{{x0H--h7KKXt,OOD88lUY8Z[		\ 	\ 	\s   A+EEc                 X   | j                   }| j                         }|j                  d      j                  d      }|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       y# 1 sw Y   yxY wrO  r  r  rS   rT   rH  rc   rl   r  r
  r   r   r   r   r   r   rS  s           r7   rU  z.PermissionsOnPageTest.test_user_can_add_pluginA  s    %%<<>
++D15565B))$/66<6P++D1J6J
3   	! 	
 $$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	1 	1   9AD  D)c                 X   | j                   }| j                         }|j                  d      j                  d      }|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       y# 1 sw Y   yxY wrX  r  rS  s           r7   rY  z/PermissionsOnPageTest.test_user_cant_add_plugin[  s    %%<<>
++D15565B))$/66<6P++D1J6J
3   	! 	
 $$Z0 	1$7STD{{''$7HX1137W]]_a0		1 	1 	1r  c                 2   | 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
       y
# 1 sw Y   y
xY wr[  )r  r  r\   r`  r  r
  r   r   r   r   r   r   rc  rN   ra  s          r7   rb  z/PermissionsOnPageTest.test_user_can_edit_pluginv  s    %%<<>
))$/--f5J6J6   	! 	
 $$Z0 	8 0IJD%DL{{''$7HX1137""$V[[$v,7	8 	8 	8   A<DDc                 2   | 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
       y
# 1 sw Y   y
xY wre  )r  r  r\   r`  r  r
  r   r   r   r   r   r   rc  rf  rN   ra  s          r7   rg  z0PermissionsOnPageTest.test_user_cant_edit_plugin  s    %%<<>
))$/--f5J6J6   	! 	
 $$Z0 	; 0IJD%DL{{''$7HX1137""$T&\:	; 	; 	;r  c                 .   | j                   }| j                         }| j                  |      }| j                  |      }| j	                  |d       | 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ri  )r  r  r\   rj  r  r
  r   r   r   r   r  r   rb   rc   rt   rd   ra  s          r7   rk  z1PermissionsOnPageTest.test_user_can_delete_plugin  s    %%<<>
))$/--f5J6J6   	! 	
 $$Z0 	ND>D{{''$7H*GHY..555CJJLM	N 	N 	Ns   A:DDc                 B   | 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	       y	# 1 sw Y   y	xY wrm  )r  r  r\   rj  r  r
  r   r   r   r   r   rG  r   rb   rc   rt   rd   ra  s          r7   rn  z2PermissionsOnPageTest.test_user_cant_delete_plugin  s    %%<<>
))$/--f5J6J6   	! 	
 $$Z0 	MD>D{{''$7HX1137OOI--44		4BIIKL	M 	M 	Ms   BDDc                    | j                   }| j                         }| j                  |      }| j                  |      }|j                  }|j                  d      j                  d      }| j                  |d|      }| j                  |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   yxY wrp  )r  r  r\   rG  rZ   rS   rT   r   r  r
  r   r   r   r   r   rG  rH  rc   rt   r  rq  s	            r7   rr  z/PermissionsOnPageTest.test_user_can_move_plugin  sg    %%<<>
))$/++F3#//!2248<<.<Q""6ACU"VJ6J6   	! 	
 $$Z0 	X{{''$7HX1137OO.::4@GG699GUV/;;DAHHFIIHVW		X 	X 	X   	B-E??Fc                    | j                   }| j                         }| j                  |      }| j                  |      }|j                  }|j                  d      j                  d      }| j                  |d|      }| j                  |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   yxY wru  )r  r  r\   rG  rZ   rS   rT   r   r  r
  r   r   r   r   r   r  rH  rc   rt   rG  rq  s	            r7   rv  z0PermissionsOnPageTest.test_user_cant_move_plugin  sg    %%<<>
))$/++F3#//!2248<<.<Q""6ACU"VJ6J6   	! 	
 $$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r  c                    | j                   }| j                         }| j                  |      }| j                  |      }| j	                  |      }|j
                  }|j                  |j                         |j                  |j                        j                  d      }|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'                  |j                        j)                  |j,                        j+                                ddd       y# 1 sw Y   yxY w)rx  rD  rQ   ry  r  rQ  Tr  r   ro   r  rP  N)r  r  r\   r  r~  rZ   r  rW   rS   rT   rt   r  r
  r   r   r   r   r   rG  rH  rc   rd   rV   r  s
             r7   r  z/PermissionsOnPageTest.test_user_can_copy_plugin  s    %%<<>
))$/33D9++F3#//[112!22;3G3GHLLR`La !'		%7%:%:%*33%7%:%:
 	J6J
3   	! 	
 $$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_OO"[112F$6$67				 		 		s   %CHH
c                    | j                   }| j                         }| j                  |      }| j                  |      }| j	                  |      }|j
                  }|j                  |j                        j                  d      }|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%                  |j                        j'                  |j,                        j)                                ddd       y# 1 sw Y   yxY w)r  rD  rQ   ry  r  rQ  Fr  r  ro   r  rP  N)r  r  r\   r  r~  rZ   rS   rW   rT   rt   r  r
  r   r   r   r   r   rG  rH  rc   rd   r  rV   r  s
             r7   r  z0PermissionsOnPageTest.test_user_cant_copy_pluginI  s    %%<<>
))$/33D9++F3#//!22;3G3GHLLR`La !'		%7%:%:%*33%7%:%:
 	J6J
3   	! 	
 $$Z0 		{{''$7HX1137OO.::4@GG699GU\\^_"[112F$6$67				 		 		s   
CG&&G/c                 v   | j                   }| j                         }| j                  |d      }| j                  |      }| j	                  t
        d|j                        }| j                  |      | j                  |      | j                  |      | j                  |      g}|d   j                  }|j                         j                  |j                        }d|j                  d}	| j                  |d       | j                  |d       | j                  ||d	       | j                  |      5  | j                   j#                  ||	      }
| j%                  |
j&                  d
       |j)                         }| j%                  |j+                         t-        |             ddd       y# 1 sw Y   yxY wr  )r  r  r  r  r"  r   rt   r\   rZ   rS   rT   rR   rW   r  r
  r   r   r   r   r   rH  r   r  r  s               r7   r  z<PermissionsOnPageTest.test_user_can_copy_plugins_to_languages  s    %%<<>
!55dDA!::4@%%k?DVDYDYZ$$T*$$T*$$T*$$T*	
 %QZ33/@@BFFL^LcLcFd  $1::

 	J6J
3   	! 	
 $$Z0 	@{{''$7HX1137,88:K[..0#g,?		@ 	@ 	@s   4A2F//F8c                    | j                   }| j                         }| j                  |      }| j                  t        d|j
                        }| j                  |      | j                  |      | j                  |      | j                  |      g}|d   j                  }d|j                  d}| j                  |d       | j                  |d       | j                  ||d       | j                  |      5  | j                  j                  ||      }| j                  |j                  d	       |j!                  |j                        }	| j                  |	j#                         d       d
d
d
       y
# 1 sw Y   y
xY wr  )r  r  r  r"  r   rt   r\   rZ   rW   r  r
  r   r   r   r   r   rH  r   r  s
             r7   r  z=PermissionsOnPageTest.test_user_cant_copy_plugins_to_language  sh    %%<<>
33D9%%k?KNNS$$T*$$T*$$T*$$T*	
 aj,,  $*33

 	J6J
3   	! 	
 $$Z0 	5{{''$7HX1137%11+2F2FGK[..0!4		5 	5 	5s   8A4E55E>c                    | j                   }| j                         }|j                  d      j                  d      }| j	                  |      }| j                  |d       | j                  |d       | j                  |      5  | j                  j                  |ddi      }| j                  |j                  d	       d
d
d
       y
# 1 sw Y   y
xY wr  r  r  rS   rT   r  r  r  r   r   r   r   r   r  s         r7   r  z;PermissionsOnPageTest.test_user_can_clear_empty_placeholder  s    
 %%<<>
++D15565B11+>J6"":$"?$$Z0 	8{{''61+>HX1137	8 	8 	8   ;C		Cc                    | j                   }| j                         }|j                  d      j                  d      }| j	                  |      }| j                  |d       | j                  |d       | j                  |      5  | j                  j                  |ddi      }| j                  |j                  d	       d
d
d
       y
# 1 sw Y   y
xY wr  r  r  s         r7   r  z<PermissionsOnPageTest.test_user_cant_clear_empty_placeholder  s     %%<<>
++D15565B11+>J6"":%"@$$Z0 	8{{''61+>HX1137	8 	8 	8r  c                 t   | j                   }| j                         }| j                  |d      | j                  |d      g}|d   j                  }| j	                  |      }| j                  |d       | 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r  r  r  r\   rZ   r  r  r  r   r   r   r   r   rH  r   r  s          r7   r  z?PermissionsOnPageTest.test_user_can_clear_non_empty_placeholder  s#    %%<<>
$$T<8$$T<8
 aj,,11+>J6J6J6"":$"?$$Z0 	G{{''61+>HX1137[44T:@@BAF	G 	G 	G   ;A*D..D7c                 t   | j                   }| j                         }| j                  |d      | j                  |d      g}|d   j                  }| j	                  |      }| j                  |d       | 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r  r  r  s          r7   r  z@PermissionsOnPageTest.test_user_cant_clear_non_empty_placeholder  s#    %%<<>
$$T<8$$T<8
 aj,,11+>J6J6J6"":%"@$$Z0 	G{{''61+>HX1137[44T:@@BAF	G 	G 	Gr  N)/r:   r;   r<   r   ri  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r#  r-  r0  r4  r7  rU  rY  rb  rg  rk  rn  rr  rv  r  r  r  r  r  r  r  r  r=   r8   r7   r  r    s   B8@86L0MBK4!LF24#1J2:'1R98$8L9>8<"MH!NF/b.`%NN$ML"\H!]F.`,\']R&\T141688;:N4M6X:W<(T(T%@N$5P8"8$G2Gr8   r  Fc                       e Zd ZdZy)PermissionsOffTestza
    Tests all user interactions with the page admin
    while permissions are set to False.
    N)r:   r;   r<   r   r=   r8   r7   r  r    s    r8   r  z#cms.test_utils.project.noadmin_urls)ROOT_URLCONFc                       e Zd Zd Zy)NoAdminPageTestsc                     t               D cg c]
  }|dk7  s	| }}| j                  |      5  | j                  d      }t        |      }| j	                  |d        d d d        y c c}w # 1 sw Y   y xY w)Nzdjango.contrib.admin)INSTALLED_APPSz
/en/admin/)r)   r   r   r+   r   )r4   r  noadmin_appsr   rU   s        r7   +test_get_page_from_request_fakeadmin_nopagez<NoAdminPageTests.test_get_page_from_request_fakeadmin_nopage$  sx    '5'7Y3BX;XYY]],]7 	)&&|4G(1DT4(	) 	) Z	) 	)s   
A(A(/A--A6N)r:   r;   r<   r  r=   r8   r7   r  r  !  s    )r8   r  )Yr  rw  r  unittestr   django.confr   django.contribr   django.contrib.sites.modelsr   django.core.cacher   django.forms.modelsr   django.httpr	   r
   django.test.htmlr   r   django.test.utilsr   django.urlsr   django.utils.encodingr   django.utils.timezoner   r  django.utils.translationr   r0  r  r   cms.admin.pageadminr   cms.apir   r   r   cms.appresolverr   cms.cache.permissionsr   r   cms.middleware.userr   
cms.modelsr   cms.models.pagemodelr   r   cms.models.permissionmodelsr   cms.models.pluginmodelr   'cms.test_utils.project.sampleapp.modelsr    cms.test_utils.testcasesr!   r"   $cms.test_utils.util.context_managersr#   r$   r%   r  r&   cms.utils.compatr'   r(   cms.utils.compat.djr)   cms.utils.confr*   cms.utils.pager+   cms.utils.urlutilsr,   r.   r?   rC   r   rf  rx  r  r  r  r  r=   r8   r7   <module>r     sa     
      , # - 1 3 / ( + / ?  0 @ @ / L 5 " . 6 , C C 
 2 3 . * 0 ,
1v 
11F 1SB; SBlm8| m8`-+<, +<\k, k\ $'kG1 kG (kG\- $'AG/ AG (AGH, %(,  )  EF){ ) G)r8   