コード例 #1
0
    def inventories(cls):
        # get all inventories
        all_inventories = Inventory.fetch_all()

        if request.method == 'POST':
            name: str = request.form['name']
            itype: str = request.form['category']
            bp = request.form['bp']
            sp = request.form['sp']

            # check if the inventory name exists
            inv = Inventory.check_inventory_exists(name)

            if inv is not None:
                flash('Inventory name already exists', 'danger')
                return redirect(url_for('inventories'))
            else:
                record = Inventory(name=name.title(),
                                   itype=itype.title(),
                                   bp=bp,
                                   sp=sp)
                record.create_record()
                flash('Successfully added', 'success')
                return redirect(url_for('inventories'))

        return render_template('/admin/inventories.html',
                               inventories=all_inventories)
コード例 #2
0
 def get_all_inventories(cls, db: Session):
     """"return a list of all inventories"""
     send_log_to_queue('All Inventory Fetched')
     return Inventory.fetch_all(db=db)
コード例 #3
0
 def inventories(cls):
     #Get all Inventories
     all_inventories = Inventory.fetch_all()
     print("Here:", all_inventories)
     return render_template("/admin/inventories.html",
                            inventories=all_inventories)
コード例 #4
0
def dashboard():
    total_inventories = len(Inventory.fetch_all())

    return render_template('/admin/dashboard.html', ti=total_inventories)