Пример #1
0
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 templatedossier
     - not inactive
    """

    assert IBaseDocument.providedBy(
        content), 'Content needs to provide IBaseDocument'

    wftool = getToolByName(content, 'portal_workflow')
    dossier = find_parent_dossier(content)

    if ITemplateDossier.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)

        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
Пример #2
0
 def test_return_itself_if_dossier_is_passed(self):
     dossier = create(Builder('dossier'))
     self.assertEquals(dossier, find_parent_dossier(dossier))
Пример #3
0
    def test_find_first_parent_dossier(self):
        dossier = create(Builder('dossier'))
        task = create(Builder('task').within(dossier))
        document = create(Builder('document').within(task))

        self.assertEquals(dossier, find_parent_dossier(document))
Пример #4
0
    def test_find_parent_on_nested_dossierts(self):
        dossier = create(Builder('dossier'))
        subdossier = create(Builder('dossier').within(dossier))
        document = create(Builder('document').within(subdossier))

        self.assertEquals(subdossier, find_parent_dossier(document))
Пример #5
0
 def test_raise_valuerror_if_plone_root_is_reached(self):
     document = create(Builder('document'))
     with self.assertRaises(ValueError):
         find_parent_dossier(document)
Пример #6
0
 def test_raise_valuerror_if_plone_root_is_passed(self):
     with self.assertRaises(ValueError):
         find_parent_dossier(self.portal)