def _handle(self, fixate):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     history = self.context.history
     principal = getattr(self.request, 'principal', None)
     history.append(
         UserNotation(getattr(principal, 'id', u"Unkown"),
                      data['workflow-message']))
     #get next URL before removing work item
     url = self.nextURL()
     self.context.finish(fixate, data['workflow-message'])
     self.request.response.redirect(url)
 def test_WorkflowHistory(self):
     from quotationtool.workflow.browser import history
     from quotationtool.workflow.interfaces import IWorkflowHistory
     from quotationtool.workflow.history import UserNotation
     # use remove as sample work item
     startRemove(TestRequest().principal.id, self.root['foo2'])
     startRemove(TestRequest().principal.id, self.root['foo2'])
     startRemove(TestRequest().principal.id, self.root['foo2'])
     hstry = IWorkflowHistory(self.root['foo2'])
     hstry.append(UserNotation(TestRequest().principal.id, "We still need it!\nBelieve me."))
     item = self.worklist.pop()
     item.finish('reject')
     pagelet = history.WorkflowHistory(self.root['foo2'], TestRequest())
     pagelet.update()
     self.assertTrue(isinstance(pagelet.render(), unicode))
 def _handle(self, finish_value):
     self.updateAttributionSubForm()
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     history = self.context.history
     principal = getattr(self.request, 'principal', None)
     history.append(
         UserNotation(getattr(principal, 'id', u"Unkown"),
                      data['workflow-message']))
     self.attribution.storeToWorkItem()
     url = self.nextURL()
     self.context.finish(finish_value, data['workflow-message'])
     self.request.response.redirect(url)
 def handleFixate(self, action):
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     history = interfaces.IWorkflowHistory(self.context)
     principal = getattr(self.request, 'principal', None)
     pd = zope.component.getUtility(IProcessDefinition,
                                    name=self.process_id,
                                    context=self.context)
     proc = pd()
     # TODO: Note that we have to remove the security proxy!
     proc.start(getattr(principal, 'id', u"Unkown"),
                datetime.datetime.now(), data['workflow-message'],
                removeAllProxies(history), removeAllProxies(self.context))
     history.append(
         UserNotation(getattr(principal, 'id', u"Unknown"),
                      data['workflow-message']))
     #self.template = ViewPageTemplateFile('fixate_process_started.pt')
     self.request.response.redirect(self.nextURL())
 def handleReclassify(self, action):
     self.updateAttributionSubForm()
     data, errors = self.extractData()
     if errors:
         self.status = self.formErrorsMessage
         return
     history = IWorkflowHistory(self.context)
     principal = getattr(self.request, 'principal', None)
     if self.checkPermission():
         # store input data to context (attribution.getContent() returns it)
         self.attribution.storeToWorkItem()
     else:
         # store input data to persistent attribution
         pattr = PersistentAttribution()
         attr_data, attr_errors = self.attribution.extractData()
         categories = []
         for catset in attr_data.values():
             for cat in catset:
                 categories.append(cat.__name__)
         pattr.set(categories)
         # start workflow process
         self.process_started = True
         pd = zope.component.getUtility(IProcessDefinition,
                                        name='quotationtool.reclassify')
         context = ReclassificationContext(removeAllProxies(self.context))
         proc = pd(context)
         proc.start(getattr(principal, 'id', u"Unknown"),
                    datetime.datetime.now(), data['workflow-message'],
                    removeAllProxies(history), removeAllProxies(pattr))
     # write history
     history.append(
         UserNotation(getattr(principal, 'id', u"Unknown"),
                      data['workflow-message']))
     zope.event.notify(ObjectModifiedEvent(self.context))
     # redirect to next url
     self.request.response.redirect(self.nextURL())