Exemple #1
0
 def test_type_limit_on_plugin_move(self):
     admin = self.get_admin()
     superuser = self.get_superuser()
     source_placeholder = Placeholder.objects.create(slot='source')
     target_placeholder = self.get_placeholder()
     data = {
         'placeholder': source_placeholder,
         'plugin_type': 'TextPlugin',
         'language': 'en',
     }
     plugin_1 = add_plugin(**data)
     plugin_2 = add_plugin(**data)
     with UserLoginContext(self, superuser):
         with SettingsOverride(CMS_PLACEHOLDER_CONF=self.placeholderconf):
             request = self.get_post_request({
                 'placeholder_id':
                 target_placeholder.pk,
                 'plugin_id':
                 plugin_1.pk
             })
             response = admin.move_plugin(request)  # first
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request({
                 'placeholder_id':
                 target_placeholder.pk,
                 'plugin_id':
                 plugin_2.pk
             })
             response = admin.move_plugin(request)  # second
             self.assertEqual(response.status_code, 400)
             self.assertEqual(
                 response.content,
                 "This placeholder already has the maximum number (1) of allowed Text plugins."
             )
Exemple #2
0
 def test_global_limit_on_plugin_move(self):
     admin = self.get_admin()
     superuser = self.get_superuser()
     cms_page = self.get_page()
     source_placeholder = cms_page.placeholders.get(slot='right-column')
     target_placeholder = cms_page.placeholders.get(slot='body')
     data = {
         'placeholder': source_placeholder,
         'plugin_type': 'LinkPlugin',
         'language': 'en',
     }
     plugin_1 = add_plugin(**data)
     plugin_2 = add_plugin(**data)
     plugin_3 = add_plugin(**data)
     with UserLoginContext(self, superuser):
         with SettingsOverride(CMS_PLACEHOLDER_CONF=self.placeholderconf):
             request = self.get_post_request({'placeholder': target_placeholder.slot, 'plugin_id': plugin_1.pk})
             response = admin.move_plugin(request) # first
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request({'placeholder': target_placeholder.slot, 'plugin_id': plugin_2.pk})
             response = admin.move_plugin(request) # second
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request({'placeholder': target_placeholder.slot, 'plugin_id': plugin_3.pk})
             response = admin.move_plugin(request) # third
             self.assertEqual(response.status_code, 400)
             self.assertEqual(response.content, "This placeholder already has the maximum number of plugins (2).")
Exemple #3
0
 def test_type_limit_on_plugin_move(self):
     admin = self.get_admin()
     superuser = self.get_superuser()
     cms_page = self.get_page()
     source_placeholder = cms_page.placeholders.get(slot='right-column')
     target_placeholder = cms_page.placeholders.get(slot='body')
     data = {
         'placeholder': source_placeholder,
         'plugin_type': 'TextPlugin',
         'language': 'en',
     }
     plugin_1 = add_plugin(**data)
     plugin_2 = add_plugin(**data)
     with UserLoginContext(self, superuser):
         with SettingsOverride(CMS_PLACEHOLDER_CONF=self.placeholderconf):
             request = self.get_post_request(
                 {'placeholder_id': target_placeholder.pk, 'plugin_id': plugin_1.pk, 'plugin_parent': ''})
             response = admin.move_plugin(request) # first
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request(
                 {'placeholder_id': target_placeholder.pk, 'plugin_id': plugin_2.pk, 'plugin_parent': ''})
             response = admin.move_plugin(request) # second
             self.assertEqual(response.status_code, 400)
             self.assertEqual(response.content,
                              b"This placeholder already has the maximum number (1) of allowed Text plugins.")
Exemple #4
0
 def test_global_limit_on_plugin_move(self):
     admin = self.get_admin()
     superuser = self.get_superuser()
     source_placeholder = Placeholder.objects.create(slot='source')
     target_placeholder = self.get_placeholder()
     data = {
         'placeholder': source_placeholder,
         'plugin_type': 'LinkPlugin',
         'language': 'en',
     }
     plugin_1 = add_plugin(**data)
     plugin_2 = add_plugin(**data)
     plugin_3 = add_plugin(**data)
     with UserLoginContext(self, superuser):
         with SettingsOverride(CMS_PLACEHOLDER_CONF=self.placeholderconf):
             request = self.get_post_request({'placeholder_id': target_placeholder.pk, 'plugin_id': plugin_1.pk})
             response = admin.move_plugin(request) # first
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request({'placeholder_id': target_placeholder.pk, 'plugin_id': plugin_2.pk})
             response = admin.move_plugin(request) # second
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request({'placeholder_id': target_placeholder.pk, 'plugin_id': plugin_3.pk})
             response = admin.move_plugin(request) # third
             self.assertEqual(response.status_code, 400)
             self.assertEqual(response.content, "This placeholder already has the maximum number of plugins (2).")
 def move_a_copy(self, admin, placeholder_id, plugin_id):
     request = self.get_post_request({
         'placeholder_id': placeholder_id,
         'plugin_id': plugin_id,
         'plugin_order': ['__COPY__'],
         'move_a_copy': 'true',
     })
     return admin.move_plugin(request)
Exemple #6
0
 def test_type_limit_on_plugin_move(self):
     admin = self.get_admin()
     superuser = self.get_superuser()
     cms_page = self.get_page()
     source_placeholder = cms_page.placeholders.get(slot="right-column")
     target_placeholder = cms_page.placeholders.get(slot="body")
     data = {"placeholder": source_placeholder, "plugin_type": "TextPlugin", "language": "en"}
     plugin_1 = add_plugin(**data)
     plugin_2 = add_plugin(**data)
     with UserLoginContext(self, superuser):
         with SettingsOverride(CMS_PLACEHOLDER_CONF=self.placeholderconf):
             request = self.get_post_request({"placeholder": target_placeholder.slot, "plugin_id": plugin_1.pk})
             response = admin.move_plugin(request)  # first
             self.assertEqual(response.status_code, 200)
             request = self.get_post_request({"placeholder": target_placeholder.slot, "plugin_id": plugin_2.pk})
             response = admin.move_plugin(request)  # second
             self.assertEqual(response.status_code, 400)
             self.assertEqual(
                 response.content, "This placeholder already has the maximum number (1) of allowed Text plugins."
             )