'Grant this object\'s user the object\'s role for the supplied courses'

def add_course(self, *course_keys):

    if (self.user.is_authenticated() and self.user.is_active):
        for course_key in course_keys:
            entry = CourseAccessRole(user=self.user, role=self.role, course_id=course_key, org=course_key.org)
            entry.save()
        if hasattr(self.user, '_roles'):
            del self.user._roles
    else:
        raise ValueError('user    is    not    active.    Cannot    grant    access    to    courses')
