def addMultiBins(form, wh): bins_ = [] bins = form.name.data.split(",") error = 0 if bins: for bin_ in bins: isBin = Bin.query.filter_by(name=bin_).first() if isBin is None: abin = Bin(name=bin_, depth=form.depth.data, warehouse_id=wh) bins_.append(abin) error = db_bulk_insert(bins_) return error
def new_tool(): """ Add a new special tool """ form = ToolForm(request.form) if request.method == 'POST' and form.validate(): # save the tool bin = Bin() save_changes(bin, form, new=True) flash('Tool listing created successfully.') return redirect('/') return render_template('new_tool.html', form=form)
def addMultiBins(form): bins_, abins = [], [] bins = form.name.data.split(",") error = 0 if bins: for bin_ in bins: bin_exist = Bin.query.filter_by(name=bin_).first() if not bin_exist: abin = Bin(name=bin_.upper(), depth=form.depth.data, warehouse_id=form.warehouse.data, aisle_id=form.aisle.data) if bin_.upper() not in abins: abins.append(bin_.upper()) bins_.append(abin) error = db_bulk_insert(bins_) return error
def post(self): city = None if self.request.get("city").lower() != "": if not getCityObjectByName(self.request.get("city").lower()): city = City() city.name = self.request.get("city").lower() city.put() else: city = getCityObjectByName(self.request.get("city").lower()) bin = None if not getBinObjectByName(city.key, self.request.get("bin_name").lower()): bin = Bin(parent=city.key) bin.name = self.request.get("bin_name").lower() bin.image = self.request.get("image").lower() bin.sortingInstructions = self.request.get( "sorting_instructions") putBinObject(bin) else: pass bin_add_template = jinja_env.get_template("templates/addbin.html") self.response.out.write(bin_add_template.render())
def post(self): bin = Bin() bin.put() self.redirect('/%s' % bin.name)