haldis/app/views/stats.py
mcbloch d0863325a5
Restructuring the codebase!
But for real, it's a real shitstorm in there.
- Added context by making the init go through a function
  and not implicitly happen via imports
- Fixup all context and contextless function mixups
- splitup the models in sensible different files
- give the dump of view functions in views/__init__.py their own file
- add all routes via blueprints, not half of them
- move the slack notifications function and class to its own file,
    no idea what it was doing in a views file in the first place.
2019-08-28 03:46:04 +02:00

21 lines
602 B
Python

from flask import Blueprint
from flask import current_app as app
from flask import render_template
from fatmodels import FatLocation, FatOrder, FatOrderItem, FatProduct, FatUser
stats_blueprint = Blueprint('stats_blueprint', __name__)
@stats_blueprint.route('/')
def stats():
data = {
'amount': {
'orders': FatOrder.amount(),
'locations': FatLocation.amount(),
'users': FatUser.amount(),
'orderitems': FatOrderItem.amount(),
'products': FatProduct.amount(),
}
}
return render_template('stats.html', data=data)