コード例 #1
0
ファイル: generator.py プロジェクト: 4teamwork/ftw.lawgiver
    def _apply_specification_statements(self, status_nodes,
                                        transition_nodes):
        transition_statements = dict([(status, set()) for status in
                                      status_nodes.keys()])

        per_status_role_inheritance = {}

        for status, snode in sorted(status_nodes.items(),
                                    key=lambda item: item[0].title):
            statements = set(status.statements) | set(
                self.specification.generals)

            role_inheritance = merge_role_inheritance(self.specification,
                                                      status)
            per_status_role_inheritance[status] = role_inheritance

            status_stmts, trans_stmts = self._distinguish_statements(
                statements)
            transition_statements[status].update(trans_stmts)

            self._apply_status_statements(snode, status_stmts,
                                          role_inheritance)

            self._add_worklist_when_necessary(status, role_inheritance)

        self._apply_transition_statements(transition_statements,
                                          transition_nodes,
                                          per_status_role_inheritance)
コード例 #2
0
ファイル: sharing.py プロジェクト: jowent/ftw.lawgiver
    def _get_action_group_grid_data(self, spec, rolename):
        """Returns a nested dict with the table / grid data, where
        the outer dict keys are the action groups and the innner
        dict keys are the statues and the inner dict values is the
        HTML cell value (tick character).

        result['edit']['Private'] = self.CHECKED
        """

        action_groups = defaultdict(dict)
        for status in spec.states.values():
            ploneroles = [spec.role_mapping[rolename]]

            role_inheritance = merge_role_inheritance(spec, status)
            ploneroles = get_roles_inherited_by(ploneroles, role_inheritance)
            statements = spec.generals + status.statements

            for statement_spec_role, action_group in statements:
                statement_plone_role = spec.role_mapping[statement_spec_role]
                if statement_plone_role not in ploneroles:
                    continue

                action_groups[action_group][status.title] = self.CHECKED

        return action_groups
コード例 #3
0
ファイル: sharing.py プロジェクト: 4teamwork/ftw.lawgiver
    def _get_action_group_grid_data(self, spec, rolename):
        """Returns a nested dict with the table / grid data, where
        the outer dict keys are the action groups and the innner
        dict keys are the statues and the inner dict values is the
        HTML cell value (tick character).

        result['edit']['Private'] = self.CHECKED
        """

        action_groups = defaultdict(dict)
        for status in spec.states.values():
            ploneroles = [spec.role_mapping[rolename]]

            role_inheritance = merge_role_inheritance(spec, status)
            ploneroles = get_roles_inherited_by(ploneroles, role_inheritance)
            statements = spec.generals + status.statements

            for statement_spec_role, action_group in statements:
                statement_plone_role = spec.role_mapping[statement_spec_role]
                if statement_plone_role not in ploneroles:
                    continue

                action_groups[action_group][status.title] = self.CHECKED

        return action_groups
コード例 #4
0
    def _apply_specification_statements(self, status_nodes, transition_nodes):
        transition_statements = dict([(status, set())
                                      for status in status_nodes.keys()])

        per_status_role_inheritance = {}

        for status, snode in sorted(status_nodes.items(),
                                    key=lambda item: item[0].title):
            statements = set(status.statements) | set(
                self.specification.generals)

            role_inheritance = merge_role_inheritance(self.specification,
                                                      status)
            per_status_role_inheritance[status] = role_inheritance

            status_stmts, trans_stmts = self._distinguish_statements(
                statements)
            transition_statements[status].update(trans_stmts)

            self._apply_status_statements(snode, status_stmts,
                                          role_inheritance)

            self._add_worklist_when_necessary(status, role_inheritance)

        self._apply_transition_statements(transition_statements,
                                          transition_nodes,
                                          per_status_role_inheritance)
コード例 #5
0
    def test_includes_general_inheritance(self):
        spec = Specification(title='My Workflow',
                             role_inheritance=[('admin', 'visitor')],
                             role_mapping=ROLE_MAPPING)
        status = Status('Private', [])

        self.assertEquals([('Manager', 'Anonymous')],
                          merge_role_inheritance(spec, status))
コード例 #6
0
    def test_merges_general_and_status_inheritance(self):
        spec = Specification(title='My Workflow',
                             role_inheritance=[('admin', 'visitor')],
                             role_mapping=ROLE_MAPPING)
        status = Status('Private', [], role_inheritance=[('admin', 'writer')])

        self.assertItemsEqual([('Manager', 'Anonymous'),
                               ('Manager', 'Editor')],
                              merge_role_inheritance(spec, status))
コード例 #7
0
    def test_includes_status_inheritance(self):
        spec = Specification(title='My Workflow',
                             role_mapping=ROLE_MAPPING)
        status = Status('Private', [],
                        role_inheritance=[('admin', 'writer')])

        self.assertEquals(
            [('Manager', 'Editor')],
            merge_role_inheritance(spec, status))
コード例 #8
0
    def test_merges_general_and_status_inheritance(self):
        spec = Specification(title='My Workflow',
                             role_inheritance=[('admin', 'visitor')],
                             role_mapping=ROLE_MAPPING)
        status = Status('Private', [],
                        role_inheritance=[('admin', 'writer')])

        self.assertItemsEqual(
            [('Manager', 'Anonymous'),
             ('Manager', 'Editor')],
            merge_role_inheritance(spec, status))