def test_executeTransition(self):
        brains = self.cat.searchResults({})

        executeTransition(self.portal, self.wf_tool, "publish", [brains[2].UID], comment="Bla Bla Bla Mr. Freeman")

        brains = self.cat.searchResults({})
        self.assertEqual(brains[2].review_state, "published")
示例#2
0
    def test_executeTransition(self):
        brains = self.cat.searchResults({})

        executeTransition(self.portal,
                          self.wf_tool,
                          'publish', [brains[2].UID],
                          comment="Bla Bla Bla Mr. Freeman")

        brains = self.cat.searchResults({})
        self.assertEqual(brains[2].review_state, 'published')
示例#3
0
    def test_execution(self):
        catalog = api.portal.get_tool('portal_catalog')

        folder1 = create(Builder('folder'))
        folder2 = create(Builder('folder'))

        uids = [folder1.UID(), folder2.UID()]

        executeTransition(self.portal, self.wf_tool, 'publish', uids, 'Lorem')

        self.assertEqual(
            len(catalog.searchResults({'review_state': 'published'})), 2)
示例#4
0
    def test_do_not_execute_transition_if_transition_is_not_allowed(self):
        self.site_manager.registerUtility(
            DummyCheckerFalse(), IConstraintChecker, name=u'checker1: False')

        folder = create(Builder('folder'))

        uids = [folder.UID(), ]

        executeTransition(self.portal, self.wf_tool, 'publish', uids, 'Lorem')

        self.assertEqual(
            'private',
            api.content.get_state(obj=folder),
            'The folder should still be private because the checker was false')
示例#5
0
    def test_execution(self):
        catalog = api.portal.get_tool('portal_catalog')

        folder1 = create(Builder('folder'))
        folder2 = create(Builder('folder'))

        uids = [
            folder1.UID(),
            folder2.UID()
            ]

        executeTransition(self.portal, self.wf_tool, 'publish', uids, 'Lorem')

        self.assertEqual(
            len(catalog.searchResults({'review_state': 'published'})), 2)
示例#6
0
    def test_do_not_execute_transition_if_transition_is_not_allowed(self):
        self.site_manager.registerUtility(DummyCheckerFalse(),
                                          IConstraintChecker,
                                          name=u'checker1: False')

        folder = create(Builder('folder'))

        uids = [
            folder.UID(),
        ]

        executeTransition(self.portal, self.wf_tool, 'publish', uids, 'Lorem')

        self.assertEqual(
            'private', api.content.get_state(obj=folder),
            'The folder should still be private because the checker was false')
示例#7
0
    def test_publish_if_ftw_publisher_constraints_are_true(self):
        # Publishing an object if the parent object is published
        # should be possible with the publisher example workflow.
        # See ftw.publisher.sender test on github:
        # test_example_workflow_constraint_definition.py

        folder = create(Builder('folder').in_state(EXAMPLE_WF_PUBLISHED))
        page = create(
            Builder('page').within(folder).in_state(EXAMPLE_WF_INTERNAL))

        uids = [
            page.UID(),
        ]

        executeTransition(self.portal, self.wf_tool, EXAMPLE_WF_PUBLISH_ACTION,
                          uids, 'Lorem')

        self.assertEqual(
            EXAMPLE_WF_PUBLISHED, api.content.get_state(obj=folder),
            'The page should still be published because the checker was true')
示例#8
0
    def change_states(self):
        transition = self.request.get("transition", "")
        comment = self.request.get("comment", "")
        uids = self.request.get("uids", [])
        error = False

        if not transition:
            msg = _(u"msg_no_transtion", default=u"Please select a Transition")
            IStatusMessage(self.request).addStatusMessage(msg, type="error")
            error = True
        if len(uids) == 0:
            msg = _(u"msg_no_uids", default=u"Please select at least one Item")
            IStatusMessage(self.request).addStatusMessage(msg, type="error")
            error = True
        if error:
            return
        executeTransition(self.context, self.wf_tool, transition, uids, comment)
        msg = _(u"msg_transition_successful", default=u"Transition executed successfully.")
        IStatusMessage(self.request).addStatusMessage(msg, type="info")
        return self.request.RESPONSE.redirect(self.context.absolute_url() + "/statusmap")
    def test_publish_if_ftw_publisher_constraints_are_true(self):
        # Publishing an object if the parent object is published
        # should be possible with the publisher example workflow.
        # See ftw.publisher.sender test on github:
        # test_example_workflow_constraint_definition.py

        folder = create(Builder('folder')
                        .in_state(EXAMPLE_WF_PUBLISHED))
        page = create(Builder('page')
                      .within(folder)
                      .in_state(EXAMPLE_WF_INTERNAL))

        uids = [page.UID(), ]

        executeTransition(
            self.portal, self.wf_tool, EXAMPLE_WF_PUBLISH_ACTION, uids, 'Lorem')

        self.assertEqual(
            EXAMPLE_WF_PUBLISHED,
            api.content.get_state(obj=folder),
            'The page should still be published because the checker was true')
示例#10
0
    def change_states(self):
        transition = self.request.get('transition', '')
        comment = self.request.get('comment', '')
        uids = self.request.get('uids', [])
        error = False

        if not transition:
            msg = _(u'msg_no_transtion', default=u"Please select a Transition")
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            error = True
        if len(uids) == 0:
            msg = _(u'msg_no_uids', default=u"Please select at least one Item")
            IStatusMessage(self.request).addStatusMessage(msg, type='error')
            error = True
        if error:
            return
        executeTransition(self.context, self.wf_tool, transition, uids,
                          comment)
        msg = _(u'msg_transition_successful',
                default=u"Transition executed successfully.")
        IStatusMessage(self.request).addStatusMessage(msg, type='info')
        return self.request.RESPONSE.redirect(self.context.absolute_url() +
                                              '/statusmap')