def user_update(request, user, **data):
    manager = keystoneclient(request, admin=True).users
    error = None

    if not keystone_can_edit_user():
        raise keystone_exceptions.ClientException(
            405, _("Identity service does not allow editing user data."))

    # The v2 API updates user model and default project separately
    if VERSIONS.active < 3:
        # Update user details
        try:
            user = manager.update(user, **data)
        except keystone_exceptions.Conflict:
            raise exceptions.Conflict()
        except Exception:
            error = exceptions.handle(request, ignore=True)

        if "project" in data:
            project = data.pop('project')

            # Update default tenant
            try:
                user_update_tenant(request, user, project)
                user.tenantId = project
            except Exception:
                error = exceptions.handle(request, ignore=True)

            # Check for existing roles
            # Show a warning if no role exists for the project
            user_roles = roles_for_user(request, user, project)
            if not user_roles:
                messages.warning(request,
                                 _('User %s has no role defined for '
                                   'that project.')
                                 % data.get('name', None))

        if error is not None:
            raise error

    # v3 API is so much simpler...
    else:
        try:
            user = manager.update(user, **data)
        except keystone_exceptions.Conflict:
            raise exceptions.Conflict()
dataset/ETHPy150Open openstack/horizon/openstack_dashboard/api/keystone.py/user_update/original