def app(self): parent = self.context.__parent__ while parent is not None: if IBungeniApplication.providedBy(parent): return parent parent = parent.__parent__ raise ValueError("Unable to locate application.")
def getMenuItems(self, context, request): """Return menu item entries in a TAL-friendly form.""" if interfaces.IBusinessWhatsOnSectionLayer.providedBy(request): return () else: if IBungeniApplication.providedBy(context.__parent__): return () wf = IWorkflow(context, None) if wf is None: return () #state = IWorkflowInfo(context).state().getState() wf_info = IWorkflowInfo(context) transitions = wf_info.getManualTransitionIds() # !+ context_workflow menu: the order of transitions is alphabetic, but # should really be order of definition. parliament_id = getCurrentParliamentId() url = ui_url.absoluteURL(context, request) site_url2 = ui_url.absoluteURL(getSite(), request) results = [] for transition in transitions: tid = transition state_transition = wf.getTransitionById(transition) #Compares the current url to homepage to determine whether we are on workspace or not. #Fix for bug 319 #Someone should probably review this. if url == site_url2: transition_url = site_url2 + \ '/archive/browse/parliaments/obj-' + str(parliament_id) + \ '/change_workflow_state?' + \ 'transition=%s&next_url=...' % tid else: transition_url = url + \ '/change_workflow_state?'\ 'transition=%s&next_url=...' % tid extra = { 'id': 'workflow-transition-%s' % tid, 'separator': None, 'class': '' } state_title = translate(str(state_transition.title), domain="bungeni.core", context=request) results.append( dict(title=state_title, description="", action=transition_url, selected=False, transition_id=tid, icon=None, extra=extra, submenu=None)) return results
def getMenuItems(self, context, request): """Return menu item entries in a TAL-friendly form.""" if interfaces.IBusinessWhatsOnSectionLayer.providedBy(request): return () else: if IBungeniApplication.providedBy(context.__parent__): return () wf = IWorkflow(context, None) if wf is None: return () #state = IWorkflowInfo(context).state().getState() wf_info = IWorkflowInfo(context) transitions = wf_info.getManualTransitionIds() # !+ context_workflow menu: the order of transitions is alphabetic, but # should really be order of definition. parliament_id = getCurrentParliamentId() _url = url.absoluteURL(context, request) site_url2 = url.absoluteURL(getSite(), request) results = [] for transition in transitions: tid = transition state_transition = wf.getTransitionById(transition) #Compares the current url to homepage to determine whether we are on workspace or not. #Fix for bug 319 #Someone should probably review this. if _url == site_url2: transition_url = site_url2 + \ "/archive/browse/parliaments/obj-" + str(parliament_id) + \ "/change_workflow_state?" + \ "transition=%s&next_url=..." % tid else: transition_url = _url + \ "/change_workflow_state?"\ "transition=%s&next_url=..." % tid extra = {"id": "workflow-transition-%s" % tid, "separator": None, "class": ""} state_title = translate(str(state_transition.title), domain="bungeni.core", context=request) results.append( dict(title=state_title, description="", action=transition_url, selected=False, transition_id=tid, icon=None, extra=extra, submenu=None)) return results