Exemplo n.º 1
0
def create_teacher():
    print('=================创建老师======================')
    name = input('请输入老师名字:')
    lever = input('请输入老师级别:')
    obj = Teacher(name, lever)
    obj.save()
    print('创建老师成功')
Exemplo n.º 2
0
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}
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
def login():
    ret = Teacher.login()
    if ret:
        if ret['status']:
            print(ret['data'])
            main(ret['teacher'])
        else:
            print(ret['error'])
Exemplo n.º 5
0
def create_teacher():
    try:
        name=input('请输入老师姓名:').strip()
        level=input('请输入老师级别:').strip()
        teacher_name_list=[obj.name for obj in Teacher.get_all_obj_list()]
        if name in teacher_name_list:
            raise Exception('\033[43;1m老师[%s] 已经存在,不可重复创建\033[0m' %(name))
        obj=Teacher(name,level)
        obj.save()
        status=True
        error=''
        data='\033[33;1m老师[%s] 级别[%s] 时间[%s] 创建成功\033[0m' %(obj.name,obj.level,obj.create_time)
    except Exception as e:
        status=False
        error=str(e)
        data=''
    return {'status':status,'error':error,'data':data}
Exemplo n.º 6
0
def create_course_to_teacher():
    try:
        print('关联教师与课程'.center(60, '='))

        course_list = Course.get_all_obj_list()
        for k, obj in enumerate(course_list):
            print(
                k, '课程[%s] ([%s] [%s]校区)' %
                (obj.name, obj.school_nid.get_obj_by_uuid().name,
                 obj.school_nid.get_obj_by_uuid().addr))
        cid = int(input("请选择课程:"))
        course_obj = course_list[cid]

        teacher_list = Teacher.get_all_obj_list()
        teacher_list_selection = []
        k = 0
        for obj in teacher_list:
            if obj.school_nid.uuid == course_obj.school_nid.uuid:
                print(
                    k, obj.name,
                    '[%s] [%s]校区' % (obj.school_nid.get_obj_by_uuid().name,
                                     obj.school_nid.get_obj_by_uuid().addr))
                teacher_list_selection.append(obj)
                k += 1
        if k == 0:
            raise Exception('\033[31;1m该学校还未有合适的教师\033[0m')
        else:
            tid = int(input("请选择教师:"))
        teacher_obj = teacher_list_selection[tid]

        course_to_teacher_list = [
            (obj.course_nid.uuid, obj.teacher_nid.uuid)
            for obj in Course_to_teacher.get_all_obj_list()
        ]
        if (course_obj.nid.uuid,
                teacher_obj.nid.uuid) in course_to_teacher_list:
            raise Exception(
                '\033[31;1m教师[%s] 已与课程[%s]([%s] [%s]校区)关联,不可重复创建\033[0m' %
                (teacher_obj.name, course_obj.name,
                 course_obj.school_nid.get_obj_by_uuid().name,
                 course_obj.school_nid.get_obj_by_uuid().addr))
        obj = Course_to_teacher(course_obj.nid, teacher_obj.nid)
        obj.save()
        status = True
        error = ''
        data='\033[33;1m教师[%s] 与课程[%s]([%s] [%s]校区)关联 创建成功\033[0m' \
             % (teacher_obj.name, course_obj.name, course_obj.school_nid.get_obj_by_uuid().name,
                course_obj.school_nid.get_obj_by_uuid().addr)

    except Exception as e:
        status = False
        error = str(e)
        data = ''
    return {'status': status, 'error': error, 'data': data}
Exemplo n.º 7
0
def create_course_to_teacher():
    print('=================创建课程与老师对应关系======================')
    course_list = Course.get_all_list()
    for k, obj in enumerate(course_list, 1):
        print(k, obj)
    course_inp = input('请选择课程:')
    course_obj = course_list[int(course_inp) - 1]

    teacher_list = Teacher.get_teacher_list()
    for k, obj in enumerate(teacher_list, 1):
        print(k, obj)
    teacher_inp = input('请选择老师:')
    teacher_obj = teacher_list[int(teacher_inp) - 1]
    obj = CourseToTeacher(course_obj.nid, teacher_obj.nid)
    obj.save()
    print('课程名称:%s,已选老师为:%s' %
          (course_obj.courseName, teacher_obj.teacherName))
Exemplo n.º 8
0
def show_teacher():
    for obj in Teacher.get_all_obj_list():
        print('\033[33;1m老师[%s] 级别[%s] 创建时间[%s]\033[0m'.center(60, '-') %
              (obj.name, obj.level, obj.create_time))
Exemplo n.º 9
0
def show_teacher():
    print("=========教师列表========")
    teacher_list = Teacher.get_all_teacher_list()
    for item in teacher_list:
        print(item)
Exemplo n.º 10
0
def show_teacher():
    for obj in Teacher.get_all_obj_list():
        print('\033[32;1m教师姓名[%s] 级别[%s] 学校[%s] [%s]校区 创建日期[%s]\033[0m' %
              (obj.name, obj.level, obj.school_nid.get_obj_by_uuid().name,
               obj.school_nid.get_obj_by_uuid().addr, obj.create_time))
Exemplo n.º 11
0
from src.data import *  # teachers, goals
from src.models import Teacher
from src.config import db
import json

# with open("db.json", "w") as f_obj:
#     content = dict()
#
#     content.update({"goals": goals})
#     content.update({"days": days})
#     content.update({"teachers": teachers[:]})
#
#     f_obj.write(json.dumps(content))

with open("db.json", "r") as f_obj:
    content = json.loads(f_obj.read())["teachers"]
    for teacher in content:
        formed_teacher = Teacher(name=teacher["name"],
                                 description=teacher["about"],
                                 picture=teacher["picture"],
                                 rating=teacher["rating"],
                                 price=teacher["price"],
                                 goals=",".join(teacher["goals"]),
                                 free=json.dumps(teacher["free"]))
        db.session.add(formed_teacher)
        db.session.commit()