コード例 #1
0
ファイル: main.py プロジェクト: kinokosu3/course-project
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)
コード例 #2
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)
コード例 #3
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)
コード例 #4
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)