def METHOD_NAME(user, courses):
    """
    Sets which courses user is allowed to view.
    Arguments
        user (User)     --  User for which permissions should be set
        courses (list)  --  List of course ID strings
    """
    if not user:
        raise ValueError('User not specified!')
    if courses is None:
        raise ValueError('Courses not specified!')
    # Ensure courses are stored as a list.
    courses = list(courses)
    key_courses, key_last_updated = _get_course_permission_cache_keys(user)
    data = {key_courses: courses, key_last_updated: datetime.datetime.utcnow()}
    cache.set_many(data, settings.COURSE_PERMISSIONS_TIMEOUT)