def update(): relationship_id = request.form['relationship_id'] professorid = db_helper.findProfessorIdByMentoringId( cursor, relationship_id) if professorid is not 'null': professorname = db_helper.getProfessorObjectById(cursor, professorid).lastname else: professorname = "None" studentCountForThisProfessor = db_helper.getProfessorAndStudentNumberInDicionary( cursor)[professorname] if studentCountForThisProfessor < db_helper.getAllNumbers(cursor)[3]: color = "green" elif studentCountForThisProfessor >= db_helper.getAllNumbers( cursor )[3] and studentCountForThisProfessor < db_helper.getAllNumbers(cursor)[4]: color = "yellow" else: color = "red" return jsonify({ 'RESULT': 'SUCCESS', 'professor_name': professorname.capitalize(), 'student_count': db_helper.getProfessorAndStudentNumberInDicionary(cursor) [professorname], 'number_color': color })
def mentoring_joined(): most_recent_changes_json_string = json.dumps( db_helper.getMost_recent_mentoring_updatesTableAsDataframeForFlask( connection).sort_index(ascending=False).values.tolist()) professorAndNumberDict = db_helper.getProfessorAndStudentNumberInDicionary( cursor) newString = "" for professorName, count in sorted(professorAndNumberDict.items()): newString += (json.dumps({ "professorName": professorName.strip().title(), "count": count })) + "," newString = '[' + newString[:-1] + ']' try: studentName = request.args.get('username').title() except: studentName = "" current_user_name = getCurrentUserName() return render_template( "mentoring_joined.html", mentoring_joined_tables=[ db_helper.readDatabaseIntoDataframe(connection, True).to_html(classes='data', index=False) ], studentName=studentName, professorJson=newString, most_recent_changes_json_string=most_recent_changes_json_string, current_user_name=current_user_name, new_approve_accounts=new_approve_accounts)
def mainMenu(): professorAndNumberDict = db_helper.getProfessorAndStudentNumberInDicionary( cursor) professorJsonString = "" for professorName, count in sorted(professorAndNumberDict.items()): status = "" if count < db_helper.getAllNumbers(cursor)[3]: status = "EMPTY" elif count >= db_helper.getAllNumbers( cursor)[3] and count < db_helper.getAllNumbers(cursor)[4]: status = "ALMOST FULL" else: status = "FULL" professorJsonString += (json.dumps( { "professorName": professorName.strip().title(), "count": count, 'status': status })) + "," professorJsonString = '[' + professorJsonString[:-1] + ']' student_table = db_helper.readTableIntoDataFrame( connection, "student").sort_values(by=['lastname']) student_table['duplicated_name'] = student_table.duplicated( subset=['lastname', 'firstname'], keep=False) studentString = "" for i in range(student_table.shape[0]): duplicated = 0 if student_table.iloc[i].duplicated_name == True: duplicated = 1 studentString += (json.dumps({ "studentName": student_table.iloc[i].lastname.title() + ", " + student_table.iloc[i].firstname.title(), "relationship_id": db_helper.findStudentIdByRelationshipId(cursor, student_table.iloc[i].ID), 'email': student_table.iloc[i].email, 'duplicated': str(duplicated) })) + "," studentString = '[' + studentString[:-1] + ']' current_user_name = getCurrentUserName() return render_template("main_menu.html", studentJson=studentString, professorJson=professorJsonString, numberForEachTable=db_helper.getAllNumbers(cursor), current_user_name=current_user_name, new_approve_accounts=new_approve_accounts)
def update_from_professor_datalist(): selected = request.form['name'] professorname = selected.strip().lower() studentCountForThisProfessor = db_helper.getProfessorAndStudentNumberInDicionary( cursor)[professorname] if studentCountForThisProfessor < db_helper.getAllNumbers(cursor)[3]: color = "green" elif studentCountForThisProfessor >= db_helper.getAllNumbers( cursor )[3] and studentCountForThisProfessor < db_helper.getAllNumbers(cursor)[4]: color = "yellow" else: color = "red" return jsonify({ 'RESULT': 'SUCCESS', 'student_count': db_helper.getProfessorAndStudentNumberInDicionary(cursor) [professorname], 'number_color': color })
def manage_mentors(): current_user_name = "" if (current_user.is_authenticated == True): current_user_name = current_user.username df = db_helper.readTableIntoDataFrame(connection, 'professor') df["Professor"] = df["lastname"].str.title().str.lstrip().str.rstrip() del df["lastname"] del df["firstname"] df = df.rename(columns={"email": "Professor Email"}) col = ["ID", "Professor", "Professor Email"] df = df[col] df["Student Numbers"] = list( db_helper.getProfessorAndStudentNumberInDicionary(cursor).values()) df.sort_values(by=["Professor"], inplace=True) return render_template("manage_mentors.html", current_user_name=current_user_name, mentor_2d_array=df.values, new_approve_accounts=new_approve_accounts)
def multiple_assign_page(): professorAndNumberDict = db_helper.getProfessorAndStudentNumberInDicionary( cursor) newString = "" for professorName, count in sorted(professorAndNumberDict.items()): newString += (json.dumps({ "professorName": professorName.strip().title(), "count": count })) + "," newString = '[' + newString[:-1] + ']' studentForProfessorsJson = db_helper.getStudentsForProfessor(connection) current_user_name = "" if (current_user.is_authenticated == True): current_user_name = current_user.username return render_template("multiple_assign_page.html", professorJson=newString, studentForProfessorsJson=studentForProfessorsJson, current_user_name=current_user_name, new_approve_accounts=new_approve_accounts)
def showall(): return render_template( "showall.html", mentoring_tables=[ db_helper.readDatabaseIntoDataframe(connection).to_html( classes='data', index=False) ], student_table=[ db_helper.readTableIntoDataFrame(connection, "student").to_html(classes='data', index=False) ], professor_table=[ db_helper.readTableIntoDataFrame(connection, "professor").to_html( classes='data', index=False) ], mentor_table=[ db_helper.readTableIntoDataFrame(connection, "mentoring").to_html( classes='data', index=False) ], offline_data_table=[ db_helper.readTableIntoDataFrame( connection, 'offline_data').to_html(classes='data', index=False) ], most_recent_mentoring_updates_table=[ db_helper.readTableIntoDataFrame( connection, 'most_recent_mentoring_updates').to_html(classes='data', index=False) ], numberForEachTable=db_helper.getAllNumbers(cursor), professorDictionary=db_helper.getProfessorAndStudentNumberInDicionary( cursor), overall_changes_table=[ db_helper.readTableIntoDataFrame( connection, 'overall_changes').to_html(classes='data', index=False) ], new_approve_accounts=new_approve_accounts)