def get_containing_dossier(obj): while not IPloneSiteRoot.providedBy(obj): if IDossierMarker.providedBy(obj) or IInbox.providedBy(obj): return obj obj = aq_parent(aq_inner(obj)) return None
def test_adding(self): portal = self.layer['portal'] setRoles(portal, TEST_USER_ID, ['Contributor']) portal.invokeFactory('opengever.inbox.inbox', 'inbox1') i1 = portal['inbox1'] self.failUnless(IInbox.providedBy(i1))
def main_dossier_title(obj): """Return the title of the main dossier.""" if obj.portal_type not in TYPES_WITH_CONTAINING_DOSSIER_INDEX: return None dossier = get_main_dossier(obj) if not dossier: return None try: title = dossier.Title() except TypeError: # XXX: During upgrades, the odd case can happen that a mail inside a # forwarding inside the inbox wants to have its containing_dossier # reindexed. This can lead to a situation where we attempt to adapt # the Inbox to ITranslatedTitle, but it doesn't provide this behavior # yet because that behavior is going to be actived in the very same # upgrade. # # Account for this case, and fall back to inbox.title, which # will contain the original title (in unicode though). if IInbox.providedBy(dossier): title = dossier.title.encode('utf-8') else: raise return title
def can_access_archival_file_form(user, content): """Returns True if the user has 'Modify portal content' permission in any open dossier state. And the containing dossier is - not a templatefolder - not inactive - not an inbox """ assert IBaseDocument.providedBy( content), 'Content needs to provide IBaseDocument' dossier = find_parent_dossier(content) if ITemplateFolder.providedBy(dossier): return False if IInbox.providedBy(dossier): return False if api.content.get_state(obj=dossier) == 'dossier-state-inactive': return False wftool = api.portal.get_tool('portal_workflow') workflow_id = wftool.getChainForPortalType(dossier.portal_type)[0] user_roles = user.getRolesInContext(dossier) for open_state in DOSSIER_STATES_OPEN: state = wftool.get(workflow_id).states.get(open_state) if state is None: continue roles_with_modify = state.permission_roles['Modify portal content'] if bool(set(roles_with_modify).intersection(user_roles)): return True return False
def test_adding(self): portal = self.layer["portal"] setRoles(portal, TEST_USER_ID, ["Contributor"]) portal.invokeFactory("opengever.inbox.inbox", "inbox1") i1 = portal["inbox1"] self.failUnless(IInbox.providedBy(i1))
def get_parent_inbox(self): """Return the document's parent inbox or None.""" parent = aq_parent(aq_inner(self)) if IInbox.providedBy(parent): return parent return None
def _has_default_role_assignments(self, obj): return any([ IRepositoryRoot.providedBy(obj), IInbox.providedBy(obj), IInboxContainer.providedBy(obj), ITemplateFolder.providedBy(obj), IContactFolder.providedBy(obj), ])
def test_adding(self, browser): self.grant('Manager') add_languages(['de-ch']) browser.login().open() factoriesmenu.add('Inbox') browser.fill({'Title': 'Inbox'}).save() self.assertTrue(IInbox.providedBy(browser.context))
def get_main_dossier(obj): """Helper method which returns the main dossier (or inbox) of the given object. If the given object is not storred inside a dossier it returns None.""" dossier = None while not IPloneSiteRoot.providedBy(obj): if IDossierMarker.providedBy(obj) or IInbox.providedBy(obj): dossier = obj obj = aq_parent(aq_inner(obj)) return dossier
def find_parent_dossier(content): """Returns the first parent dossier (or inbox) relative to the current context. """ if IPloneSiteRoot.providedBy(content): raise ValueError('Site root passed as argument.') while content and not (IDossierMarker.providedBy(content) or IInbox.providedBy(content)): content = aq_parent(aq_inner(content)) if IPloneSiteRoot.providedBy(content): raise ValueError('Site root reached while searching ' 'parent dossier.') return content
def __call__(self, factories): if not IInbox.providedBy(self.context): # use default return factories cleaned_factories = [] for factory in factories: if factory['extra']['id'] not in [ u'ftw-mail-mail', u'opengever-inbox-forwarding', u'opengever-inbox-yearfolder']: cleaned_factories.append(factory) # Order the factory-menu cleaned_factories = order_factories(self.context, cleaned_factories) return cleaned_factories
def __call__(self, factories): if not IInbox.providedBy(self.context): # use default return factories cleaned_factories = [] for factory in factories: if factory['extra']['id'] not in [ u'ftw-mail-mail', u'opengever-inbox-forwarding', u'opengever-inbox-yearfolder' ]: cleaned_factories.append(factory) # Order the factory-menu cleaned_factories = order_factories(self.context, cleaned_factories) return cleaned_factories
def can_access_public_trial_edit_form(user, content): """Returns True if the user has 'Modify portal content' permission in any open dossier state. And the containing dossier is - not a templatefolder - not inactive - not an inbox """ assert IBaseDocument.providedBy( content), 'Content needs to provide IBaseDocument' wftool = getToolByName(content, 'portal_workflow') dossier = find_parent_dossier(content) if ITemplateFolder.providedBy(dossier): return False if IInbox.providedBy(dossier): return False if wftool.getInfoFor(dossier, 'review_state') == 'dossier-state-inactive': return False workflow_id = wftool.getChainForPortalType(dossier.portal_type)[0] user_roles = user.getRolesInContext(dossier) has_role = False for open_state in DOSSIER_STATES_OPEN: state = wftool.get(workflow_id).states.get(open_state) if state is None: continue roles_with_modify = state.permission_roles['Modify portal content'] has_role = bool(set(roles_with_modify) & set(user_roles)) if has_role: break else: continue return has_role
def test_factory(self): fti = queryUtility(IDexterityFTI, name="opengever.inbox.inbox") factory = fti.factory new_object = createObject(factory) self.failUnless(IInbox.providedBy(new_object))
def test_factory(self): fti = queryUtility(IDexterityFTI, name='opengever.inbox.inbox') factory = fti.factory new_object = createObject(factory) self.failUnless(IInbox.providedBy(new_object))