Merge branch 'index_page' into implement_delete_account

This commit is contained in:
Joachim Lusiardi 2016-05-25 09:40:20 +02:00
parent 00579eb542
commit da7c40c78b
4 changed files with 25 additions and 4 deletions

View File

@ -239,12 +239,15 @@ def get_statistics():
stats.append(tools.VehicleStats(vehicle)) stats.append(tools.VehicleStats(vehicle))
return render_template('statistics.html', data=stats) return render_template('statistics.html', data=stats)
@app.route('/account/delete', methods=['GET', 'POST']) @app.route('/account/delete', methods=['GET', 'POST'])
@login_required @login_required
def delete_account(): def delete_account():
form = DeleteAccountForm() form = DeleteAccountForm()
if form.validate_on_submit(): if form.validate_on_submit():
return redirect(url_for('get_account_page')) user_datastore.delete_user(current_user)
db.session.commit()
return redirect(url_for('index'))
return render_template('deleteVehicleForm.html', form=form, vehicle=vehicle) return render_template('deleteAccountForm.html', form=form)

View File

@ -47,4 +47,4 @@ class DeleteVehicleForm(Form):
class DeleteAccountForm(Form): class DeleteAccountForm(Form):
submit = SubmitField(label='Do it!') submit = SubmitField(label='Really delete my account!')

View File

@ -58,7 +58,7 @@
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading">Account</div> <div class="panel-heading">Account</div>
<div class="panel-body"> <div class="panel-body">
<a href='{{ url_for('security.change_password') }}'> <a href='{{ url_for('delete_account') }}' class="btn btn-primary " role="button">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete
</a> </a>
</div> </div>

View File

@ -0,0 +1,18 @@
{% extends "layout.html" %}
{% block body %}
<div class="col-md-2" ></div>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-body">
<h3>Delete account for '{{current_user.email}}'?</h3>
This cannot be undone!
<form class='form-horizontal' method="POST">
{{ form.hidden_tag() }}
{{ render_field_with_errors(form.submit) }}
</form>
</div>
</div>
</div>
<div class="col-md-2" ></div>
{% endblock %}