def add_user_to_cohort(cohort, username_or_email):
 user = get_user_by_username_or_email(username_or_email)
 membership = CohortMembership(course_user_group=cohort, user=user)
 membership.save()
 tracker.emit('edx.cohort.user_add_requested', {'user_id': user.id, 'cohort_id': cohort.id, 'cohort_name': cohort.name, 'previous_cohort_id': membership.previous_cohort_id, 'previous_cohort_name': membership.previous_cohort_name})
 return (user, membership.previous_cohort_name)

def add_user_to_cohort ( cohort , username_or_email ) : user = get_user_by_username_or_email ( username_or_email ) membership = CohortMembership ( course_user_group = cohort , user = user ) membership . save ( ) tracker . emit ( 'edx.cohort.user_add_requested' , { 'user_id' : user . id , 'cohort_id' : cohort . id , 'cohort_name' : cohort . name , 'previous_cohort_id' : membership . previous_cohort_id , 'previous_cohort_name' : membership . previous_cohort_name } ) return ( user , membership . previous_cohort_name )
look up the given user .