def handleSchedule(object, event): """ move scheduled items from to be scheduled state to schedule when draft agenda is finalised and vice versa""" session = Session() s = removeSecurityProxy(object) sitting = session.query(domain.GroupSitting).options( eagerload('sitting_type'), eagerload('item_schedule')).get(s.sitting_id) schedulings = map(removeSecurityProxy, sitting.item_schedule) if sitting.status == "draft_agenda": for sch in schedulings: if sch.item.type != "heading": wf_info = IWorkflowInfo(sch.item) transitions = wf_info.getSystemTransitionIds() state = wf_info.state() wf = wf_info.workflow() next_state = get_states(sch.item.type, tagged=["tobescheduled"]) for transition_id in transitions: t = wf.getTransition(state.getState(), transition_id) if t.destination in next_state: #TODO find out why firetransition fails for reschedule even #when the user has requisite permissions wf_info.fireTransition(transition_id, check_security=False) break elif sitting.status == "published_agenda": for sch in schedulings: if sch.item.type != "heading": wf_info = IWorkflowInfo(sch.item) transitions = wf_info.getSystemTransitionIds() state = wf_info.state() wf = wf_info.workflow() next_state = get_states(sch.item.type, tagged=["scheduled"]) for transition_id in transitions: t = wf.getTransition(state.getState(), transition_id) if t.destination in next_state: wf_info.fireTransition(transition_id, check_security=False) break
def handleSchedule(object, event): """ move scheduled items from to be scheduled state to schedule when draft agenda is finalised and vice versa """ session = Session() s = removeSecurityProxy(object) sitting = session.query(domain.GroupSitting ).options(eagerload("group_sitting_type"), eagerload("item_schedule") ).get(s.group_sitting_id) schedulings = map(removeSecurityProxy, sitting.item_schedule) if sitting.status == "draft_agenda": for sch in schedulings: if sch.item.type != "heading": wf_info = IWorkflowInfo(sch.item) transitions = wf_info.getSystemTransitionIds() state = wf_info.state() wf = wf_info.workflow() next_state = get_states(sch.item.type, tagged=["tobescheduled"]) for transition_id in transitions: t = wf.getTransition(state.getState(), transition_id) if t.destination in next_state: #TODO find out why firetransition fails for reschedule even #when the user has requisite permissions wf_info.fireTransition(transition_id, check_security=False) break elif sitting.status == "published_agenda": for sch in schedulings: if sch.item.type != "heading": wf_info = IWorkflowInfo(sch.item) transitions = wf_info.getSystemTransitionIds() state = wf_info.state() wf = wf_info.workflow() next_state = get_states(sch.item.type, tagged=["scheduled"]) for transition_id in transitions: t = wf.getTransition(state.getState(), transition_id) if t.destination in next_state: wf_info.fireTransition(transition_id, check_security=False) break
def extra(self): info = IWorkflowInfo(self.context, None) if info is None: return {"id": "plone-contentmenu-workflow"} state = info.state().getState() stateTitle = translate( str(info.workflow().workflow.states[state].title), domain="bungeni.core", context=self.request) return {"id" : "plone-contentmenu-workflow", "class" : "state-%s" % state, "state" : state, "stateTitle" : stateTitle,} # TODO: should be translated
def extra(self): info = IWorkflowInfo(self.context, None) if info is None: return {'id': 'plone-contentmenu-workflow'} state = info.state().getState() stateTitle = translate( str(info.workflow().workflow.states[state].title), domain="bungeni.core", context=self.request) return {'id' : 'plone-contentmenu-workflow', 'class' : 'state-%s' % state, 'state' : state, 'stateTitle' : stateTitle,} # TODO: should be translated
def extra(self): info = IWorkflowInfo(self.context, None) if info is None: return {"id": "plone-contentmenu-workflow"} state = info.state().getState() stateTitle = translate(str( info.workflow().workflow.states[state].title), domain="bungeni.core", context=self.request) return { "id": "plone-contentmenu-workflow", "class": "state-%s" % state, "state": state, "stateTitle": stateTitle, } # TODO: should be translated
def extra(self): info = IWorkflowInfo(self.context, None) if info is None: return {'id': 'plone-contentmenu-workflow'} state = info.state().getState() stateTitle = translate(str( info.workflow().workflow.states[state].title), domain="bungeni.core", context=self.request) return { 'id': 'plone-contentmenu-workflow', 'class': 'state-%s' % state, 'state': state, 'stateTitle': stateTitle, } # TODO: should be translated
def list_permissions(item): wf = IWorkflow(item) info = IWorkflowInfo(item) state = info.state().getState() return tuple(transition.permission for transition in wf.getTransitions(state))