Fixed issue with status on non-logged in index page

This commit is contained in:
Joachim Lusiardi 2016-07-16 13:29:32 +02:00
parent 1516ac2c51
commit 1f5cb6b1fa
2 changed files with 20 additions and 5 deletions

View File

@ -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)

View File

@ -11,7 +11,13 @@
<div class="panel-body" >
<h1>Join the pitstop community!</h1>
<p>There are already {{ data.users}} members with {{ data.vehicles }} vehicles who have logged {{ data.pitstops }} pitstops fuelling {{ data.litres }}l for {{ data.kilometers }}km.</p>
<p>There are already {{ data.users}} members with {{ data.vehicles }} vehicles who have logged {{ data.kilometers }}km in {{ data.pitstops }} pitstops. They fuelled</p>
<ul>
{% for key in data.consumables %}
{% set consumable = data.consumables[key] %}
<li>{{consumable.amount}}{{consumable.unit}} of {{consumable.name}}</li>
{% endfor %}
</ul>
<p>With pitstop community you can:</p>
<ul>