예제 #1
0
def teacher_resister(name, password):
    # 要判断是否存在这个老师
    filenames = DB_handler.get_all_filename(Teacher.__name__.lower())
    school = input("请选择学校:").strip()
    #回去所有学校列表
    school_name = DB_handler.get_all_filename(School.__name__.lower())
    if school not in school_name:
        return "该学校不存在"
    # 第一次没有相对目录filenames为None
    if not filenames:
        #生成老师对象
        teacher = Teacher(name, password, school)
        DB_handler.save_obj_to_file(teacher)
        return
    if name in filenames:
        return "该老师已存在"
    # 处理数据并且完成存储
    teacher = Teacher(name, password, school)
    DB_handler.save_obj_to_file(teacher)
    return
예제 #2
0
def student_resister(name, password):
    # 要判断是否存在这个学生
    filenames = DB_handler.get_all_filename(Student.__name__.lower())
    if not filenames:
        student = Student(name, password)
        DB_handler.save_obj_to_file(student)
        return student
    if name in filenames:
        return
    # 处理数据并且完成存储
    student = Student(name, password)
    DB_handler.save_obj_to_file(student)
    return student
예제 #3
0
def admin_resister(name, password):
    # 要判断是否存在这个管理员,返回管理员列表
    filenames = DB_handler.get_all_filename(Admin.__name__.lower())
    if not filenames:
        #生成管理员对象
        admin = Admin(name, password)
        DB_handler.save_obj_to_file(admin)
        return admin
    if name in filenames:
        return
    # 处理数据并且完成存储
    admin = Admin(name, password)
    DB_handler.save_obj_to_file(admin)
예제 #4
0
def student_choice_read(obj_name):
    if obj_name == "School":
        obj_name = School
    elif obj_name == "Teacher":
        obj_name = Teacher
    else:
        obj_name = Course
    filenames = DB_handler.get_all_filename(obj_name.__name__.lower())
    if not filenames:
        return False
    # 生成对象
    obj_lis=[DB_handler.load_obj_from_file(obj_name.__name__.lower(), i)\
             for i in filenames]
    return obj_lis
예제 #5
0
def admin_create_school(name, address, telephone):
    #获得学校列表
    filenames = DB_handler.get_all_filename(School.__name__.lower())
    if not filenames:
        #生成学习对象
        school = School(name, address, telephone)
        #保存学校对象
        DB_handler.save_obj_to_file(school)
        return school
    if name in filenames:
        return
    school = School(name, address, telephone)
    DB_handler.save_obj_to_file(school)
    return school
예제 #6
0
def admin_create_classes(course_school, course_class):
    # 生成创建班级的路径,是不同学校可以创建相同班级
    file_path = os.path.join(settings.DB_DIR, Classes.__name__.lower(),
                             course_school)
    filenames = DB_handler.get_all_filename(file_path)
    if not filenames:
        #生成班级对象
        classes = Classes(course_class)
        DB_handler.save_obj_to_file(classes, file_path)
        return
    if course_class in filenames:
        return course_class
    classes = Classes(course_class)
    DB_handler.save_obj_to_file(classes, file_path)
    return
예제 #7
0
def admin_create_course(schol_name, course_name, course_time, course_money):
    #生成创建课程的路径,是不同学校可以创建相同课程
    filenames_path = os.path.join(settings.DB_DIR, Course.__name__.lower(),
                                  schol_name)
    #获得课程列表
    filenames = DB_handler.get_all_filename(filenames_path)
    if not filenames:
        #生成课程对象
        course = Course(course_name, course_time, course_money)
        DB_handler.save_obj_to_file(course, filenames_path)
        return
    if course_name in filenames:
        return course_name
    course = Course(course_name, course_time, course_money)
    DB_handler.save_obj_to_file(course, filenames_path)
    return
예제 #8
0
파일: common.py 프로젝트: okada8/python
def login(startname):
    global Logging, name
    while True:
        username = input("请输入登录用户名:").strip()
        filenames = DB_handler.get_all_filename(startname.lower())
        if username in filenames:
            pwd = input("请输入登录密码:").strip()
            obj1 = DB_handler.halib_file(pwd)
            obj = DB_handler.load_obj_from_file(startname, username)
            pwd2 = getattr(obj, "pwd")
            if obj1 == pwd2:
                Logging = True
                print("登录成功!!!")
                name = obj
                return name
            print("密码错误!!!")
            continue
        while True:
            if startname == "student" or startname == "admin":
                print("""
======================
    1.注册
    2.返回
======================           
                """)
                choice = input("请选择:")
                if choice == "1":
                    obj = register(startname)
                    if not obj:
                        return
                    elif choice == "2":
                        return
                    else:
                        print("输入错误!!!")
            else:
                print("请联系管理员帮你注册")
                return