def createItem(self): if self.validateSubmission() != 0: return None item = Item() itemSnapshot = ItemSnapshot(flask.request.form['name'], flask.request.form['num'], flask.request.form['quantity'], flask.request.form['reorder_quantity'], flask.request.form['reorder_point']) primary_vendor = session.query(Vendor).get( flask.request.form['primary_vendor']) itemSnapshot.primary_vendor_p = flask.request.form['primary_vendor_p'] itemSnapshot.primary_vendor = primary_vendor if (flask.request.form['secondary_vendor'] != ""): secondary_vendor = session.query(Vendor).get( flask.request.form['secondary_vendor']) itemSnapshot.secondary_vendor = secondary_vendor if (flask.request.form['secondary_vendor_p'] != ""): itemSnapshot.secondary_vendor_p = flask.request.form[ 'secondary_vendor_p'] item.snapshots.append(itemSnapshot) session.add(item) session.commit() return item
def createLot(self): if self.validateSubmission() != 0: return None lot = Lot(flask.request.form['name']) session.add(lot) session.commit() return lot
def editLot(self, lot_id): if self.validateSubmission() != 0: return None lot = session.query(Lot).get(lot_id) lot.name = flask.request.form['name'] session.commit() return lot
def createVendor(self): if self.validateSubmission() != 0: return None vendor = Vendor(flask.request.form['name']) session.add(vendor) session.commit() return vendor
def editVendor(self, vendor_id): if self.validateSubmission() != 0: return None vendor = session.query(Vendor).get(vendor_id) vendor.name = flask.request.form['name'] session.commit() return vendor
def createItem(self): if self.validateSubmission() != 0: return None item = Item() itemSnapshot = ItemSnapshot(flask.request.form['name'], flask.request.form['num'], flask.request.form['quantity'], flask.request.form['reorder_quantity'], flask.request.form['reorder_point']) primary_vendor = session.query(Vendor).get(flask.request.form['primary_vendor']) itemSnapshot.primary_vendor_p = flask.request.form['primary_vendor_p'] itemSnapshot.primary_vendor = primary_vendor if (flask.request.form['secondary_vendor'] != ""): secondary_vendor = session.query(Vendor).get(flask.request.form['secondary_vendor']) itemSnapshot.secondary_vendor = secondary_vendor if (flask.request.form['secondary_vendor_p'] != ""): itemSnapshot.secondary_vendor_p = flask.request.form['secondary_vendor_p'] item.snapshots.append(itemSnapshot) session.add(item) session.commit() return item
def get(self): item = Item('test', '1', 1, 1, 1) session.add(item) session.commit() # items = Item.query.all() # return flask.render_template('home.html', items = items) return "hi"
def post(self, item_id): if item_id == None or flask.request.form[ 'vendor'] == "" or flask.request.form['quantity'] == "": return "" item = session.query(Item).get(item_id) vendor = session.query(Vendor).get(flask.request.form['vendor']) lot = session.query(Lot).get(flask.request.form['lot']) itemSnapshot = getNextSnapshot(item) # Lot lot.state = flask.request.form['lot_list'] itemSnapshot.lot = lot # Vendors if int(flask.request.form['vendor']) == int( item.snapshots[0].primary_vendor.id): itemSnapshot.primary_vendor_q = flask.request.form['quantity'] else: itemSnapshot.secondary_vendor_q = flask.request.form['quantity'] item.snapshots.append(itemSnapshot) session.commit() return flask.redirect(flask.url_for('item', item_id=item_id))
def post(self, item_id): if item_id == None or flask.request.form['quantity'] == "": return flask.render_template('index.html') item = session.query(Item).get(item_id) itemSnapshot = getNextSnapshot(item) itemSnapshot.quantity_on_hand = flask.request.form['quantity'] item.snapshots.append(itemSnapshot) session.commit() return flask.redirect(flask.url_for('item', item_id=item_id))
def post(self, item_id): if item_id == None or flask.request.form['vendor'] == "" or flask.request.form['quantity'] == "": return "" item = session.query(Item).get(item_id) vendor = session.query(Vendor).get(flask.request.form['vendor']) lot = session.query(Lot).get(flask.request.form['lot']) itemSnapshot = getNextSnapshot(item) # Lot lot.state = flask.request.form['lot_list'] itemSnapshot.lot = lot # Vendors if int(flask.request.form['vendor']) == int(item.snapshots[0].primary_vendor.id): itemSnapshot.primary_vendor_q = flask.request.form['quantity'] else: itemSnapshot.secondary_vendor_q = flask.request.form['quantity'] item.snapshots.append(itemSnapshot) session.commit() return flask.redirect(flask.url_for('item', item_id=item_id))