diff --git a/app/rollerverbrauch/__init__.py b/app/rollerverbrauch/__init__.py index 3581461..19a6f99 100644 --- a/app/rollerverbrauch/__init__.py +++ b/app/rollerverbrauch/__init__.py @@ -9,6 +9,7 @@ from flask.ext.security import Security, SQLAlchemyUserDatastore, \ from flask.ext.security import user_registered from flask_security.core import current_user from flask_sqlalchemy import SQLAlchemy +from flask.ext.security.forms import LoginForm app = Flask(__name__) app.config['SECURITY_PASSWORD_HASH'] = 'pbkdf2_sha512' @@ -72,9 +73,28 @@ def before_request(): @app.route('/') -@login_required def index(): - return redirect(url_for('get_pit_stops')) + if current_user.is_authenticated: + return redirect(url_for('get_pit_stops')) + else: + user_count = len(User.query.all()) + vehicles = Vehicle.query.all() + litres = 0 + kilometers = 0 + for vehicle in vehicles: + stats = tools.VehicleStats(vehicle) + litres += stats.overall_litres + kilometers += stats.overall_distance + vehicle_count = len(vehicles) + pitstop_count = len(Pitstop.query.all()) + data = { + 'users':user_count, + 'vehicles': vehicle_count, + 'pitstops': pitstop_count, + 'litres': litres, + 'kilometers': kilometers + } + return render_template('index.html', login_user_form=LoginForm(), data=data) @app.route('/account/edit_vehicle/', methods=['GET', 'POST']) diff --git a/app/rollerverbrauch/templates/layout.html b/app/rollerverbrauch/templates/layout.html index 2df1885..e03289b 100644 --- a/app/rollerverbrauch/templates/layout.html +++ b/app/rollerverbrauch/templates/layout.html @@ -134,7 +134,7 @@ - refuel journal + refuel journal