def warehouse_create(): location = request.form.get('location') store = Store.get_by_id(request.form['store_id']) warehouse = Warehouse(location=location, store=store) if warehouse.save(): flash("Warehouse created!", "success") return redirect(url_for('warehouse_new'))
def warehouse_create(): store = Store.get_by_id(request.form['store_id']) w = Warehouse(location=request.form['warehouse_location'], store=store) w.save() if w.save(): flash("Warehouse created") return redirect(url_for('warehouse_new'))
def parse(filename): with open(filename) as f: r = lambda: f.readline().strip() rows, cols, drones, deadline, max_payload = map(int, r().split()) n_products = int(r()) Products = map(int, r().split()) assert n_products == len(Products) n_warehouses = int(r()) warehouses = [] for w in range(n_warehouses): row, col = map(int, r().split()) products = map(int, r().split()) warehouses.append(Warehouse(w, row, col, products)) n_orders = int(r()) orders = [] for i in range(n_orders): row, col = map(int, r().split()) _ = int(r()) products = map(int, r().split()) orders.append(Order(i, row, col, products)) return Problem(Products, warehouses, orders, rows, cols, drones, deadline, max_payload)
def warehouse_create(): w = Warehouse(store=request.form.get("store_id"), location=request.form.get("location")) if w.save(): flash("Warehouse created.", "success") else: flash("Unable to create warehouse.", "danger") return redirect(url_for("warehouse_new"))
def warehouse_update(id): updated_wh = Warehouse(warehouse_id=id, location=request.form['location']) if updated_wh.save(only=[Warehouse.location]): flash("Successfully updated!", 'success') else: flash("Something went wrong, check your internet and try again", 'danger') return redirect(url_for('warehouse_show', id=id))
def warehouse_created(): store = request.form.get("store_id") location = request.form.get("location") w = Warehouse(store=store, location=location) if w.save(): flash("Warehouse Created!", "success") else: flash("Warehouse Duplicated", "danger") return redirect(url_for('warehouse_new'))
def warehouse_create(): location = request.form.get('wh_location') wh = Warehouse(location=location, store_id=1) if wh.save(): flash(f"Warehouse at {location} has been created!", 'danger') else: flash('Something went wrong!') return redirect('/')
def create_warehouse(): store = request.form['store_id'] w = Warehouse(location=request.form['warehouse_location'], store=store) if w.save(): flash("successfully save") return redirect(url_for('warehouse')) else: return render_template('warehouse.html', name=request.form.get('store_location'))
def w_create(): store_id = Store.get_by_id(request.form.get('s_id')) warehouse_name = request.form.get('warehouse_name') w = Warehouse(location=warehouse_name, store=store_id) if w.save(): flash(f"Successfully saved {warehouse_name}") return redirect(url_for('warehouse')) else: return render_template('warehouse', location=warehouse_name)
def create_warehouse(): storeid = request.form.get("storeid") warehouseloc = request.form.get("warehouse_location") whouse = Warehouse(location=warehouseloc, store_id=storeid) if whouse.save(): flash(f"Warehouse {warehouseloc} saved at Store {storeid}") return redirect(url_for("new_warehouse")) else: flash("That name is already taken") return render_template("warehouse.html")
def add_warehouse(): store = Store.get(Store.name == request.form["store_select"]) w = Warehouse(location=request.form["location"], store=store) try: w.save() flash("Successfully saved!") return redirect("/") except: flash("Warehouse exists! Trash!") return redirect("/warehouse")
def warehouse_create(): location = request.form.get('warehouse_location') store_id = request.form.get('store_id') store =Store.get(Store.id == store_id) w = Warehouse(location=location, store=store) if w.save(): return redirect(url_for('warehouse')) else: return render_template('warehouse.html')
def create_warehouse(): location = request.form['location'] store_id = Store.get(Store.name == request.form['store_name']) warehouse = Warehouse(location=location, store_id=store_id) if warehouse.save(): flash('Succesfully created warehouse!', "success") return render_template('index.html') else: flash('Failed to create warehouse', "danger") return redirect(url_for('show_warehouse'))
def warehouse_form(): store_id = request.form.get('store_id') warehouse_location = request.form.get('location_name') # breakpoint() # store = Store.get_by_id(store_id) #if wanna pass Warehouse first argument as instance new_warehouse = Warehouse(store_id = store_id, location=warehouse_location) if new_warehouse.save(): return redirect(url_for('warehouse')) else: return render_template('warehouse.html', store_id = store_id, warehouse_location = warehouse_location)
def w_create(): w = Warehouse(location=request.form['location'], store=request.form['store_choice']) #Warehouse is the class #location for Warehouse class is from html(name='location') from form if w.save(): flash("flash saved") return redirect(url_for('warehouse')) else: return render_template('warehouse.html', name=request.args['location]'])
def warehouse_create(): warehouse_location = request.form.get('warehouse_location') store_id = request.form.get('store_id') warehouse = Warehouse(location=warehouse_location, store=store_id) if warehouse.save(): flash(f"Added Warehouse: {warehouse_location}") return redirect(url_for('warehouse_new')) #redirect back to the GET app.route('warehouse/new/) to re-render the whole form again# else: flash('Store already has a warehouse') return render_template('warehouse.html', stores=Store.select())
def create_warehouse(): w_location = request.form.get('w_location') s_id = Store.get_by_id(request.form.get('s_id')) w = Warehouse(location=w_location, store=s_id) if w.save(): flash("successfully saved") return redirect(url_for('warehouse')) else: return render_template('warehouse.html', name=request.form['name'], errors=s.errors)
def create_warehouse(): if request.method == "POST": store = Store.get_by_id(request.form['store_id']) w = Warehouse(location=request.form['warehouse_location'], store=store) if w.save(): flash( f"{store.name} added a new warehouse at {request.form['warehouse_location']}." ) return redirect(url_for('new_warehouse')) else: return render_template('warehouse.html', location=request.form['warehouse_location'])
def run_test(): rows, cols, drones_n, turns_n, max_payload = 100, 100, 3, 50, 500 product_types_weights = [100, 5, 450] warehouses = [ Warehouse(0, [0, 0], [5, 1, 0]), Warehouse(1, [5, 5], [0, 10, 2]), ] orders = [ Order(0, (1, 1), [2, 0]), Order(1, (3, 3), [0, 0, 0]), Order(2, (5, 6), [2]) ] predictor = MagicCommandPredictor(drones_n, turns_n, max_payload, product_types_weights, warehouses, orders) randomized_orders = randomize_orders(orders) commands = list(predictor.predict_commands_for_orders(randomized_orders)) commands_str = [str(c) for c in commands] print(len(commands_str)) print('\n'.join(commands_str))
def warehouse_create(): connected_st = Store.get_or_none( Store.store_id == request.form['store_id']) if not connected_st: flash('Selected store does not exist, please create a store first', 'danger') return redirect(url_for('warehouse_new')) new_wh = Warehouse(location=request.form['location'], store=connected_st) if new_wh.save(): flash('Warehouse Successfully created!', "success") return redirect(url_for('warehouses_list')) else: flash('Please check your internet connection and try again', 'danger') return render_template('warehouse.html')
def warehouse_crud(): if request.method == 'POST': new_warehouse_id = request.form['warehouse_id'] new_warehouse_name = request.form['warehouse_name'] # new_warehouse = Warehouse(warehouse_id=new_warehouse_id, warehouse_name=new_warehouse_name) try: new_warehouse = Warehouse( warehouse_id=new_warehouse_id, warehouse_name=new_warehouse_name).create() return redirect('/warehouse_crud') except: return redirect('/warehouse_crud') # return 'There was an issue adding your warehouse' else: warehouses = get_all_warehouses() return render_template('warehouses.html', warehouses=warehouses)
def read_warehouse(id): location = tuple(int(x) for x in input().split()) products = [int(x) for x in input().split()] return Warehouse(id, location, products)
def insert_in_db(insert_id): if request.method == 'POST': if insert_id == '1': try: id = int(request.form.get('worker_id')) name = request.form.get('worker_name') id_card = request.form.get('id_card_no') age = int(request.form.get('age')) sex = request.form.get('sex') tel = request.form.get('telephone') address = request.form.get('address') salary = int(request.form.get('salary')) type = request.form.get('worker_type') workshop_id = int(request.form.get('workshop_id')) worker = Worker(worker_id=id, name=name, id_card_NO=id_card, age=age, sex=sex, contart_info=tel, address=address, salary=salary, work_type=type, workshop_id=workshop_id) db.session.add(worker) db.session.commit() return render_template('BOSS/insert.html', success=True, msg="添加成功~") except: db.session.rollback() return render_template('BOSS/insert.html', success=False, msg="输入有误,添加失败~") elif insert_id == '2': try: id = int(request.form.get('order-num')) company = request.form.get('company') date = request.form.get('order_data') delivery_date = request.form.get('delivery_date') order_state = request.form.get('order_state') order = Order(order_num=id, company=company, order_date=date, delivery_data=delivery_date, delivery_state=order_state) db.session.add(order) db.session.commit() return render_template('BOSS/insert.html', success=True, msg="添加成功~") except: db.session.rollback() return render_template('BOSS/insert.html', success=False, msg="输入有误,添加失败~") elif insert_id == '3': try: workshop_id = int(request.form.get('workshop_id')) director_id = int(request.form.get('director_id')) tel = request.form.get('telephone') workshop = Workshop(workshop_id=workshop_id, director_id=director_id, telephone=tel) db.session.add(workshop) db.session.commit() return render_template('BOSS/insert.html', success=True, msg="添加成功~") except: db.session.rollback() return render_template('BOSS/insert.html', success=False, msg="输入有误,添加失败~") elif insert_id == '4': try: company_name = request.form.get('company-name') name = request.form.get('name') tel = request.form.get('telephone') address = request.form.get('address') cooperation = Cooperation(company=company_name, contact_info=tel, name=name, address=address) db.session.add(cooperation) db.session.commit() return render_template('BOSS/insert.html', success=True, msg="添加成功~") except: db.session.rollback() return render_template('BOSS/insert.html', success=False, msg="输入有误,添加失败~") elif insert_id == '5': try: product_id = int(request.form.get('product-id')) product_name = request.form.get('product-name') price = int(request.form.get('price')) reward = int(request.form.get('reward')) output = int(request.form.get('output')) product = Cooperation(product_id=product_id, product_name=product_name, price=price, reward=reward, output=output) db.session.add(product) db.session.commit() return render_template('BOSS/insert.html', success=True, msg="添加成功~") except: db.session.rollback() return render_template('BOSS/insert.html', success=False, msg="输入有误,添加失败~") elif insert_id == '6': try: warehouse_id = int(request.form.get('warehouse-id')) worker_id = int(request.form.get('worker-id')) tel = request.form.get('telephone') warehouse = Warehouse(warehouse_id=warehouse_id, worker_id=worker_id, telephone=tel) db.session.add(warehouse) db.session.commit() return render_template('BOSS/insert.html', success=True, msg="添加成功~") except: db.session.rollback() return render_template('BOSS/insert.html', success=False, msg="输入有误,添加失败~") else: pass
def warehouse_create(): w = request.form.get("w") s = request.form.get("s") wh = Warehouse(location=w, store_id=s) wh.save() return redirect(url_for("warehouse"))
def warehouse_create(): # print(request.form['store_id']) store = Store.get_by_id(request.form['store_id']) w = Warehouse(location=request.form['warehouse_location'], store=store) w.save() return redirect(url_for('warehouse_new'))