def _update(self): spec = get_specification_for(self.context) workflow = get_workflow_for(self.context) if spec is None or workflow is None: return rolename = self._get_untranslated_role_name(spec) if rolename is None: return self.table_data = self._get_table_data(spec, workflow, rolename) self.role_description = self._get_role_description( spec, workflow, rolename)
def available_roles(self): if get_specification_for(self.context) is not None: # In lawgiver workflow specifications we can configure the # "visible roles", therefore we dont need to overwrite the # behavior here. return self.roles() result = [] for key, value in ROLE_MAPPING: if key.providedBy(self.context) or key is IStandard: roles = [r.get('id') for r in self.roles()] for role_id, title in value: if role_id in roles: result.append( {'id': role_id, 'title': title, }) return result return self.roles()
def available_roles(self): if get_specification_for(self.context) is not None: # In lawgiver workflow specifications we can configure the # "visible roles", therefore we dont need to overwrite the # behavior here. return self.roles() result = [] for key, value in ROLE_MAPPING: if key.providedBy(self.context) or key is IStandard: roles = [r.get('id') for r in self.roles()] for role_id, title in value: if role_id in roles: result.append({ 'id': role_id, 'title': title, }) return result return self.roles()
def is_available(self): """Returns True when sharing description is available for this context. It is only available when a lawgiver workflow is used for this context. """ return bool(get_specification_for(self.context))
def test_get_specification_for_non_managed_object(self): self.assertIsNone(get_specification_for(self.portal))
def test_get_specification_for_object(self): folder = create(Builder('folder')) spec = get_specification_for(folder) self.assertTrue(spec) self.assertEquals('My Custom Workflow', spec.title)