#NEWLINE# def for_user( self , user , obj , check_groups = True ) : #NEWLINE# #INDENT# perms = self . get_for_model ( obj ) #NEWLINE# if ( not check_groups ) : #NEWLINE# #INDENT# return perms . select_related ( 'user' , 'creator' ) . filter ( user = user ) #NEWLINE# #UNINDENT# return perms . select_related ( 'user' , 'creator' ) . prefetch_related ( 'user__groups' ) . filter ( ( Q ( user__pk = user . pk ) | Q ( group__in = user . groups . all ( ) ) ) )