def test_version_menu_for_version_content_no_permission(self):
     """Manage versions entry shouldn't appear if user doesn't have
     access to that endpoint"""
     user = UserFactory(is_staff=True)
     version = PollVersionFactory()
     toolbar = get_toolbar(version.content, user=user, preview_mode=True)
     toolbar.post_template_populate()
     version_menu = toolbar.toolbar.get_menu("version")
     self.assertFalse(version_menu.get_items())
    def test_edit_not_in_toolbar_in_structure_mode(self):
        version = PollVersionFactory()
        toolbar = get_toolbar(version.content,
                              user=self.get_superuser(),
                              structure_mode=True)

        toolbar.post_template_populate()

        self.assertFalse(toolbar_button_exists("Edit", toolbar.toolbar))
Example #3
0
    def test_for_grouper(self):
        poll1_version2 = PollVersionFactory(
            content__poll=self.initial_version.content.poll)
        poll2_version = PollVersionFactory()
        PollVersionFactory(content__poll=poll2_version.content.poll)
        PollVersionFactory(content__poll=poll2_version.content.poll)

        versionable = VersionableItem(
            content_model=PollContent,
            grouper_field_name="poll",
            copy_function=default_copy,
        )

        self.assertQuerysetEqual(
            versionable.for_grouper(self.initial_version.content.poll),
            [self.initial_version.content.pk, poll1_version2.content.pk],
            transform=lambda x: x.pk,
            ordered=False,
        )
Example #4
0
 def test_version_menu_and_url_for_version_content(self):
     # Versioned item should have versioning menu and url should be version list url
     version = PollVersionFactory()
     toolbar = get_toolbar(version.content,
                           user=self.get_superuser(),
                           preview_mode=True)
     toolbar.post_template_populate()
     version_menu = toolbar.toolbar.get_menu("version")
     self.assertIsNotNone(version_menu)
     self.assertEqual(version_menu.get_items()[0].url,
                      version_list_url(version.content))
Example #5
0
    def test_edit_in_toolbar_in_preview_mode(self):
        version = PollVersionFactory()
        toolbar = self._get_toolbar(version.content, preview_mode=True)

        toolbar.post_template_populate()

        edit_button = toolbar.toolbar.get_right_items()[0].buttons[0]
        self.assertEqual(edit_button.name, 'Edit')
        self.assertEqual(edit_button.url, self._get_edit_url(version))
        self.assertFalse(edit_button.disabled)
        self.assertListEqual(edit_button.extra_classes,
                             ['cms-btn-action', 'cms-versioning-js-edit-btn'])
Example #6
0
    def test_version_menu_label(self):
        # Versioned item should have correct version menu label
        version = PollVersionFactory()
        toolbar = get_toolbar(version.content,
                              user=self.get_superuser(),
                              preview_mode=True)
        toolbar.post_template_populate()
        version_menu = toolbar.toolbar.get_menu("version")

        expected_label = "Version #{number} ({state})".format(
            number=version.number, state=version.state)

        self.assertEqual(expected_label, version_menu.name)
    def test_publish_in_toolbar_in_edit_mode(self):
        version = PollVersionFactory()
        toolbar = get_toolbar(version.content, edit_mode=True)

        toolbar.post_template_populate()
        publish_button = find_toolbar_buttons('Publish', toolbar.toolbar)[0]

        self.assertEqual(publish_button.name, 'Publish')
        self.assertEqual(publish_button.url, self._get_publish_url(version))
        self.assertFalse(publish_button.disabled)
        self.assertListEqual(
            publish_button.extra_classes,
            ['cms-btn-action', 'cms-versioning-js-publish-btn'])
Example #8
0
 def test_version_menu_for_version_content(self):
     # Versioned item should have versioning menu
     user = UserFactory(is_staff=True)
     user.user_permissions.add(
         Permission.objects.get(
             content_type__app_label="djangocms_versioning",
             codename="change_pollcontentversion",
         ))
     version = PollVersionFactory()
     toolbar = get_toolbar(version.content, user=user, preview_mode=True)
     toolbar.post_template_populate()
     version_menu = toolbar.toolbar.get_menu("version")
     self.assertEqual(version_menu.get_items()[0].name,
                      "Manage Versions...")
Example #9
0
    def test_url_for_edit_uses_version_id_not_content_id(self):
        """Regression test for a bug. Make sure than when we generate
        the edit url, we use the id of the version record, not the
        id of the content record.
        """
        # All versions are stored in the version table so increase the
        # id of version id sequence by creating a blogpost version
        BlogPostVersionFactory()
        # Now create a poll version - the poll content and version id
        # will be different.
        version = PollVersionFactory()
        toolbar = self._get_toolbar(version.content, preview_mode=True)

        toolbar.post_template_populate()

        edit_button = toolbar.toolbar.get_right_items()[0].buttons[0]
        self.assertEqual(edit_button.url, self._get_edit_url(version))
Example #10
0
    def test_url_for_publish_uses_version_id_not_content_id(self):
        """Regression test for a bug. Make sure than when we generate
        the publish url, we use the id of the version record, not the
        id of the content record.
        """
        # All versions are stored in the version table so increase the
        # id of version id sequence by creating a blogpost version
        BlogPostVersionFactory()
        # Now create a poll version - the poll content and version id
        # will be different.
        version = PollVersionFactory()
        toolbar = get_toolbar(version.content,
                              user=self.get_superuser(),
                              edit_mode=True)
        toolbar.post_template_populate()
        publish_button = find_toolbar_buttons("Publish", toolbar.toolbar)[0]

        self.assertEqual(publish_button.url, self._get_publish_url(version))
Example #11
0
 def setUp(self):
     self.initial_version = PollVersionFactory()