Exemple #1
0
    def list_opset_groups(self, account, opset_name):
        """ Return groups where L{account} has the specific permission
        L{opset_name}.

        This is a complement to the L{list_ownership_accounts). This method is
        meant for answering questions like 'which groups am I moderating?'

        @type group: Cerebrum.Account
        @param group: The account to list 'moderated group' for.

        @type opset_name: str
        @param opset_name: The permission to list groups for.

        @rtype: list
        @return: A list of dictionaries with keys:
                 ['group_id', 'group_name', 'url', 'description',
                  'account_id', 'account_name']
        """
        assert opset_name in GROUP_AUTH_OPSETS
        assert hasattr(account, 'entity_id')

        gr = self.group_class(self.db)
        ba = BofhdVirtHomeAuth(self.db)
        aos = BofhdAuthOpSet(self.db)
        aos.find_by_name(opset_name)

        tmp = list(ba.get_permission_holders_on_groups(
            aos.op_set_id, account_id=account.entity_id))
        for entry in tmp:
            gr.clear()
            gr.find(entry['group_id'])
            entry['url'] = gr.get_contact_info(self.co.virthome_group_url)

        return tmp
Exemple #2
0
    def list_opset_groups(self, account, opset_name):
        """ Return groups where L{account} has the specific permission
        L{opset_name}.

        This is a complement to the L{list_ownership_accounts). This method is
        meant for answering questions like 'which groups am I moderating?'

        @type group: Cerebrum.Account
        @param group: The account to list 'moderated group' for.

        @type opset_name: str
        @param opset_name: The permission to list groups for.

        @rtype: list
        @return: A list of dictionaries with keys: 
                 ['group_id', 'group_name', 'url', 'description', 
                  'account_id', 'account_name']
        """
        assert opset_name in GROUP_AUTH_OPSETS
        assert hasattr(account, 'entity_id')

        gr = self.group_class(self.db)
        ba = BofhdVirtHomeAuth(self.db)
        aos = BofhdAuthOpSet(self.db)
        aos.find_by_name(opset_name)

        tmp = list(ba.get_permission_holders_on_groups(
            aos.op_set_id, account_id=account.entity_id))
        for entry in tmp:
            gr.clear()
            gr.find(entry['group_id'])
            entry['url'] = gr.get_contact_info(self.co.virthome_group_url)
        
        return tmp
Exemple #3
0
    def list_opset_accounts(self, group, opset_name):
        """ Return accounts holding a specific permission L{opset_name} on
        L{group}.

        This method is meant for answering questions like 'which accounts
        moderate this group?'.

        @type group: Cerebrum.Group
        @param group: A populated group object to list 'moderators' for.

        @rtype: list
        @return: A list of dictionaries with keys:
                 ['account_id', 'account_name', 'owner_name', 'email_address',
                  'group_id', 'group_name', 'description']

        See also L{list_opset_groups}.
        """
        assert opset_name in GROUP_AUTH_OPSETS
        assert hasattr(group, 'entity_id')

        ac = self.account_class(self.db)
        ba = BofhdVirtHomeAuth(self.db)
        aos = BofhdAuthOpSet(self.db)
        aos.find_by_name(opset_name)

        tmp = list(ba.get_permission_holders_on_groups(
            aos.op_set_id, group_id=group.entity_id))
        for entry in tmp:
            ac.clear()
            ac.find(entry['account_id'])
            entry['owner_name'] = ac.get_owner_name(self.co.human_full_name)
            entry['email_address'] = ac.get_email_address()

        return tmp
Exemple #4
0
    def list_opset_accounts(self, group, opset_name):
        """ Return accounts holding a specific permission L{opset_name} on
        L{group}.

        This method is meant for answering questions like 'which accounts
        moderate this group?'.

        @type group: Cerebrum.Group
        @param group: A populated group object to list 'moderators' for.

        @rtype: list
        @return: A list of dictionaries with keys: 
                 ['account_id', 'account_name', 'owner_name', 'email_address',
                  'group_id', 'group_name', 'description']

        See also L{list_opset_groups}.
        """
        assert opset_name in GROUP_AUTH_OPSETS
        assert hasattr(group, 'entity_id')

        ac = self.account_class(self.db)
        ba = BofhdVirtHomeAuth(self.db)
        aos = BofhdAuthOpSet(self.db)
        aos.find_by_name(opset_name)

        tmp = list(ba.get_permission_holders_on_groups(
            aos.op_set_id, group_id=group.entity_id))
        for entry in tmp:
            ac.clear()
            ac.find(entry['account_id'])
            entry['owner_name'] = ac.get_owner_name(self.co.human_full_name)
            entry['email_address'] = ac.get_email_address()
            
        return tmp