def create_course(): if current_user is not None and current_user.is_privileged(UserType.staff): teachers = Teacher.query.order_by(Teacher.tid).all() print teachers return render_template( "create_course.html", username=current_user.username, types=GameType.getAll(), teachers=teachers ) else: abort(403)
def update_course(): if current_user is not None and current_user.is_privileged(UserType.staff): cid = request.args.get("cid") course = Course.query.filter(Course.cid == cid).first() print course if course is None: return render_template("error.html", message="查找不到与之匹配的课程") else: # status = CourseStatus.getName(course.status) # teacher = Teacher.query.filter(Teacher.tid==course.tid).first() # allteachers = Teacher.query.order_by(Teacher.tid).all() gtype = {"type": course.gtype, "name": GameType.getName(course.gtype)} return render_template( "update_course.html", username=current_user.username, course=course, gtype=gtype, types=GameType.getAll(), ) else: abort(403)
def update_teacher(): if current_user is not None and current_user.is_privileged(UserType.staff): tid = request.args.get("tid") teacher = Teacher.query.filter(Teacher.tid == tid).first() if teacher is None: return render_template("error.html", message="查找不到与之匹配的讲师") else: user = Users.query.filter(Users.username == teacher.username).first() if not user: return render_template("error.html", message="找不到教师的基本用户数据") else: return render_template( "update_teacher.html", username=current_user.username, teacher=teacher, types=GameType.getAll(), genderName=GenderType.getName(user.gender), gname=GameType.getName(teacher.gtype), ) else: abort(403)
def add_teacher(): if current_user is not None and current_user.is_privileged(UserType.staff): return render_template("add_teacher.html", username=current_user.username, index=2, types=GameType.getAll()) else: abort(403)