示例#1
0
def visit(name=None):
    ap_list = apartment_list()
    if name == 'quit-list':
        ql = quit_list()
        return render_template('visit.html', ql=ql, name=name)
    elif name is not None:
        if request.method == 'POST':
            quit_time = request.form['quit_time']
            write_quit(ID=name, quit_time=quit_time)
            return redirect((url_for('outin')))
        return render_template('visit.html', name=name)
    if request.method == 'POST':
        apartment_name = request.form['apartment_name']
        id_num = request.form['id_num']
        name = request.form['name']
        origin = request.form['origin']
        visit_time = request.form['visit_time']
        string = id_num + name + origin + visit_time + visit_time
        ID = sha(string)
        if not exists(ID, table_name='visit_register', row_name='hash'):
            write_visit(ID=ID,
                        apartment_name=apartment_name,
                        id_num=id_num,
                        name=name,
                        origin=origin,
                        visit_time=visit_time)
    return render_template('visit.html', name=None, ap_list=ap_list)
示例#2
0
def system(name=None):
    if name == 'apartment':
        results = system_everything('apartment')
        if request.method == 'POST':
            apartment_name = request.form['apartment_name']
            apartment_dir = request.form['apartment_dir']
            floor = request.form['floor']
            system_apartment_write(apartment_name=apartment_name,
                                   apartment_dir=apartment_dir,
                                   floor=floor)
        return render_template('system.html', name=name, results=results)
    if name == 'room':
        ap_list = apartment_list()
        results = system_everything('room')
        if request.method == 'POST':
            # room_id, student_count, face, orientation, floor_num, apartment_name
            room_id = request.form['room_id']
            student_count = request.form['student_count']
            face = request.form['face']
            orientation = request.form['orientation']
            floor_num = request.form['floor_num']
            apartment_name = request.form['apartment_name']
            system_room_write(room_id=room_id,
                              student_count=student_count,
                              face=face,
                              orientation=orientation,
                              floor_num=floor_num,
                              apartment_name=apartment_name)

        return render_template('system.html',
                               results=results,
                               name=name,
                               ap_list=ap_list)
    if name == 'class':
        results = system_everything('class')
        de_list = department_list()
        if request.method == 'POST':
            class_num = request.form['class_num']
            class_name = request.form['class_name']
            profession = request.form['profession']
            grade = request.form['grade']
            department_name = request.form['department_name']
            system_class_write(class_num=class_num,
                               class_name=class_name,
                               profession=profession,
                               grade=grade,
                               department_name=department_name)
        return render_template('system.html',
                               de_list=de_list,
                               name=name,
                               results=results)
    if name == 'department':
        results = system_everything('department')
        if request.method == 'POST':
            department_name = request.form['department_name']
            department_leader = request.form['department_leader']
            system_department_write(department_name=department_name,
                                    department_leader=department_leader)
        return render_template('system.html', name=name, results=results)
    return render_template('system.html', name=name)
示例#3
0
def student(name=None):
    ap_list = apartment_list()
    department = None
    if name == 'write':
        de_list = department_list()
        if request.method == 'POST':
            student_name = request.form['student_name']
            student_num = request.form['student_num']
            gender = request.form['gender']
            stay_time = request.form['stay_time']
            room_id = request.form['room_id']
            class_num = request.form['class_num']
            department = request.form['department']
            apartment_name = request.form['apartment_name']
            if exists(student_num, 'student', 'student_num'):
                flash('该学生已经在系统中')
            elif not exists(room_id, 'room', 'room_id'):
                flash('宿舍号出现错误')
            elif not exists(class_num, 'class', 'class_num'):
                flash('班级出现错误')
            else:
                student_write(student_num=student_num,
                              name=student_name,
                              gender=gender,
                              stay_time=stay_time,
                              room_id=room_id,
                              class_num=class_num,
                              department_name=department,
                              apartment_name=apartment_name)
                flash('写入OK')
        return render_template('student.html',
                               name=name,
                               de_list=de_list,
                               ap_list=ap_list)
    if name == 'condition-search':
        results = None
        if request.method == 'POST':
            apartment_name = request.form['apartment_name']
            student_name = request.form['student_name']
            student_num = request.form['student_num']
            if not exists(
                    student_num, table_name='student', row_name='student_num'):
                flash('该学生不在系统内')
            results = student_search(apartment_name=apartment_name,
                                     student_num=student_num,
                                     student_name=student_name)
            if not results:
                flash('该公寓无该学生')
        return render_template('student.html',
                               name=name,
                               ap_list=ap_list,
                               results=results)
    if name == 'everything':
        results = student_everything()
        return render_template('student.html', results=results, name=name)
    return render_template('student.html', name=None)
示例#4
0
def cargo():
    ap_list = apartment_list()
    if request.method == 'POST':
        apartment_name = request.form['apartment_name']
        cargo_id = request.form['cargo_id']
        time = request.form['time']
        origin = request.form['origin']
        direction = request.form['direction']
        duty_man = request.form['duty_man']
        string = apartment_name + cargo_id + time + origin + direction + duty_man
        ID = sha(string)
        if not exists(ID, table_name='cargo_register', row_name='ID'):
            cargo_re(ID=ID,
                     apartment_name=apartment_name,
                     cargo_id=cargo_id,
                     time=time,
                     origin=origin,
                     direction=direction,
                     duty_man=duty_man)
        else:
            flash('已经存在该记录')
    return render_template('cargo.html', ap_list=ap_list)
示例#5
0
def apartment(name=None):
    ap_list = apartment_list()
    if name == 'write':
        if request.method == 'POST':
            property_name = request.form['name']
            apartment_name = request.form['apartment_name']
            value = request.form['value']
            string = apartment_name + value
            ID = sha(string)
            if not exists(ID, 'apartment_manage', 'id'):
                apartment_write(ID,
                                name=property_name,
                                apartment_name=apartment_name,
                                value=value)
                flash('写入OK')
                return redirect('/apartment/write')
            else:
                flash('该财产已经存在')
        return render_template('apartment.html', name=name, ap_list=ap_list)
    if name == 'everything':
        results = apartment_everything()
        return render_template('apartment.html', name=name, results=results)
    if name == 'condition-search':
        results = None
        if request.method == 'POST':
            property_name = request.form['name']
            apartment_name = request.form['apartment_name']
            value = request.form['value']
            results = apartment_search(apartment_name=apartment_name,
                                       name=property_name,
                                       value=value)
            if not results:
                flash('没有合适条目')
        return render_template('apartment.html',
                               name=name,
                               results=results,
                               ap_list=ap_list)
    return render_template('apartment.html', name=None)