On Feb 3, 2011, at 6:14 AM, Franzé Jr wrote:
> On Thu, Feb 3, 2011 at 11:08 AM, Clayton <[email protected]> wrote:
> Hello,
> 
> I can't seem to find an easy way to check if a *group* has a
> permission without making my own query on the auth_permission table
> (and then I lose auth logging and the code is uglier).
> auth.has_permission only works on users, not groups, as far as I can
> tell. I need it for a control which is adding and removing permissions
> from groups.
> 
> add_permission and del_permission use groups. Shouldn't there perhaps
> be a function that checks whether a group has a given permission? Or
> am I just missing something.
> 
> Cheers,
> 
> Clayton
> 
> I have the same doubt.

Proposal:

Change Auth.has_permission from this:

    def has_permission(
        self,
        name='any',
        table_name='',
        record_id=0,
        user_id=None,
        ):

to this:

    def has_permission(
        self,
        name='any',
        table_name='',
        record_id=0,
        user_id=None,
        group_id=None,
        ):

If the caller specifies a group_id, then we check permissions on that group 
instead of the groups the user belongs to. It is an error to call 
has_permission with both user_id and group_id.

The change would be simple.

Reply via email to