(di, old_data_item, transaction)
return errors
Removes users from data items and add new ones based on the user column.

    Note the removal does not happen within a context of the "transaction"
Removes users from data items and add new ones based on the user column.
Removes users from data items and add new ones based on the user column .
def _process_user_ownership(di, old_data_item, transaction):
    """Removes users from data items and add new ones based on the user column.

    Note the removal does not happen within a context of the "transaction"
    """
    errors = []
    domain = old_data_item.domain

    old_users = old_data_item.users
    for user in old_users:
        old_data_item.remove_user(user)

    for raw_username in di.get('user', []):
        try:
            username = normalize_username(str(raw_username), domain)
        except ValidationError:
            errors.append(
                _("Invalid username: '%(name)s'. Row is not added")
                % {'name': raw_username}
            )
            continue
        user = CommCareUser.get_by_username(username)
        if user:
            old_data_item.add_user(user)
        else:
            errors.append(
                _("Unknown user: '%(name)s'. But the row is successfully added")
                % {'name': raw_username}
            )

    return errors
def _process_user_ownership ( di , old_data_item , transaction ) : errors = [ ] domain = old_data_item . domain old_users = old_data_item . users for user in old_users : old_data_item . remove_user ( user ) for raw_username in di . get ( 'user' , [ ] ) : try : username = normalize_username ( str ( raw_username ) , domain ) except ValidationError : errors . append ( _ ( "Invalid username: '%(name)s'. Row is not added" ) % { 'name' : raw_username } ) continue user = CommCareUser . get_by_username ( username ) if user : old_data_item . add_user ( user ) else : errors . append ( _ ( "Unknown user: '%(name)s'. But the row is successfully added" ) % { 'name' : raw_username } ) return errors