def create_school(): print('===============创建学校====================') name = input('请输入学校名称:') address = input('请输入学校地址:') obj = School(name, address) obj.save() print('创建学校成功')
def create_school(): """ 创建学校 :return: """ name = input('请输入学校名称:') obj = School(name) obj.save()
def create_course(): try: print('创建课程'.center(60, '=')) school_list = School.get_all_obj_list() for k, obj in enumerate(school_list): print(k, obj, obj.addr) sid = int(input('请选择学校: ')) school_obj = school_list[sid] name = input('请输入课程名: ').strip() price = input('请输入课程价格: ').strip() period = input('请输入课程周期: ').strip() course_name_list = [(obj.name, obj.school_nid.uuid) for obj in Course.get_all_obj_list()] if (name, school_obj.nid.uuid) in course_name_list: raise Exception('\033[43;1m课程[%s] 已经存在,不可重复创建\033[0m' % (name)) obj = Course(name, price, period, school_obj.nid) obj.save() status = True error = '' data = '\033[33;1m课程[%s] 价格[%s] 周期[%s]创建成功\033[0m' % ( obj.name, obj.price, obj.period) except Exception as e: status = False error = str(e) data = '' return {'status': status, 'error': error, 'data': data}
def create_teacher(): try: username = input("请输入教师登录账户:") teacher_list = [obj.username for obj in Teacher.get_all_obj_list()] if username in teacher_list: raise Exception('\033[31;1m教师登录账户[%s] 已经存在,不可重复创建\033[0m' % username) password = input("请输入教师登录密码:") name = input("请输入教师姓名:").strip() level = input("请输入教师级别:").strip() school_list = School.get_all_obj_list() for k, obj in enumerate(school_list): print(k, obj, obj.addr) sid = int(input('请选择学校: ')) school_obj = school_list[sid] obj = Teacher(username, password, name, level, school_obj.nid) obj.save() status = True error = '' data = '\033[33;1m教师 %s [%s]创建成功\033[0m' % (obj.name, obj.username) except Exception as e: status = False error = str(e) data = '' return {'status': status, 'error': error, 'data': data}
def create_school(): try: name=input('请输入学校名字:').strip() addr=input('请输入学校地址:').strip() school_name_list=[(obj.name,obj.addr) for obj in School.get_all_obj_list()] if (name,addr) in school_name_list: raise Exception('\033[43;1m[%s] [%s]校区 已经存在,不可重复创建\033[0m' %(name,addr)) obj=School(name,addr) obj.save() status=True error='' data='\033[33;1m[%s] [%s]校区 创建成功\033[0m' %(obj.name,obj.addr) except Exception as e: status=False error=str(e) data='' return {'status':status,'error':error,'data':data}
def get_one_school(): get_school_list() try: choose = int(input('choose your school index:')) school_obj = School.get_all()[choose] except Exception as e: print(e) else: print('学校信息:id:%s name:%s' % (school_obj.id, school_obj.name))
def create_class(): get_school_list() try: choose = int(input('choose your school index:')) school_id = School.get_all()[choose].id except Exception as e: print(e) else: name = input('input class name:') Classes(name, school_id)
def get_one_class(): get_class_list() try: choose = int(input('choose your class index:')) class_obj = Classes.get_all()[choose] except Exception as e: print(e) else: print('课程信息:id:%s name:%s school_id:%s school_name:%s' % (class_obj.id, class_obj.name, class_obj.school_id, School.get_obj_by_id(class_obj.school_id)))
def create_teacher(): print("=========创建老师========") print("学校列表") school_list = School.get_all_school_list() for k, obj in enumerate(school_list, 1): print(k, obj) sid = int(input("请选择学校选项:")) school_obj = school_list[sid - 1] name = input("请输入教师姓名") teacher_obj = Teacher(name, school_obj.nid) teacher_obj.save()
def register(): try: username = input("请输入学生登录账户:") student_list = [obj.username for obj in Student.get_all_obj_list()] if username in student_list: raise Exception('\033[31;1m学生登录账户[%s] 已经存在,不可重复创建\033[0m' % username) password = input("请输入学生登录密码:") name = input("请输入学生姓名:").strip() age = input("请输入学生年龄:").strip() mobile = input("请输入学生手机号码:").strip() school_list = School.get_all_obj_list() for k, obj in enumerate(school_list): print(k, obj, obj.addr) sid = int(input('请选择学校: ')) school_obj = school_list[sid] class_list = Classes.get_all_obj_list() class_list_s = [] k = 0 for obj in class_list: if obj.school_nid.uuid == school_obj.nid.uuid: print(k, obj) class_list_s.append(obj) k += 1 if k == 0: raise Exception('\033[31;1m该学校尚未有开课班级\033[0m') else: cid = int(input("请选择班级:")) class_obj = class_list_s[cid] obj = Student(username, password, name, age, mobile, school_obj.nid, class_obj.nid) obj.save() status = True error = '' data = '\033[33;1m学生姓名[%s] 年龄[%s] 手机[%s] 学校[%s] 班级[%s]创建成功\033[0m' % ( obj.name, obj.age, obj.mobile, school_obj, class_obj) student_obj = obj except Exception as e: status = False error = str(e) data = '' student_obj = None return { 'status': status, 'error': error, 'data': data, 'student': student_obj }
def create_course(): print('=================创建课程======================') school_list = School.get_all_list() for k, obj in enumerate(school_list, 1): print(k, obj) sid = input('请选择学校:') sid = int(sid) school_obj = school_list[sid - 1] name = input('请输入课程名称:') price = input('请输入课程价格:') period = input('请输入课程周期:') obj = Course(name, price, period, school_obj.nid) obj.save() print('课程【%s】创建成功' % name)
def run_around_tests(): try: db.create_all() school = School('University of School', ['uos.edu']) db.session.add(school) db.session.commit() yield db.session.commit() except: db.session.rollback() finally: db.engine.execute('drop schema if exists public cascade') db.engine.execute('create schema public')
def create_classes(): try: print('创建班级'.center(60, '=')) name = input('请输入班级名称: ').strip() school_list = School.get_all_obj_list() for k, obj in enumerate(school_list): print(k, obj, obj.addr) sid = int(input('请选择学校: ')) school_obj = school_list[sid] class_name_list = [(obj.name, obj.school_nid.uuid) for obj in Classes.get_all_obj_list()] if (name, school_obj.nid.uuid) in class_name_list: raise Exception('\033[31;1m班级[%s] (校区[%s])已经存在,不可重复创建\033[0m' % (name, school_obj)) course_to_teacher_all_list = Course_to_teacher.get_all_obj_list() course_to_teacher_selection = [] k = 0 for obj in course_to_teacher_all_list: if obj.school_nid.uuid == school_obj.nid.uuid: print( k, obj.teacher_nid.get_obj_by_uuid(), obj.course_nid.get_obj_by_uuid(), '[%s] [%s]校区' % (obj.school_nid.get_obj_by_uuid().name, obj.school_nid.get_obj_by_uuid().addr)) course_to_teacher_selection.append(obj) k += 1 if k == 0: raise Exception('\033[31;1m该学校尚未有适合的课程开设\033[0m') else: ctid = int(input("请选择教师和课程:")) course_to_teacher_list = course_to_teacher_selection[ctid] obj = Classes(name, school_obj.nid, course_to_teacher_list) obj.save() status = True error = '' data='\033[33;1m班级[%s] 校区[%s] 任课老师[%s] 课程[%s]创建成功\033[0m' \ %(obj.name,obj.school_nid.get_obj_by_uuid(),obj.course_to_teacher_list.teacher_nid.get_obj_by_uuid(), obj.course_to_teacher_list.course_nid.get_obj_by_uuid()) except Exception as e: status = False error = str(e) data = '' return {'status': status, 'error': error, 'data': data}
def create_classes(): print('=================创建班级======================') school_list = School.get_all_list() for k, obj in enumerate(school_list, 1): print(k, obj) sid = input('请选择学校:') sid = int(sid) school_obj = school_list[sid - 1] course_teacher_list = CourseToTeacher.course_teacher_list() for k, obj in enumerate(course_teacher_list, 1): print(k, obj) c_t_id = input('请选择教师列表:') c_t_id = int(c_t_id) course_to_teacher_obj = course_teacher_list[c_t_id - 1] name = input('请输入班级名称:') tuition = input('请输入学费:') obj = Classes(name, tuition, school_obj.nid, course_to_teacher_obj.nid) obj.save() print('课程【%s】创建成功' % name)
def get_school_list(): show(School.get_all())
def create_school(): name = input('input school name:') School(name)
def get_school_list(): School.get_all()
def show_school(): for obj in School.get_all_obj_list(): print('\033[45;1m学校[%s] 地址[%s] 创建日期[%s]\033[0m'.center(60, '-') % (obj.name, obj.addr, obj.create_time))
def show_school(): print("=========学校========") school_list = School.get_all_school_list() for item in school_list: print(item.schoolName)
def show_school(): print('======学校======') school_list = School.get_all_list() for obj in school_list: print(obj)
def show_school(): for obj in School.get_all_obj_list(): print('\033[32;1m学校[%s] 地址[%s] 创建日期[%s]\033[0m' % (obj.name, obj.addr, obj.create_time))
def create_school(): school_name = input("请输入学校名称:") obj = School(school_name) obj.save()
def show_school(): print('==============查看学校===================') school_list = School.get_all_list() for item in school_list: print(item)