diff --git a/app/__init__.py b/app/__init__.py index 58a6b80..18c3a92 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -85,12 +85,20 @@ def index(): return redirect(url_for('get_pit_stops')) else: user_count = len(User.query.all()) + consumables = Consumable.query.all() + per_consumable = {} + for consumable in consumables: + per_consumable[consumable.id] = { + 'name': consumable.name, + 'unit': consumable.unit, + 'amount': 0 + } vehicles = Vehicle.query.all() - litres = 0 kilometers = 0 for vehicle in vehicles: stats = tools.VehicleStats(vehicle) - #litres += stats.overall_litres + for consumable in stats.consumables: + per_consumable[consumable.id]['amount'] += consumable.overall_amount kilometers += stats.overall_distance vehicle_count = len(vehicles) pitstop_count = len(Pitstop.query.all()) @@ -98,9 +106,10 @@ def index(): 'users': user_count, 'vehicles': vehicle_count, 'pitstops': pitstop_count, - 'litres': litres, - 'kilometers': kilometers + 'kilometers': kilometers, + 'consumables': per_consumable } + return render_template('index.html', login_user_form=LoginForm(), data=data) diff --git a/app/templates/index.html b/app/templates/index.html index 162c066..2dc8e1f 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -11,7 +11,13 @@

Join the pitstop community!

-

There are already {{ data.users}} members with {{ data.vehicles }} vehicles who have logged {{ data.pitstops }} pitstops fuelling {{ data.litres }}l for {{ data.kilometers }}km.

+

There are already {{ data.users}} members with {{ data.vehicles }} vehicles who have logged {{ data.kilometers }}km in {{ data.pitstops }} pitstops. They fuelled

+

With pitstop community you can: