From 1f5cb6b1fae8d242e45087726c732a955bac7d53 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Sat, 16 Jul 2016 13:29:32 +0200 Subject: [PATCH] Fixed issue with status on non-logged in index page --- app/rollerverbrauch/__init__.py | 17 +++++++++++++---- app/rollerverbrauch/templates/index.html | 8 +++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/rollerverbrauch/__init__.py b/app/rollerverbrauch/__init__.py index 85b7afb..a94a45b 100644 --- a/app/rollerverbrauch/__init__.py +++ b/app/rollerverbrauch/__init__.py @@ -87,12 +87,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()) @@ -100,9 +108,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/rollerverbrauch/templates/index.html b/app/rollerverbrauch/templates/index.html index 162c066..2dc8e1f 100644 --- a/app/rollerverbrauch/templates/index.html +++ b/app/rollerverbrauch/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: