Пример #1
0
    def update_state_permissions(self):
        wf = self.selected_workflow
        state = wf.states[self.request.get('selected-state')]
        perm_roles = PersistentMapping()
        available_roles = state.getAvailableRoles()

        for managed_perm in managed_permissions(wf.id):
            selected_roles = []
            for role in available_roles:
                key = 'permission-%s-role-%s-state-%s' % (
                    managed_perm['name'], role, state.id)
                if key in self.request:
                    selected_roles.append(role)

            acquire_key = 'permission-acquire-%s-state-%s' % (
                managed_perm['name'], state.id)
            if acquire_key in self.request:
                acquired = True
            else:
                acquired = False

            if len(selected_roles) > 0:
                if not acquired:
                    selected_roles = tuple(selected_roles)
                perm_roles[managed_perm['perm']] = selected_roles
                if managed_perm['perm'] not in wf.permissions:
                    wf.permissions = wf.permissions + (managed_perm['perm'], )
            elif managed_perm['perm'] in wf.permissions:
                # it's managed, no perms set, but still could save acquired
                if acquired:
                    perm_roles[managed_perm['perm']] = []
                else:
                    perm_roles[managed_perm['perm']] = ()
            elif not acquired:
                # not already managing perms, but no longer acquire permissions
                if managed_perm['perm'] not in wf.permissions:
                    wf.permissions = wf.permissions + (managed_perm['perm'], )
                perm_roles[managed_perm['perm']] = ()

        state.permission_roles = perm_roles
 def managed_permissions(self):
     return managed_permissions(self.selected_workflow.getId())
Пример #3
0
 def managed_permissions(self):
     return managed_permissions(self.selected_workflow.getId())