Exemple #1
0
def mentee_list():          
    menteeList = Mentee.query.all()
    for mentee in menteeList:
        user = User.query.filter_by(email=mentee.email).first()
        mentee.email_hash = user.email_hash
        mentee.mentor = user.mentor
        #if mentor remove empty accts
        if current_user.is_mentor():
            if mentee.company is None:
                menteeList.remove(mentee)
    mentor = None
    if current_user.is_mentor():
        mentor = User.query.filter_by(email=current_user.email).first()
    return render_template('menteelist.html', title='Mentee List', mentees=menteeList, mentor=mentor)
Exemple #2
0
def mentor_shortlist():
    if current_user.is_company():
        cohort = Company.query.filter_by(email=current_user.email).first()
        mentors = Mentor.query.filter_by(cohort=cohort)
        prefMentors = [cohort.mentor1, cohort.mentor2, cohort.mentor3]
    elif current_user.is_admin():
        mentors = None
        prefMentors = None
    elif current_user.is_mentor():
        mentors = None
        prefMentors = None
    else:
        mentee = Mentee.query.filter_by(email=current_user.email).first()
        mentors = Mentor.query.filter_by(mentee=mentee)
        prefMentors = [mentee.mentor1, mentee.mentor2, mentee.mentor3]
    mentorList = []
    for mentor in mentors:
        user = User.query.filter_by(email=mentor.email).first()
        # clean the data a bit before passing to mentees
        if current_user.access == 0:
            mentor.email = None
        mentor.email_hash = user.email_hash
        mentorList.append(mentor)
            
    return render_template('mentorshortlist.html', title='Mentor Shortlist', mentors=mentorList, prefMentors=prefMentors)
Exemple #3
0
def dashboard():
    if current_user.is_admin():
        return render_template('dashboard.html', title='Dashboard')
    elif current_user.is_mentor():
        return redirect(url_for('mentee_list'))
    else:
        return redirect(url_for('mentor_list'))
Exemple #4
0
def mentee_shortlist():
    if current_user.is_mentor():
        user = User.query.filter_by(email=current_user.email).first()
        mentees = Mentee.query.filter_by(mentorpref=user)
        menteeList = []
        cohorts = Company.query.filter_by(mentorpref=user)
        cohortList = []
              
        # preferred mentees
        mentor = Mentor.query.filter_by(email=current_user.email).first()
        prefMentees = [mentor.mentee1, mentor.mentee2, mentor.mentee3]

        for mentee in mentees:
            user = User.query.filter_by(email=mentee.email).first()
            mentee.email_hash = user.email_hash
            menteeList.append(mentee)
        
        for cohort in cohorts:
            user = User.query.filter_by(email=cohort.email).first()
            cohort.email_hash = user.email_hash
            cohortList.append(cohort)
    else:
        menteeList = None
        cohortList = None
        prefMentees = None
    return render_template('menteeshortlist.html', title='Mentee Shortlist', mentees=menteeList, cohorts=cohortList, prefMentees=prefMentees)
Exemple #5
0
def edit_picture():
    profile_pic_filepath = 'https://s3.ca-central-1.amazonaws.com/enlight-hub-profile-pictures/'
    if current_user.is_mentor():
        profile_pic_filepath += 'mentors/' + str(current_user.email_hash) + '-profile-pic.png'
    elif current_user.is_company():
        profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
    else:
        profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
    return render_template('edit_picture.html', title='Edit Profile Picture', profile_pic_filepath=profile_pic_filepath)
Exemple #6
0
def homepage():
    if current_user.is_admin():
        return render_template('home_mentor.html', title='Home')
    elif current_user.is_mentor():
        return render_template('home_mentor.html', title='Home')
    elif current_user.is_company():
        return render_template('home_cohort.html', title='Home')
    else:
        app = Application.query.filter_by(email=current_user.email).first()
        return render_template('home_gm.html', title='Home', app=app)
Exemple #7
0
def shortlist():
    if current_user.is_company():
        return redirect(url_for('mentor_shortlist'))
    elif current_user.is_admin():
        flash('Feature not available for admin.')
        return redirect(url_for('dashboard'))
    elif current_user.is_mentor():
        return redirect(url_for('mentee_shortlist'))
    else:
        return redirect(url_for('mentor_shortlist'))
Exemple #8
0
def company_list():          
    companyList = Company.query.all()
    for company in companyList:
        memberList = Mentee.query.filter_by(company_l=company)
        if memberList:
            for member in memberList:
                user = User.query.filter_by(email=member.email).first()
                member.email_hash = user.email_hash
    mentor = None
    if current_user.is_mentor():
        mentor = User.query.filter_by(email=current_user.email).first()
    return render_template('companylist.html', title='Company List', companies=companyList, mentor=mentor)
Exemple #9
0
def combined_list():          
    menteeList = Mentee.query.all()
    companyList = Company.query.all()
    for mentee in menteeList:
        user = User.query.filter_by(email=mentee.email).first()
        mentee.email_hash = user.email_hash
        mentee.mentor = user.mentor
        # if mentor mark empty accts for removal
        if current_user.is_mentor():
            if mentee.company is None:
                menteeList.remove(mentee)
    for company in companyList:
        user = User.query.filter_by(email=company.email).first()
        company.email_hash = user.email_hash
        company.mentor = user.mentor
        #if mentor remove empty accts
        if current_user.is_mentor():
            if company.company is None:
                companyList.remove(company)
    mentor = None
    if current_user.is_mentor():
        mentor = User.query.filter_by(email=current_user.email).first()
    return render_template('combinedlist.html', title='Mentee List', mentees=menteeList, cohorts=companyList, mentor=mentor)
Exemple #10
0
def del_menteepref(menteeId):
    user = User.query.filter_by(email_hash=menteeId).first()
    if current_user.is_mentor():
        mentor = User.query.filter_by(email=current_user.email).first()
        if user.is_company():
            cohort = Company.query.filter_by(email=user.email).first()
            cohort.mentorpref = None
        else:
            mentee = Mentee.query.filter_by(email=user.email).first()
            mentee.mentorpref = None
        db.session.commit()
        flash('Removed from shortlist.')
    else:
        flash('Feature not available.')
    return redirect(url_for('mentee_list'))
Exemple #11
0
def save_pref(Id):
    if current_user.is_mentor():
        mentor = Mentor.query.filter_by(email=current_user.email).first()
        if not mentor.mentee1 and mentor.mentee1 != Id:
            mentor.mentee1 = Id
            flash('Added to preferred mentees')
        elif not mentor.mentee2 and mentor.mentee2 != Id:
            mentor.mentee2 = Id
            flash('Added to preferred mentees')
        elif not mentor.mentee3 and mentor.mentee3 != Id:
            mentor.mentee3 = Id
            flash('Added to preferred mentees')
        else:
           flash('You already have 3 preferred mentees') 
        db.session.commit()   
        return redirect(url_for('mentee_shortlist'))
    elif current_user.is_company():
        cohort = Cohort.query.filter_by(email=current_user.email).first()
        if not cohort.mentor1 and cohort.mentor1 != Id:
            cohort.mentor1 = Id
            flash('Added to preferred mentors')
        elif not cohort.mentor2 and cohort.mentor2 != Id:
            cohort.mentor2 = Id
            flash('Added to preferred mentors')
        elif not cohort.mentor3 and cohort.mentor3 != Id:
            cohort.mentor3 = Id
            flash('Added to preferred mentors')
        else:
           flash('You already have 3 preferred mentors')
        db.session.commit()
        return redirect(url_for('mentor_shortlist'))
    elif current_user.is_admin():
        flash('Feature not available.')
    else:
        mentee = Mentee.query.filter_by(email=current_user.email).first()
        if not mentee.mentor1 and mentee.mentor1 != Id:
            mentee.mentor1 = Id
            flash('Added to preferred mentors')
        elif not mentee.mentor2 and mentee.mentor2 != Id:
            mentee.mentor2 = Id
            flash('Added to preferred mentors')
        elif not mentee.mentor3 and mentee.mentor3 != Id:
            mentee.mentor3 = Id
            flash('Added to preferred mentors')
        else:
           flash('You already have 3 preferred mentors')
        db.session.commit()
        return redirect(url_for('mentor_shortlist'))
Exemple #12
0
def acc_menteepref(menteeId):
    user = User.query.filter_by(email_hash=menteeId).first()
    if current_user.is_mentor():
        mentor = User.query.filter_by(email=current_user.email).first()
        if user.is_company():
            cohort = Company.query.filter_by(email=user.email).first()
            print('2', mentor)
            cohort.mentorpref = mentor
        else:
            mentee = Mentee.query.filter_by(email=user.email).first()
            mentee.mentorpref = mentor
        db.session.commit()
        flash('Shortlist has been updated.')
    else:
        flash('Feature not available.')
    return redirect(url_for('mentee_list'))
Exemple #13
0
def del_mentorpref(mentorId):
    user = User.query.filter_by(email_hash=mentorId).first()
    mentor = Mentor.query.filter_by(email=user.email).first()
    if current_user.is_company():
        cohort = Company.query.filter_by(email=current_user.email).first()
        mentor.cohort = None
        db.session.commit()
        flash('Removed from shortlist.')
    elif current_user.is_admin():
        flash('Feature not available.')
    elif current_user.is_mentor():
        flash('Removed from shortlist.')
    else:
        mentee = Mentee.query.filter_by(email=current_user.email).first()
        mentor.mentee = None
        db.session.commit()
        flash('Shortlist has been updated.')
    return redirect(url_for('mentor_list'))
Exemple #14
0
def del_pref(Id):
    if current_user.is_mentor():
        mentor = Mentor.query.filter_by(email=current_user.email).first()
        if mentor.mentee1 == Id:
            mentor.mentee1 = None
            flash('Removed from preferred mentees')
        elif mentor.mentee2 == Id:
            mentor.mentee2 = None
            flash('Removed from preferred mentees')
        elif mentor.mentee3 == Id:
            mentor.mentee3 = None
            flash('Removed from preferred mentees') 
        db.session.commit()   
        return redirect(url_for('mentee_shortlist'))
    elif current_user.is_company():
        cohort = Cohort.query.filter_by(email=current_user.email).first()
        if cohort.mentor1 == Id:
            cohort.mentor1 = None
            flash('Removed from preferred mentors')
        elif cohort.mentor2 == Id:
            cohort.mentor2 = None
            flash('Removed from preferred mentors')
        elif cohort.mentor3 == Id:
            cohort.mentor3 = None
            flash('Removed from preferred mentors')
        db.session.commit()
        return redirect(url_for('mentor_shortlist'))
    elif current_user.is_admin():
        flash('Feature not available.')
    else:
        mentee = Mentee.query.filter_by(email=current_user.email).first()
        if mentee.mentor1 == Id:
            mentee.mentor1 = None
            flash('Removed from preferred mentors')
        elif mentee.mentor2 == Id:
            mentee.mentor2 = None
            flash('Removed from preferred mentors')
        elif mentee.mentor3 == Id:
            mentee.mentor3 = None
            flash('Removed from preferred mentors')
        db.session.commit()
        return redirect(url_for('mentor_shortlist'))
Exemple #15
0
def upload():
    s3 = boto3.resource('s3')
    s3_filename = str(current_user.email_hash) + "-profile-pic.png"
    if current_user.is_mentor():
        s3.Bucket('enlight-hub-profile-pictures').put_object(Key='mentors/' + s3_filename, Body=request.files['myfile'])
        form = EditMentorProfileForm(current_user.email)
        info = Mentor.query.filter_by(email=current_user.email).first()
        form.email.data = current_user.email
        form.first_name.data = info.first_name
        form.last_name.data = info.last_name
        form.about_me.data = info.about_me
        form.avail.data = info.avail
        form.skill.data = info.skill
        form.industry.data = info.industry
        form.company.data = info.company
        form.position.data = info.position
        form.linked.data = info.linked
        form.twitter.data = info.twitter
    elif current_user.is_company():
        s3.Bucket('enlight-hub-profile-pictures').put_object(Key='mentees/' + s3_filename, Body=request.files['myfile'])
        form = EditCohortProfileForm(current_user.email)
        info = Cohort.query.filter_by(email=current_user.email).first()
        form.email.data = current_user.email
        form.company_name.data = info.company
        form.founder_names.data = info.founder
        form.industry.data = info.industry
        form.team_skills.data = info.skills
        form.help_needed.data = info.help_req
    else:
        s3.Bucket('enlight-hub-profile-pictures').put_object(Key='mentees/' + s3_filename, Body=request.files['myfile'])
        form = EditMenteeProfileForm(current_user.email)
        info = Mentee.query.filter_by(email=current_user.email).first()
        form.email.data = current_user.email
        form.company_name.data = info.company
        form.founder_names.data = info.founder
        form.industry.data = info.industry
        form.team_skills.data = info.skills
        form.help_needed.data = info.help_req
    flash('Profile picture successfully uploaded. Please allow some time for profile to update.')
    return redirect(url_for('edit_profile'))
Exemple #16
0
def mentor_list():
    mentorList = Mentor.query.all()
    cohort = None
    mentee = None
    for mentor in mentorList:
        user = User.query.filter_by(email=mentor.email).first()
        # clean the data a bit before passing to mentees
        if current_user.access == 0:
            mentor.email = None
        mentor.email_hash = user.email_hash
        mentor.mentees = []
        for m in mentor.users:
            mentee = Mentee.query.filter_by(email=m.email).first()
            mentor.mentees.append(mentee)
    if current_user.is_company():
        cohort = Company.query.filter_by(email=current_user.email).first()
    elif current_user.is_admin():
        print('no data to grab')
    elif current_user.is_mentor():
        print('no data to grab')
    else:
        mentee = Mentee.query.filter_by(email=current_user.email).first()        
    return render_template('mentorlist.html', title='Mentor List', mentors=mentorList, menteeInfo=mentee, cohortInfo=cohort)
Exemple #17
0
def edit_profile():
    profile_pic_filepath = 'https://s3.ca-central-1.amazonaws.com/enlight-hub-profile-pictures/'
    if current_user.is_admin():
        return render_template('404.html')
    elif current_user.is_mentor():
        form = EditMentorProfileForm(current_user.email)
        info = Mentor.query.filter_by(email=current_user.email).first()
        profile_pic_filepath += 'mentors/' + str(current_user.email_hash) + '-profile-pic.png'

        if form.validate_on_submit():
            current_user.email = form.email.data
            current_user.set_id()
            info.first_name = form.first_name.data
            info.last_name = form.last_name.data
            info.email = form.email.data
            info.about_me = form.about.data
            info.headline = form.headline.data
            info.avail = form.avail.data
            info.skill = form.skill.data
            info.mentor_company = form.company.data
            info.position = form.position.data
            info.industry = dict(form.industry.choices).get(form.industry.data)
            info.university = dict(form.university.choices).get(form.university.data)
            info.major = dict(form.major.choices).get(form.major.data)
            info.grad_year = form.grad_year.data
            info.linkedin = form.linkedin.data
            info.twitter = form.twitter.data
            db.session.commit()
            flash('Your changes have been saved.')
            return redirect(url_for('user', userId=current_user.email_hash))
        elif request.method == 'GET':
            form.first_name.data = info.first_name
            form.last_name.data = info.last_name
            form.email.data = current_user.email
            form.headline.data = info.headline
            form.about.data = info.about_me
            form.avail.data = info.avail
            form.skill.data = info.skills
            form.company.data = info.mentor_company
            form.position.data = info.position
            form.industry.data = info.industry
            form.university.data = info.university
            form.major.data = info.major
            form.grad_year.data = info.grad_year
            form.linkedin.data = info.linkedin
            form.twitter.data = info.twitter
        return render_template('edit_profile.html', title='Edit Profile', form=form)
    elif current_user.is_company():
        form = EditCohortProfileForm(current_user.email)
        info = Company.query.filter_by(email=current_user.email).first()

        if form.validate_on_submit():
            current_user.email = form.email.data
            current_user.set_id()
            info.email = form.email.data
            info.company = form.company_name.data
            info.members = form.member_names.data
            info.industry = dict(form.industry.choices).get(form.industry.data)
            info.help_req = form.help_needed.data
            db.session.commit()
            flash('Your changes have been saved.')
            return redirect(url_for('user', userId=current_user.email_hash))
        elif request.method == 'GET':
            form.email.data = current_user.email
            form.company_name.data = info.company
            form.member_names.data = info.members
            form.industry.data = info.industry
            form.university.data = info.university
            form.major.data = info.major
            form.grad_year.data = info.grad_year
            form.help_needed.data = info.help_req
        return render_template('edit_profile.html', title='Edit Profile', form=form)
    else:
        form = EditMenteeProfileForm(current_user.email)
        info = Mentee.query.filter_by(email=current_user.email).first()
        profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'

        if form.validate_on_submit():
            # current_user.email = form.email.data
            current_user.set_id()
            info.first_name = form.first_name.data
            info.last_name = form.last_name.data
            info.headline = form.headline.data
            info.about = form.about.data
            info.company = form.company.data
            info.university = dict(form.university.choices).get(form.university.data)
            info.major = dict(form.major.choices).get(form.major.data)
            info.year = dict(form.year.choices).get(form.year.data)
            info.industry = dict(form.industry.choices).get(form.industry.data)
            info.email = form.email.data
            info.skills = form.skill.data
            info.linkedin = form.linkedin.data
            info.twitter = form.twitter.data
            db.session.commit()
            flash('Your changes have been saved.')
            return redirect(url_for('user', userId=current_user.email_hash))
        elif request.method == 'GET':
            form.first_name.data = info.first_name
            form.last_name.data = info.last_name
            form.headline.data = info.headline
            form.about.data = info.about
            form.university.data = info.university
            form.major.data = info.major
            form.year.data = info.year
            form.email.data = current_user.email
            form.company.data = info.company
            form.industry.data = info.industry
            form.skill.data = info.skills
            form.linkedin.data = info.linkedin
            form.twitter.data = info.twitter
        return render_template('edit_profile.html', title='Edit Profile', form=form)
Exemple #18
0
def user(userId):
    user = User.query.filter_by(email_hash=userId).first()
    profile_pic_filepath = 'https://s3.ca-central-1.amazonaws.com/enlight-hub-profile-pictures/'
    try:
        # check if user is defined
        user.id
    except AttributeError:
        return render_template('404.html')
    mentees = []
    skill_array = []
    prefs = []
    if user == current_user:
        if current_user.is_admin():
            return render_template('404.html')
        elif current_user.is_mentor():
            info = Mentor.query.filter_by(email=user.email).first()
            if info.skills is not None:
                skill_array = info.skills.split(", ")
            for m in info.users:
                if m.is_company():
                    mentee = Cohort.query.filter_by(email=m.email).first()
                else:
                    mentee = Mentee.query.filter_by(email=m.email).first()
                user_m = User.query.filter_by(email=mentee.email).first()
                mentee.email_hash = user_m.email_hash
                mentees.append(mentee)
        else:
            info = Mentee.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skills is not None:
                skill_array = info.skills.split(", ")
            
            # find preferred mentors
            tempList = []
            if info.mentor1 is not None:
                user_p1 = User.query.filter_by(email_hash=info.mentor1).first()
                tempList.append(user_p1)
            if info.mentor2 is not None:
                user_p2 = User.query.filter_by(email_hash=info.mentor2).first()
                tempList.append(user_p2)
            if info.mentor3 is not None:
                user_p3 = User.query.filter_by(email_hash=info.mentor3).first()
                tempList.append(user_p3)

            for tempu in tempList:
                mentor = Mentor.query.filter_by(email=tempu.email).first()
                user_m = User.query.filter_by(email=mentor.email).first()
                mentor.email_hash = user_m.email_hash
                prefs.append(mentor)

    elif current_user.is_admin():
        if user.is_admin():
            # dont load profile for
            return render_template('404.html')
        elif user.is_mentor():
            info = Mentor.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentors/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skill is not None:
                skill_array = info.skill.split(", ")
        elif current_user.is_company():
            info = Cohort.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skills is not None:
                skill_array = info.skills.split(", ")
        else:
            info = Mentee.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skills is not None:
                skill_array = info.skills.split(", ")
            
    elif current_user.is_mentor():
        if user.is_admin():
            return render_template('404.html')
        elif user.is_mentor():
            return render_template('404.html')
        elif user.is_company():
            info = Cohort.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skills is not None:
                skill_array = info.skills.split(", ")
        else:
            # current user = mentor, can only view mentees
            info = Mentee.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentees/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skills is not None:
                skill_array = info.skills.split(", ")
    else:
        if user.is_admin():
            return render_template('404.html')
        elif user.is_mentor():
            # current user = mentee, can only view mentors
            info = Mentor.query.filter_by(email=user.email).first()
            profile_pic_filepath += 'mentors/' + str(current_user.email_hash) + '-profile-pic.png'
            if info.skill is not None:
                skill_array = info.skill.split(", ")
            # clean the data a bit before passing to mentees
            info.email = None
            user.email = None
        else:
            return render_template('404.html')
    return render_template('user.html', title='Profile', user=user, info=info, mentor=user.mentor, mentees=mentees, skill_array=skill_array)