Beispiel #1
0
    def __call__(self):
        self.errors = {}

        if self.request.get('form.actions.add', False) == 'Add':
            self.authorize()
            am = ActionManager()
            rule = am.get_rule(self.selected_transition)
            if rule is None:
                id = generateRuleName(self.selected_transition)
                r = Rule()
                r.title = u"%s transition content rule" % (
                    self.selected_transition.id)
                r.description = """This content rule was automatically created
by the workflow manager to support actions on workflow transitions. If you want
the behavior to work as expected, do not modify this outside of the workflow
manager."""
                am.storage[id] = r
                rule = RuleAdapter(r, self.selected_transition)
                rule.activate()

            editurl = '%s/%s/+action' % (self.portal.absolute_url(), rule.id)
            data = urlencode({
                ':action':
                self.request.get('action-type', 'plone.actions.Mail'),
                'form.button.AddAction':
                'Add'
            })

            return self.handle_response(load=editurl + '?' + data)
        else:
            return self.handle_response(tmpl=self.template)
    def __call__(self):
        self.errors = {}

        if self.request.get('form.actions.add', False):
            self.authorize()
            am = ActionManager()
            rule = am.get_rule(self.selected_transition)
            if rule is None:
                rule_id = generateRuleName(self.selected_transition)
                r = Rule()
                r.title = u"%s transition content rule" % (
                    self.selected_transition.id)
                r.description = """This content rule was automatically created
by the workflow manager to support actions on workflow transitions. If you want
the behavior to work as expected, do not modify this outside of the workflow
manager."""
                am.storage[rule_id] = r
                rule = RuleAdapter(r, self.selected_transition)
                rule.activate()

            editurl = '%s/%s/+action' % (self.portal.absolute_url(), rule.id)
            data = urlencode({
                ':action': self.request.get('action-type',
                                            'plone.actions.Mail'),
                'form.button.AddAction': 'Add'})

            return self.handle_response(load=editurl + '?' + data)
        else:
            return self.handle_response(tmpl=self.template)
    def test_action_manager_action_url(self):
        portal = self.layer["portal"]
        am = ActionManager()
        pw = getToolByName(portal, "portal_workflow")
        workflow = pw["simple_publication_workflow"]
        transition = workflow.transitions["publish"]
        rule = am.create(transition)

        element = getUtility(IRuleAction, name="plone.actions.Copy")
        adding = getMultiAdapter((rule.rule, self.layer["request"]), name="+action")
        addview = getMultiAdapter((adding, self.layer["request"]), name=element.addview)

        addview.createAndAdd(data={"target_folder": "/target"})

        ra = RuleAdapter(rule, transition)
        action = ra.get_action(0)
        self.assertTrue(rule.rule.id in ra.action_url(action) and "++0" in ra.action_url(action))
Beispiel #4
0
    def test_action_manager_action_index(self):
        portal = self.layer['portal']
        am = ActionManager()
        pw = getToolByName(portal, 'portal_workflow')
        workflow = pw['simple_publication_workflow']
        transition = workflow.transitions['publish']
        rule = am.create(transition)

        element = getUtility(IRuleAction, name='plone.actions.Copy')
        adding = getMultiAdapter((rule.rule, self.layer['request']),
                                 name='+action')
        addview = getMultiAdapter((adding, self.layer['request']),
                                  name=element.addview)

        addview.createAndAdd(data={'target_folder': '/target'})

        ra = RuleAdapter(rule, transition)
        action = ra.get_action(0)
        self.assertEquals(ra.action_index(action), 0)
    def test_action_manager_action_index(self):
        portal = self.layer['portal']
        am = ActionManager()
        pw = getToolByName(portal, 'portal_workflow')
        workflow = pw['simple_publication_workflow']
        transition = workflow.transitions['publish']
        rule = am.create(transition)

        element = getUtility(IRuleAction, name='plone.actions.Copy')
        adding = getMultiAdapter((rule.rule, self.layer['request']),
                                 name='+action')
        addview = getMultiAdapter((adding, self.layer['request']),
                                  name=element.addview)

        addview.createAndAdd(data={'target_folder': '/target'})

        ra = RuleAdapter(rule, transition)
        action = ra.get_action(0)
        self.assertEquals(ra.action_index(action), 0)
Beispiel #6
0
    def test_action_manager_action_url(self):
        portal = self.layer['portal']
        am = ActionManager()
        pw = getToolByName(portal, 'portal_workflow')
        workflow = pw['simple_publication_workflow']
        transition = workflow.transitions['publish']
        rule = am.create(transition)

        element = getUtility(IRuleAction, name='plone.actions.Copy')
        adding = getMultiAdapter((rule.rule, self.layer['request']),
                                 name='+action')
        addview = getMultiAdapter((adding, self.layer['request']),
                                  name=element.addview)

        try:
            createAndAdd = addview.form_instance.createAndAdd
        except AttributeError:
            createAndAdd = addview.createAndAdd
        createAndAdd(data={'target_folder': '/target'})

        ra = RuleAdapter(rule, transition)
        action = ra.get_action(0)
        self.assertTrue(rule.rule.id in ra.action_url(action) and \
                        '++0' in ra.action_url(action))