Example #1
0
    def _principal_search_results(self, search_for_principal,
                                  get_principal_by_id, get_principal_title,
                                  principal_type, id_key):
        """A mapper for the original method, to constraint the users
        list to only the users which are assigned to the current client"""

        all_principals = SharingView._principal_search_results(
            self, search_for_principal, get_principal_by_id,
            get_principal_title, principal_type, id_key)

        if len(all_principals) == 0:
            return all_principals

        info = getUtility(IContactInformation)
        assigned_users = [user.userid for user in info.list_assigned_users()]
        results = []

        registry = getUtility(IRegistry)
        reg_proxy = registry.forInterface(ISharingConfiguration)

        for principal in all_principals:
            # users
            if principal.get('type') == 'user':
                if principal.get('id') in assigned_users:
                    results.append(principal)

            # groups
            elif re.search(reg_proxy.black_list_prefix, principal.get('id')):
                if re.search(reg_proxy.white_list_prefix, principal.get('id')):
                    results.append(principal)
            else:
                results.append(principal)
        return results
Example #2
0
 def roles(self):
     """
     Manage additional roles in addition to the default, these
     app-specific roles need not have ISharingPageRole utilities
     registered.
     """
     sharing_page_managed_roles = SharingView.roles(self)
     return sharing_page_managed_roles + APP_ROLES
Example #3
0
 def roles(self):
     """
     Manage additional roles in addition to the default, these
     app-specific roles need not have ISharingPageRole utilities
     registered.
     """
     sharing_page_managed_roles = SharingView.roles(self)
     return sharing_page_managed_roles + APP_ROLES
    def update_role_settings(self, new_settings, reindex=True):
        """Update local role settings and reindex object security if necessary.

        new_settings is a list of dicts with keys id, for the user/group id;
        type, being either 'user' or 'group'; and roles, containing the list
        of role ids that are set.

        Returns True if changes were made, or False if the new settings
        are the same as the existing settings.
        """

        before = self.context.get_local_roles(raw=True)
        changed = BaseView.update_role_settings(self, new_settings, reindex=False)
        after = self.context.get_local_roles(raw=True)
        if reindex and dict(before) != dict(after):
            self.context.reindexObjectSecurity()
        return changed
Example #5
0
    def _principal_search_results(self,
                                  search_for_principal,
                                  get_principal_by_id,
                                  get_principal_title,
                                  principal_type,
                                  id_key):
        """A mapper for the original method, to constraint the users
        list to only the users which are assigned to the current client"""

        all_principals = SharingView._principal_search_results(
            self,
            search_for_principal,
            get_principal_by_id,
            get_principal_title,
            principal_type,
            id_key)

        if len(all_principals) == 0:
            return all_principals

        info = getUtility(IContactInformation)
        assigned_users = [user.userid for user in info.list_assigned_users()]
        results = []

        registry = getUtility(IRegistry)
        reg_proxy = registry.forInterface(ISharingConfiguration)

        for principal in all_principals:
            # users
            if principal.get('type') == 'user':
                if principal.get('id') in assigned_users:
                    results.append(principal)

            # groups
            elif re.search(reg_proxy.black_list_prefix, principal.get('id')):
                if re.search(reg_proxy.white_list_prefix, principal.get('id')):
                    results.append(principal)
            else:
                results.append(principal)
        return results
Example #6
0
 def roles(self):
     """
     Reduce the available roles for sharing
     """
     pairs = OSV.roles(self)
     return [ p for p in pairs if p['id'] == 'Reader' ]