'Performs conversions on user-supplied field data, to make it
easier for users to pass human-readable data.
For all fields that have choice sets, convert their values
from human-readable strings to enum values, if necessary.  This
allows users to pass strings instead of the corresponding
integer values.
For all foreign key fields, call smart_get with the supplied
data.  This allows the user to pass either an ID value or
the name of the object as a string.
If to_human_readable=True, perform the inverse - i.e. convert
numeric values to human readable values.
This method modifies data in-place.'

@classmethod
def convert_human_readable_values(cls, data, to_human_readable=False):

    field_dict = cls.get_field_dict()
    for field_name in data:
        if ((field_name not in field_dict) or (data[field_name] is None)):
            continue
        field_obj = field_dict[field_name]
        if field_obj.choices:
            for choice_data in field_obj.choices:
                if to_human_readable:
                    (from_val, to_val) = choice_data
                else:
                    (to_val, from_val) = choice_data
                if (from_val == data[field_name]):
                    data[field_name] = to_val
                    break
        elif field_obj.rel:
            dest_obj = field_obj.rel.to.smart_get(data[field_name], valid_only=False)
            if to_human_readable:
                if (dest_obj.name_field is not None):
                    data[field_name] = getattr(dest_obj, dest_obj.name_field)
            else:
                data[field_name] = dest_obj
