Ejemplo n.º 1
0
    def update(self, transition_id=None):
        if IWorkspaceContainer.providedBy(self.context.__parent__):
            self._old_url = WorkspaceAbsoluteURLView(self.context,
                                                     self.request)()
        workflow = interfaces.IWorkflow(self.context)
        if transition_id:
            transition = workflow.get_transition(transition_id)
            title = translate(_(transition.title), context=self.request)
            self.status = translate(_(
                u"Confirmation required for workflow transition: '${title}'",
                mapping={"title": title}),
                                    context=self.request)
        self.setupActions(transition_id)

        if (ILegislativeContent.providedBy(self.context)
                and get_mask(self.context) == "manual"
                and not self.context.registry_number):
            self.form_fields = self.form_fields.omit("note", "date_active")
        else:
            self.form_fields = self.form_fields.omit("registry_number")

        if not self.actions:
            self.form_fields = self.form_fields.omit("note", "date_active")
        elif not IFeatureAudit.providedBy(self.context):
            self.form_fields = self.form_fields.omit("note", "date_active")
        # !+SUPERFLUOUS_ObejctModifiedEvent(mr, nov-2011) the following update()
        # is causing a ModifiedEvent to be fired, causing a modify change to be
        # logged (while this workflow change should be just that).
        super(WorkflowActionViewlet, self).update()
Ejemplo n.º 2
0
 def update(self, transition_id=None):
     if IWorkspaceContainer.providedBy(self.context.__parent__):
         self._old_url = WorkspaceAbsoluteURLView(
             self.context, self.request)()
     workflow = interfaces.IWorkflow(self.context)
     if transition_id:
         transition = workflow.get_transition(transition_id)
         title = translate(_(transition.title), context=self.request)
         self.status = translate(
             _(u"Confirmation required for workflow transition: '${title}'",
                 mapping={"title": title}
             ), 
             context=self.request)
     self.setupActions(transition_id)
     
     if (ILegislativeContent.providedBy(self.context) and
             get_mask(self.context) == "manual" and 
             not self.context.registry_number
         ):
         self.form_fields = self.form_fields.omit("note", "date_active")
     else:
         self.form_fields = self.form_fields.omit("registry_number")
     
     if not self.actions: 
         self.form_fields = self.form_fields.omit("note", "date_active")
     elif not IFeatureAudit.providedBy(self.context):
         self.form_fields = self.form_fields.omit("note", "date_active")
     # !+SUPERFLUOUS_ObejctModifiedEvent(mr, nov-2011) the following update()
     # is causing a ModifiedEvent to be fired, causing a modify change to be 
     # logged (while this workflow change should be just that).
     super(WorkflowActionViewlet, self).update()
Ejemplo n.º 3
0
    def __call__(self, transition_id=None, headless=False):
        # parameters coming in via URL querystring or post vars !
        method = self.request["REQUEST_METHOD"]
        # !+ALWAYS_POST(mr, sep-2011) requests coming from link clicks (GETs)
        # from the bungeni Web UI seem to always be intercepted and switched
        # into POSTs.
        workflow = interfaces.IWorkflow(self.context)

        require_confirmation = True
        if transition_id is not None:
            self.update(transition_id)
            require_confirmation = workflow.get_transition(
                transition_id).require_confirmation
        else:
            self.update()

        if (ILegislativeContent.providedBy(self.context)
                and get_mask(self.context) == "manual"
                and not self.context.registry_number):
            require_confirmation = True

        if (not require_confirmation and method == "POST"):
            actions = bindTransitions(self.action_viewlet, (transition_id, ),
                                      workflow)
            assert len(actions) == 1
            # execute action
            # !+ should pass self.request.form as data? e.g. value is:
            # {u"next_url": u"...", u"transition": u"submit_response"}
            result = actions[0].success({})
            # !+UNUSED(mr, jun-2011) this result is never used!

        if headless:
            actions = get_actions("context_workflow", self.context,
                                  self.request)
            state_title = workflow.get_state(self.context.status).title
            result = self.ajax_template(actions=actions,
                                        state_title=state_title)
            if require_confirmation:
                self.request.response.setStatus(403)
            else:
                self.request.response.setStatus(200)
                self.request.response.setResult(result)
                self.request.response.setHeader("Content-Type", "text/xml")
            return result

        template = self.template()
        return template
Ejemplo n.º 4
0
 def __call__(self, transition_id=None, headless=False):
     # parameters coming in via URL querystring or post vars !
     method = self.request["REQUEST_METHOD"]
     # !+ALWAYS_POST(mr, sep-2011) requests coming from link clicks (GETs) 
     # from the bungeni Web UI seem to always be intercepted and switched 
     # into POSTs.
     workflow = interfaces.IWorkflow(self.context)
     
     require_confirmation = True
     if transition_id is not None: 
         self.update(transition_id)
         require_confirmation = workflow.get_transition(transition_id
             ).require_confirmation
     else:
         self.update()
     
     if (ILegislativeContent.providedBy(self.context) and
             get_mask(self.context) == "manual" and 
             not self.context.registry_number
         ):
         require_confirmation = True
     
     if (not require_confirmation and method == "POST"):
         actions = bindTransitions(
             self.action_viewlet, (transition_id,), workflow)
         assert len(actions) == 1
         # execute action
         # !+ should pass self.request.form as data? e.g. value is:
         # {u"next_url": u"...", u"transition": u"submit_response"}
         result = actions[0].success({})
         # !+UNUSED(mr, jun-2011) this result is never used!
     
     if headless:
         actions = get_actions("context_workflow", self.context, self.request)
         state_title = workflow.get_state(self.context.status).title
         result = self.ajax_template(actions=actions, state_title=state_title)
         if require_confirmation:
             self.request.response.setStatus(403)
         else:
             self.request.response.setStatus(200)
             self.request.response.setResult(result)
             self.request.response.setHeader("Content-Type", "text/xml")
         return result
         
     template = self.template()
     return template