示例#1
0
def edit_factory():
    if request.method == 'POST':
        action = request.form['submit']
        if action == "Изменить":
            manufacturers = DbUtils.select_manufacturers_name()
            formated_man = []
            for i in manufacturers:
                formated_man.append(i[0])
            return render_template('edit_factory.html',
                                   manufacturers=formated_man,
                                   id=request.form['id'],
                                   location=request.form['location'],
                                   fact_name=request.form['fact_name'],
                                   manuf_name=request.form['manuf_name'],
                                   login=app.config['USER'].login,
                                   type=app.config['USER'].type)
        elif action == "Удалить":
            DbUtils.delete_factory(request.form['id'])
            factories = DbUtils.select_factories()
            return render_template('manage_factories.html',
                                   factories=factories,
                                   len=len(factories),
                                   login=app.config['USER'].login,
                                   type=app.config['USER'].type)
    return render_template('edit_factory.html',
                           login=app.config['USER'].login,
                           type=app.config['USER'].type)
示例#2
0
def add_factory():
    if request.method == 'POST':
        DbUtils.insert_factory(request.form['location'],
                               request.form['fact_name'],
                               request.form['manuf_name'])
        factories = DbUtils.select_factories()
        return render_template('manage_factories.html',
                               factories=factories,
                               len=len(factories),
                               login=app.config['USER'].login,
                               type=app.config['USER'].type)
    else:
        manufacturers = DbUtils.select_manufacturers_name()
        formated_man = []
        for i in manufacturers:
            formated_man.append(i[0])
        return render_template('add_factory.html',
                               manufacturers=formated_man,
                               login=app.config['USER'].login,
                               type=app.config['USER'].type)