Beispiel #1
0
def dict_to_student(d):
    """
    Convert dictionary to Student object
    :param d: dictionary
    :return: Student object
    """
    st_obj = Student()
    st_obj.username = d[
        'username'] if 'username' in d else ''  # each student has a unique username
    st_obj.first_name = d['first_name'] if 'first_name' in d else ''
    st_obj.last_name = d['last_name'] if 'last_name' in d else ''
    st_obj.email = d['email']
    st_obj.password = d['password']
    st_obj.linkedin_token = d['linkedin_token'] if 'linkedin_token' in d else ''
    st_obj.github_token = d['github_token'] if 'github_token' in d else ''
    st_obj.skills = d['skills'] if 'skills' in d else []  # list of strings
    st_obj.need_visa = d[
        'need_visa'] if 'need_visa' in d else 'no'  # boolean STRING
    st_obj.location = d['location'] if 'location' in d else 'New York'  # string
    st_obj.looking_for = d['looking_for'] if 'looking_for' in d else [
        'Internship', 'Full-Time', 'Co-op'
    ]  # list
    st_obj.job_matches = d['job_matches'] if 'job_matches' in d else []  # list
    st_obj.favorited_jobs = d['favorited_jobs'] if 'favorited_jobs' in d else [
    ]  # list
    st_obj.declined_jobs = d['declined_jobs'] if 'declined_jobs' in d else [
    ]  # list

    return st_obj
Beispiel #2
0
def li_to_student(d):
    """
    Convert linkedin profile API response to student object
    :param d: Linkedin API response dict
    :return: Student representation
    """

    st_obj = Student()
    st_obj.username = d['emailAddress']  # each student has a unique username
    st_obj.first_name = d['firstName']
    st_obj.last_name = d['lastName']
    st_obj.email = d['emailAddress']
    st_obj.password = ''
    st_obj.linkedin_token = ''
    st_obj.github_token = ''
    st_obj.skills = []
    st_obj.need_visa = ''
    st_obj.location = d['location']['name']  # string
    st_obj.looking_for = []
    st_obj.job_matches = []
    st_obj.favorited_jobs = []
    st_obj.declined_jobs = []

    return st_obj