示例#1
0
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'))
示例#2
0
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'))
示例#3
0
def create_warehouse():
   location = request.form.get('location')
   store_select = request.form.get('store_select')
   try:
      Warehouse.create(location = location, store = store_select)
   except:
      print("error")
   return redirect(url_for('new_warehouse', location = location, store_select = store_select))
示例#4
0
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))
示例#5
0
def delete_shop(): 
    store_to_delete_id = request.form.get('store_to_delete')
    store_delete = Store.get_by_id(store_to_delete_id)
    Warehouse.delete().where(Warehouse.store_id == store_to_delete_id).execute()
    store_delete.delete_instance()
    

    return redirect(url_for("shop_index"))
示例#6
0
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"))
示例#7
0
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'))
示例#8
0
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('/')
示例#9
0
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'))
示例#10
0
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)
示例#11
0
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")
示例#12
0
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")
示例#13
0
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')
示例#14
0
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'))
示例#15
0
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 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())
示例#17
0
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)
示例#18
0
文件: server.py 项目: whoabe/inv_mgmt
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]'])
示例#19
0
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) 
示例#20
0
def warehouse():
	if request.method == 'POST':
		store = request.form['store_list']
		location = request.form['warehouse_location']
		new_warehouse = Warehouse.create(location=location, store=store)
		new_warehouse.save()
		flash("Warehouse created", "success")
		return redirect(url_for('warehouse'))
	else:
		# result = Store.select(Store.name, fn.COUNT(Warehouse.store.id == Store.id)).join(Warehouse).group_by(Store.name).where(Store.id == Warehouse.store.id)
		warehouse_list = Warehouse.select()
		store_list = Store.select()
		return render_template('warehouse.html', warehouse_list=warehouse_list, store_list=store_list)
示例#21
0
def store_delete(id):
    store = Store.get_by_id(id)
    query = Warehouse.delete().where(Warehouse.store_id == id)
    query.execute()
    store.delete_instance()

    return redirect('/')
示例#22
0
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)
示例#23
0
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')
示例#24
0
def warehouses_list():
    warehouses = Warehouse.select(
        Warehouse.location, Warehouse.warehouse_id, Warehouse.store,
        fn.COUNT(Product.warehouse_id).alias('count')).join(
            Product, JOIN.LEFT_OUTER).group_by(
                Warehouse.warehouse_id).order_by(Warehouse.location)
    # warehouses = Warehouse.select()
    return render_template('warehouses.html', warehouses=warehouses)
示例#25
0
def warehouse_update(warehouse_id):
    warehouse = Warehouse.get_by_id(warehouse_id)
    warehouse.location = request.form.get("warehouse_location")
    if warehouse.save():
        flash("Warehouse location successfully updated.", "success")
    else:
        flash("The location entered is same as the previous", "danger")
    return redirect(url_for('warehouse_show', warehouse_id=warehouse.id))
示例#26
0
def store_delete(id):
    s_del = Store.get_by_id(id)
    query = Warehouse.delete().where(Warehouse.store_id == id)
    query.execute()

    if s_del.delete_instance():
        flash(f"Successfully deleted {s_del.name}")
        return redirect(url_for('stores'))
    else:
        return render_template('stores')
示例#27
0
    def getWarehouseCase(self, complaintnum):
        info = {}
        complaintnum = str(complaintnum)
        if exists(p for p in Warehouse if p.complaint_number == complaintnum):
            obj = Warehouse.get(complaint_number=complaintnum)        

            info['Complaint Number'] = obj.complaint_number
            info['Date Entered'] = obj.date_entered
            info['Status'] = obj.status

        return info        
示例#28
0
def delete(id_num):
    store = Store.get_by_id(id_num)
    delete_warehouses = Warehouse.delete().where(
        Warehouse.store_id == store.id)
    try:
        delete_warehouses.execute()
        store.delete_instance()
        flash("Store has been deleted! :(")
        return redirect("/stores")
    except:
        flash("Attempt unsuccessful! >:(")
        return redirect("/stores")
示例#29
0
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))
示例#30
0
def product():
	if request.method == 'POST':
		name = request.form['product_name']
		description = request.form['product_description']
		warehouse = request.form['warehouse_list']
		color = request.form['product_color']
		new_product = Product(name=name, description=description, warehouse=warehouse, color=color)
		new_product.save()
		flash("Product created", "success")
		return redirect(url_for('product'))
	else:
		product_list = Product.select()
		warehouse_list = Warehouse.select()
		return render_template('product.html', warehouse_list=warehouse_list, product_list=product_list)
示例#31
0
def store_delete(id):
    del_st = Store.get_by_id(id)
    wh_checking = Warehouse.get_or_none(Warehouse.store_id == del_st)

    if wh_checking:
        wh_checking.delete().where(
            Warehouse.store_id == wh_checking.store_id).execute()

    if del_st.delete_instance():
        flash('Successfully deleted!', 'success')
    else:
        flash('Something went wrong, check your internet and try again',
              'danger')

    return redirect(url_for('stores_list'))