def update_extra_view_permissions(**kwargs):
    """
    Get all views that inherit the PermissionViewMetaClass and
    adding them permission.
    """
    logger.info('Updating extra views permissions...')
    admin_classes = {}
    for model, admin_class in ralph_site._registry.items():
        for change_view in admin_class.change_views:
            admin_classes[change_view] = model

    old_permission = Permission.objects.filter(
        codename__startswith='can_view_extra_'
    ).values_list('id', flat=True)
    current_permission = []
    for class_view, codename in _permission_views:
        model = admin_classes.get(class_view, None)
        if not model:
            model = get_user_model()
        ct = ContentType.objects.get_for_model(model)
        perm, _ = Permission.objects.get_or_create(
            content_type=ct,
            codename=codename,
            defaults={'name': 'Can view {}'.format(class_view.__name__)}
        )
        current_permission.append(perm.id)

    # Remove old permission codename views.
    permission_ids = set(current_permission) - set(old_permission)
    if permission_ids:
        logger.warning(
            'Removing unused permissions: {}'.format(", ".join(
                Permission.objects.filter(id__in=permission_ids).values_list(
                    'codename', flat=True
                )
            ))
        )
        Permission.objects.filter(id__in=permission_ids).delete()
dataset/ETHPy150Open allegro/ralph/src/ralph/lib/permissions/views.py/update_extra_view_permissions/swapped operands of `-`