def get_by_project_teacher(teacher_id): result = list() id_std = request.args.get("id_std") try: ma_gv = TeacherModel.get_magvhd_by_id(teacher_id=teacher_id) projects = ProjectModel.get_project_by_teacher(ma_gv) cap = StudentModel.get_level_student_id(id_std) except Exception as e: print(e) return jsonify({ "message": "Có lỗi phát sinh trong server!", "code": 500 }), 500 for project in projects: check = StudentModel.get_data_by_project(project.id) if id_std and str(project.Cap) != str(cap): continue result.append({ "id": project.id, "Ten": project.Ten, "Mota": project.MoTa, "TrangThai": project.TrangThai if not check else "Đã chọn", "GhiChu": project.GhiChu, "Cap": project.Cap }) return jsonify({ "message": "request thành công!", "data": result, "code": 200 }), 200
def get_all_project(): result = list() try: projects = ProjectModel.get_all_project() except Exception as e: print(e) return jsonify({ "message": "Có lỗi phát sinh trong server!", "code": 500 }), 500 for project in projects: check = StudentModel.get_data_by_project(project.id) result.append({ "id": project.id, "Ten": project.Ten, "Mota": project.MoTa, "TrangThai": project.TrangThai if not check else "Đã chọn", "GhiChu": project.GhiChu, "Cap": project.Cap }) return jsonify({ "message": "request thành công!", "data": result, "code": 200 }), 200