예제 #1
0
 def objectStateChanged(self, object, event):
     """
     object: origin domain workflowed object 
     event: bungeni.core.workflow.states.WorkflowTransitionEvent
         .object # origin domain workflowed object 
         .source # souirce state
         .destination # destination state
         .transition # transition
         .comment #
     """
     change_data = self._get_change_data()
     # if note, attach it on object (if object supports such an attribute)
     if change_data["note"]:
         if hasattr(object, "note"):
             object.note = change_data["note"]
     # update object's workflow status date (if supported by object)
     if hasattr(object, "status_date"):
         object.status_date = change_data["date_active"] or datetime.now()
     # as a "base" description, use human readable workflow state title
     wf = IWorkflow(object) # !+ adapters.get_workflow(object)
     description = wf.get_state(event.destination).title
     # extras, that may be used e.g. to elaborate description at runtime
     extras = {
         "source": event.source, 
         "destination": event.destination,
         "transition": event.transition.id,
         "comment": change_data["note"]
     }
     return self._objectChanged("workflow", object, 
                     description=description,
                     extras=extras,
                     date_active=change_data["date_active"])
예제 #2
0
def schedule_sitting_items(context):
    
    # !+fireTransitionToward(mr, dec-2010) sequence of fireTransitionToward 
    # calls was introduced in r5818, 28-jan-2010 -- here the code is reworked
    # to be somewhat more sane, and added logging of both SUCCESS and of 
    # FAILURE of each call to fireTransitionToward().
    #
    # The check/logging should be removed once it is understood whether
    # NoTransitionAvailableError is *always* raised (i.e. fireTransitionToward is
    # broken) or it is indeed raised correctly when it should be.
    
    def fireTransitionScheduled(item, check_security=False):
        try:
            IWorkflowController(item).fireTransitionToward("scheduled", 
                    check_security=False)
            raise RuntimeWarning(
                """It has WORKED !!! fireTransitionToward("scheduled")""")
        except (NoTransitionAvailableError, RuntimeWarning):
            debug.log_exc_info(sys.exc_info(), log.error)
    
    for schedule in context.item_schedule:
        wf = IWorkflow(schedule.item, None)
        if wf is None: 
            continue
        try:
            if wf.get_state("scheduled"):
                fireTransitionScheduled(schedule.item)
        except InvalidStateError:
            pass
예제 #3
0
 def objectStateChanged(self, object, event):
     """
     object: origin domain workflowed object 
     event: bungeni.core.workflow.states.WorkflowTransitionEvent
         .object # origin domain workflowed object 
         .source # souirce state
         .destination # destination state
         .transition # transition
         .comment #
     """
     change_data = self._get_change_data()
     # if note, attach it on object (if object supports such an attribute)
     if change_data["note"]:
         if hasattr(object, "note"):
             object.note = change_data["note"]
     # update object's workflow status date (if supported by object)
     if hasattr(object, "status_date"):
         object.status_date = change_data["date_active"] or datetime.now()
     # as a "base" description, use human readable workflow state title
     wf = IWorkflow(object)  # !+ adapters.get_workflow(object)
     description = wf.get_state(event.destination).title
     # extras, that may be used e.g. to elaborate description at runtime
     extras = {
         "source": event.source,
         "destination": event.destination,
         "transition": event.transition.id,
         "comment": change_data["note"]
     }
     return self._objectChanged("workflow",
                                object,
                                description=description,
                                extras=extras,
                                date_active=change_data["date_active"])
예제 #4
0
def schedule_sitting_items(context):

    # !+fireTransitionToward(mr, dec-2010) sequence of fireTransitionToward
    # calls was introduced in r5818, 28-jan-2010 -- here the code is reworked
    # to be somewhat more sane, and added logging of both SUCCESS and of
    # FAILURE of each call to fireTransitionToward().
    #
    # The check/logging should be removed once it is understood whether
    # NoTransitionAvailableError is *always* raised (i.e. fireTransitionToward is
    # broken) or it is indeed raised correctly when it should be.

    def fireTransitionScheduled(item, check_security=False):
        try:
            IWorkflowController(item).fireTransitionToward(
                "scheduled", check_security=False)
            raise RuntimeWarning(
                """It has WORKED !!! fireTransitionToward("scheduled")""")
        except (NoTransitionAvailableError, RuntimeWarning):
            debug.log_exc_info(sys.exc_info(), log.error)

    for schedule in context.item_schedule:
        wf = IWorkflow(schedule.item, None)
        if wf is None:
            continue
        try:
            if wf.get_state("scheduled"):
                fireTransitionScheduled(schedule.item)
        except InvalidStateError:
            pass
예제 #5
0
 def get_status(self, item_type):
     workspace_config = component.getUtility(IWorkspaceTabsUtility)
     roles = get_workspace_roles() + OBJECT_ROLES
     domain_class = workspace_config.get_domain(item_type)
     results = set()
     for role in roles:
         status = workspace_config.get_status(role, domain_class,
                                              self.context.__name__)
         if status:
             for s in status:
                 results.add(s)
     translated = dict()
     for result in results:
         workflow = IWorkflow(domain_class())
         status_title = translate(str(workflow.get_state(result).title),
                                  domain="bungeni",
                                  context=self.request)
         translated[result] = status_title
     return translated
예제 #6
0
 def get_status(self, item_type):
     workspace_config = component.getUtility(IWorkspaceTabsUtility)
     roles = get_workspace_roles() + OBJECT_ROLES
     domain_class = workspace_config.get_domain(item_type)
     results = set()
     for role in roles:
         status = workspace_config.get_status(
             role, domain_class, self.context.__name__)
         if status:
             for s in status:
                 results.add(s)
     translated = dict()
     for result in results:
         workflow = IWorkflow(domain_class())
         status_title = translate(
             str(workflow.get_state(result).title),
             domain="bungeni",
             context=self.request
             )
         translated[result] = status_title
     return translated