Пример #1
0
    def test_workflow_history_is_migrated(self):
        self.set_workflow_chain(for_type='Folder',
                                to_workflow='simple_publication_workflow')

        folder = create(Builder('folder'))
        self.execute_transition(folder, 'publish')

        self.assert_workflow_history_length(folder, 2)
        self.assert_workflow_history_entry(
            folder, {
                'action': 'publish',
                'actor': 'test_user_1_',
                'comments': '',
                'review_state': 'published'
            })

        mapping = {
            ('simple_publication_workflow', 'intranet_folder_workflow'): {
                'published': 'internal'
            }
        }
        with WorkflowChainUpdater([folder], mapping):
            self.set_workflow_chain(for_type='Folder',
                                    to_workflow='intranet_folder_workflow')

        self.assert_workflow_history_length(folder, 2)
        self.assert_workflow_history_entry(
            folder, {
                'action': 'publish',
                'actor': 'test_user_1_',
                'comments': '',
                'review_state': 'internal'
            }, -1)
Пример #2
0
    def test_changing_workflow_with_mapping(self):
        self.set_workflow_chain(for_type='Folder',
                                to_workflow='intranet_folder_workflow')

        private_folder = create(
            Builder('folder').titled('Private Folder').in_state('private'))
        published_folder = create(
            Builder('folder').titled('Published Folder').in_state('internal'))

        objects = [private_folder, published_folder]
        mapping = {
            ('intranet_folder_workflow', 'folder_workflow'): {
                'private': 'visible',
                'internal': 'published'
            }
        }

        with WorkflowChainUpdater(objects, mapping):
            self.set_workflow_chain(for_type='Folder',
                                    to_workflow='folder_workflow')

        self.assertReviewStates({
            private_folder: 'visible',
            published_folder: 'published'
        })
Пример #3
0
    def __call__(self):
        query = {'portal_type': 'opengever.dossier.templatedossier'}
        objects = self.catalog_unrestricted_search(query, full_objects=True)
        review_state_mapping = {
            ('opengever_templatedossier_workflow', 'opengever_templatefolder_workflow'): {
                'templatedossier-state-active': 'templatefolder-state-active'}
            }

        # Save current ITemplateDossierProperties settings
        create_doc_properties = api.portal.get_registry_record(
            'create_doc_properties', ITemplateDossierProperties)

        with WorkflowChainUpdater(objects, review_state_mapping,
                                  migrate_workflow_history=False) as updater:
            self.install_upgrade_profile()
            for obj in ProgressLogger("Migrate type opengever.dossier.templatedossier "
                                      "to opengever.dossier.templatefolder",
                                      updater.objects):

                self.migrate_class(obj, TemplateFolder)
                obj.portal_type = 'opengever.dossier.templatefolder'
                notify(ObjectModifiedEvent(obj))

        # Restore current ITemplateDossierProperties settings
        api.portal.set_registry_record(
            'create_doc_properties',
            create_doc_properties,
            ITemplateFolderProperties)
Пример #4
0
    def activate_policy(self, policy_id, review_state_mapping,
                        activate_in=True, activate_below=True,
                        **chain_updater_kwargs):

        with WorkflowChainUpdater(self.get_objects(), review_state_mapping,
                                  **chain_updater_kwargs):
            self._activate_placeful_policy(policy_id,
                                           activate_in=activate_in,
                                           activate_below=activate_below)
Пример #5
0
    def activate_lawgiver_workflow(self, portal_type, review_state_mapping):
        objects = self.catalog_unrestricted_search({'portal_type': portal_type},
                                                   full_objects=True)

        with WorkflowChainUpdater(objects, review_state_mapping):
            yield

        # Remove all old states from all old workflows so that we have a
        # clean new state.
        portal_workflow = self.getToolByName('portal_workflow')
        for ((old_wf, new_wf), state_mapping) in review_state_mapping.items():
            states = portal_workflow.get(old_wf).states
            states.deleteStates(
                [old_state for old_state in state_mapping.keys()
                 if old_state in states])
Пример #6
0
    def test_object_security_is_updated(self):
        self.set_workflow_chain(for_type='Folder',
                                to_workflow='intranet_workflow')

        container = create(
            Builder('folder').titled('Container').in_state('external'))

        mapping = {
            ('intranet_workflow', 'plone_workflow'): {
                'external': 'published'
            }
        }

        with WorkflowChainUpdater([container], mapping):
            self.set_workflow_chain(for_type='Folder',
                                    to_workflow='plone_workflow')

        self.assertSecurityIsUpToDate()
Пример #7
0
    def test_workflow_history_is_not_migrated_when_migration_disabled(self):
        self.set_workflow_chain(for_type='Folder',
                                to_workflow='simple_publication_workflow')

        folder = create(Builder('folder'))
        self.assert_workflow_history_length(folder, 1)

        mapping = {
            ('simple_publication_workflow', 'folder_workflow'): {
                'published': 'published'
            }
        }
        with WorkflowChainUpdater([folder],
                                  mapping,
                                  migrate_workflow_history=False):
            self.set_workflow_chain(for_type='Folder',
                                    to_workflow='folder_workflow')

        self.assert_workflow_history_length(folder, 0)
Пример #8
0
    def test_state_is_set_correctly_when_wfhistory_migration_is_disabled(self):
        self.set_workflow_chain(for_type='Folder',
                                to_workflow='simple_publication_workflow')

        folder = create(Builder('folder'))
        self.assert_workflow_history_length(folder, 1)

        mapping = {
            ('simple_publication_workflow', 'intranet_folder_workflow'): {
                'published': 'internal'
            }
        }
        with WorkflowChainUpdater([folder],
                                  mapping,
                                  migrate_workflow_history=False):
            self.set_workflow_chain(for_type='Folder',
                                    to_workflow='intranet_folder_workflow')

        self.assert_workflow_history_length(folder, 0)
        self.assertReviewStates({folder: 'internal'})
Пример #9
0
    def test_object_security_is_reindexed(self):
        self.set_workflow_chain(for_type='Folder',
                                to_workflow='intranet_workflow')

        container = create(
            Builder('folder').titled('Container').in_state('internal'))

        self.assertIn('Member',
                      self.get_allowed_roles_and_users(for_object=container))

        mapping = {
            ('intranet_workflow', 'plone_workflow'): {
                'internal': 'published'
            }
        }

        with WorkflowChainUpdater([container], mapping):
            self.set_workflow_chain(for_type='Folder',
                                    to_workflow='plone_workflow')

        self.assertEquals(
            ['Anonymous'],
            self.get_allowed_roles_and_users(for_object=container))