Пример #1
0
    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
Пример #2
0
 def createLot(self):
     if self.validateSubmission() != 0:
         return None
     lot = Lot(flask.request.form['name'])
     session.add(lot)
     session.commit()
     return lot
Пример #3
0
 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
Пример #4
0
 def createVendor(self):
     if self.validateSubmission() != 0:
         return None
     vendor = Vendor(flask.request.form['name'])
     session.add(vendor)
     session.commit()
     return vendor
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
    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
Пример #8
0
 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
Пример #9
0
 def createLot(self):
     if self.validateSubmission() != 0:
         return None
     lot = Lot(flask.request.form['name'])
     session.add(lot)
     session.commit()
     return lot
Пример #10
0
    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"
Пример #11
0
 def createVendor(self):
     if self.validateSubmission() != 0:
         return None
     vendor = Vendor(flask.request.form['name'])
     session.add(vendor)
     session.commit()
     return vendor
Пример #12
0
 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"
Пример #13
0
    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))
Пример #14
0
    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))
Пример #15
0
    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))
Пример #16
0
    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))