Skip to content

Commit

Permalink
fix(backend): fix missing home page (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
drahamim authored May 23, 2024
1 parent 0ec4918 commit 5de1cd9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/invenflask/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ def get_version():
# ASSET ROUTES


@app.route('/')
def index():
assets = db.session.query(Asset).all()
asset_total = db.session.query(Asset).count()
asset_types = db.session.query(
Asset.asset_type, db.func.count()).group_by(Asset.asset_type).all()
asset_status = db.session.query(
Asset.asset_type,
db.func.count().label('TotalCount'),
db.func.sum(db.case((Asset.asset_status == 'checkedout', 1), else_=0)).label(
'AvailCount')
).group_by(Asset.asset_type).all()
checkouts = db.session.query(Checkout).all()
return render_template(
'index.html', assets=assets, asset_total=asset_total,
asset_type=asset_types, asset_status=asset_status, checkouts=checkouts)


@app.route('/create/asset', methods=('GET', 'POST'))
def asset_create():

Expand Down

0 comments on commit 5de1cd9

Please sign in to comment.