def has_permission(perm, user, obj):
    """ Check whether the user has the permisson on the object (or the
    objects' permission_authority)."""
    authority = getattr(obj, 'permission_authority', obj)
    if not authority:
        return True
    return user.has_perm(perm, obj=authority)
