Example #1
0
    def test_table_name_patching(self):
        """
        This tests the plugin models patching when publishing from the command line
        """
        User = get_user_model()
        User.objects.create_superuser('djangocms', '*****@*****.**', '123456')
        create_page("The page!", "nav_playground.html", "en", published=True)
        draft = Page.objects.drafts()[0]
        draft.reverse_id = 'a_test'  # we have to change *something*
        draft.save()
        add_plugin(draft.placeholders.get(slot=u"body"),
                   u"TextPlugin", u"en", body="Test content")
        draft.publish('en')
        add_plugin(draft.placeholders.get(slot=u"body"),
                   u"TextPlugin", u"en", body="Test content")

        # Manually undoing table name patching
        Text._meta.db_table = 'djangocms_text_ckeditor_text'
        plugin_pool.patched = False

        with disable_logger(log):
            call_command('cms', 'moderator', 'on')
        # Sanity check the database (we should have one draft and one public)
        not_drafts = len(Page.objects.filter(publisher_is_draft=False))
        drafts = len(Page.objects.filter(publisher_is_draft=True))
        self.assertEqual(not_drafts, 1)
        self.assertEqual(drafts, 1)
Example #2
0
    def test_table_name_patching(self):
        """
        This tests the plugin models patching when publishing from the command line
        """
        self.get_superuser()
        create_page("The page!", "nav_playground.html", "en", published=True)
        draft = Page.objects.drafts()[0]
        draft.reverse_id = 'a_test'  # we have to change *something*
        draft.save()
        add_plugin(draft.placeholders.get(slot=u"body"),
                   u"TextPlugin", u"en", body="Test content")
        draft.publish('en')
        add_plugin(draft.placeholders.get(slot=u"body"),
                   u"TextPlugin", u"en", body="Test content")

        # Manually undoing table name patching
        Text._meta.db_table = 'djangocms_text_ckeditor_text'
        plugin_pool.patched = False

        with disable_logger(log):
            call_command('cms', 'moderator', 'on')
        # Sanity check the database (we should have one draft and one public)
        not_drafts = len(Page.objects.filter(publisher_is_draft=False))
        drafts = len(Page.objects.filter(publisher_is_draft=True))
        self.assertEqual(not_drafts, 1)
        self.assertEqual(drafts, 1)
Example #3
0
 def test_switch_moderator_on(self):
     with force_language("en"):
         pages_root = unquote(reverse("pages-root"))
     page1 = create_page('page', 'nav_playground.html', 'en', published=True)
     with disable_logger(log):
         call_command('cms', 'moderator', 'on')
     with force_language("en"):
         path = page1.get_absolute_url()[len(pages_root):].strip('/')
         page2 = get_page_from_path(path)
     self.assertEqual(page1.get_absolute_url(), page2.get_absolute_url())
Example #4
0
 def test_switch_moderator_on(self):
     with force_language("en"):
         pages_root = unquote(reverse("pages-root"))
     page1 = create_page('page', 'nav_playground.html', 'en', published=True)
     with disable_logger(log):
         call_command('cms', 'moderator', 'on')
     with force_language("en"):
         path = page1.get_absolute_url()[len(pages_root):].strip('/')
         page2 = get_page_from_path(path)
     self.assertEqual(page1.get_absolute_url(), page2.get_absolute_url())