def group_owners_changed(**kwargs):
    """
    Handle changes in group ownership.
    This could be broken out into 2 signal receivers, but that would involve
    2 duplicate queries to the User table to get a list of changed owners
    """

    # If this is a change in owners, grab the list of owners
    if ['post_add', 'post_remove'] in kwargs['action']:
        users = get_user_model().objects.filter(pk__in=kwargs['pk_set'])

        # Clear the user's 'owned_groups' cache
        for user in users:
            cache.delete(user.cache_key + 'owned_groups')

    # Make sure group owners can direct message all other users
    if kwargs['action'] == 'post_add':
        direct_message_permission = Permission.objects.get(
            codename='can_initiate_direct_messages',
            content_type__app_label='accounts')
        for user in users:
            user.user_permissions.add(direct_message_permission)
dataset/ETHPy150Open ofa/connect/open_connect/groups/models.py/group_owners_changed/swapped operands of `in`