def create_course_teacher(): course_list = Course.get_obj_list() teacher_list = Teacher.get_obj_list() for k, obj in enumerate(course_list): print(k, obj.name) choose_course = input('选择课程 >> ').strip() if choose_course.isdigit(): choose_course = int(choose_course) if choose_course <= len(course_list): for j, t in enumerate(teacher_list): print(j, t.name) choose_teacher = input('选择关联的讲师 >> ').strip() if choose_teacher.isdigit(): choose_teacher = int(choose_teacher) if choose_teacher <= len(teacher_list): course_id = course_list[int(choose_course)] teacher_id = teacher_list[int(choose_teacher)] course_teacher = Course_teacher(course_id.nid, teacher_id.nid) course_teacher.save() return else: print('\033[31;1m没有此选项\033[0m') else: print('\033[31;1m没有此选项\033[0m')
def create_course(): school_list = School.get_obj_list() # 所有学校列表 for k, obj in enumerate(school_list): print(k, obj.name, obj.addr) choose = input('选择学校 >> ').strip() if choose.isdigit(): choose = int(choose) if choose < len(School.get_obj_list()): choose_school = school_list[choose] # 选择的学校 name = input('课程名 >> ').strip() period = input('课程周期(month) >> ').strip() price = input('课程价格(RMB) >> ').strip() course_list = [obj.name for obj in Course.get_obj_list()] if name in course_list: print('\033[33;1m课程[%s]已存在\033[0m' % name) else: course = Course(name, price, period, choose_school.nid) course.save() print('\033[33;1m课程[%s]创建成功\033[0m' % name) else: print('请正确输入')
def show_course(): for obj in Course.get_obj_list(): print('课程名:[%s] 价格(元):[%s] 周期(月):[%s] 学校:[%s] 地址:[%s]' % (obj.name, obj.price, obj.period, obj.school_id.get_obj_uuid().name, obj.school_id.get_obj_uuid().addr))