def __call__(self):
        self.errors = {}

        if not self.request.get('form.actions.add', False):
            return self.handle_response(tmpl=self.template)
        else:
            self.authorize()
            transition = validators.not_empty(self, 'transition-name')
            transition_id = validators.id(self, 'transition-name',
                                          self.selected_workflow.transitions)

            if not self.errors:
                # must have transition to go on
                workflow = self.selected_workflow

                workflow.transitions.addTransition(transition_id)
                new_transition = workflow.transitions[transition_id]
                clone_of_id = self.request.get('clone-from-transition')
                new_transition.title = transition

                if clone_of_id:
                    # manage_copy|paste|clone doesn't work?
                    clone_transition(new_transition,
                                     workflow.transitions[clone_of_id])
                else:
                    new_transition.actbox_name = transition
                    new_transition.actbox_url = \
    "%(content_url)s/content_status_modify?workflow_action=" + transition_id
                    new_transition.actbox_category = 'workflow'
                    new_transition.script_name = ''
                    new_transition.after_script_name = ''

                # if added from state screen
                referenced_state = self.request.get('referenced-state', None)
                if referenced_state:
                    state = self.selected_workflow.states[referenced_state]
                    state.transitions += (new_transition.id, )

                return self.handle_response(message=_(
                    'msg_transition_created',
                    default=
                    u'"${transition_id}" transition successfully created.',
                    mapping={'transition_id': new_transition.id}),
                                            slideto=True,
                                            transition=new_transition)
            else:
                return self.handle_response(tmpl=self.template,
                                            justdoerrors=True)
    def __call__(self):
        self.errors = {}

        if not self.request.get('form.actions.add', False):
            return self.handle_response(tmpl=self.template)
        else:
            self.authorize()
            transition = validators.not_empty(self, 'transition-name')
            transition_id = validators.id(self, 'transition-name',
                self.selected_workflow.transitions)

            if not self.errors:
                # must have transition to go on
                workflow = self.selected_workflow

                workflow.transitions.addTransition(transition_id)
                new_transition = workflow.transitions[transition_id]
                clone_of_id = self.request.get('clone-from-transition')
                new_transition.title = transition

                if clone_of_id:
                    # manage_copy|paste|clone doesn't work?
                    clone_transition(new_transition,
                        workflow.transitions[clone_of_id])
                else:
                    new_transition.actbox_name = transition
                    new_transition.actbox_url = \
    "%(content_url)s/content_status_modify?workflow_action=" + transition_id
                    new_transition.actbox_category = 'workflow'
                    new_transition.script_name = ''
                    new_transition.after_script_name = ''

                # if added from state screen
                referenced_state = self.request.get('referenced-state', None)
                if referenced_state:
                    state = self.selected_workflow.states[referenced_state]
                    state.transitions += (new_transition.id, )

                return self.handle_response(
                    message=_('msg_transition_created',
                        default=u'"${transition_id}" transition successfully created.',
                        mapping={'transition_id': new_transition.id}),
                    slideto=True,
                    transition=new_transition)
            else:
                return self.handle_response(tmpl=self.template,
                                            justdoerrors=True)
    def __call__(self):
        self.errors = {}

        if not self.request.get('form.actions.add', False):
            return self.handle_response(tmpl=self.template)
        else:
            self.authorize()
            state = validators.not_empty(self, 'state-name')
            state_id = validators.id(self, 'state-name',
                                     self.selected_workflow.states)

            if not self.errors:
                # must have state to go on
                workflow = self.selected_workflow

                workflow.states.addState(state_id)
                new_state = workflow.states[state_id]
                clone_of_id = self.request.get('clone-from-state')
                if clone_of_id:
                    # manage_copy|paste|clone doesn't work?
                    clone_state(new_state, workflow.states[clone_of_id])

                new_state.title = state

                # if added from transition screen
                referenced_transition = self.request.get(
                    'referenced-transition', None)
                if referenced_transition:
                    new_state.transitions = \
                        new_state.transitions + (referenced_transition, )

                msg = _('msg_state_created',
                        default=u'"${state_id}" state successfully created.',
                        mapping={'state_id': new_state.id})
                return self.handle_response(
                    message=msg,
                    slideto=True,
                    state=new_state)
            else:
                return self.handle_response(tmpl=self.template,
                    justdoerrors=True)
    def __call__(self):
        self.errors = {}
        workflow = validators.not_empty(self, 'workflow-name')
        workflow_id = validators.id(self, 'workflow-name',
                                    self.portal_workflow)

        if not self.request.get('form.actions.add', False):
            return self.handle_response(tmpl=self.template)
        elif self.errors:
            return self.handle_response(tmpl=self.template, justdoerrors=True)
        else:
            self.authorize()
            # must have state to go on
            cloned_from_workflow = \
                self.portal_workflow[self.request.get('clone-from-workflow')]

            self.context.portal_workflow.manage_clone(cloned_from_workflow,
                workflow_id)
            new_workflow = self.context.portal_workflow[workflow_id]
            new_workflow.title = workflow
            self.next_id = new_workflow.id

            return self.handle_response(redirect=True)
Beispiel #5
0
    def __call__(self):
        self.errors = {}
        workflow = validators.not_empty(self, 'workflow-name')
        workflow_id = validators.id(self, 'workflow-name',
                                    self.portal_workflow)

        if not self.request.get('form.actions.add', False):
            return self.handle_response(tmpl=self.template)
        elif self.errors:
            return self.handle_response(tmpl=self.template, justdoerrors=True)
        else:
            self.authorize()
            # must have state to go on
            cloned_from_workflow = \
                self.portal_workflow[self.request.get('clone-from-workflow')]

            self.context.portal_workflow.manage_clone(cloned_from_workflow,
                workflow_id)
            new_workflow = self.context.portal_workflow[workflow_id]
            new_workflow.title = workflow
            self.next_id = new_workflow.id

            return self.handle_response(redirect=True)