Merge branch 'implement_delete_account' into 'development'

Implement delete account



See merge request !11
This commit is contained in:
Joachim Lusiardi 2016-05-25 09:41:15 +02:00
commit 2176579baa
4 changed files with 45 additions and 1 deletions

View File

@ -28,7 +28,8 @@ from rollerverbrauch.forms import \
CreatePitstopForm, \
EditVehicleForm, \
DeleteVehicleForm, \
SelectVehicleForm
SelectVehicleForm, \
DeleteAccountForm
from rollerverbrauch.entities import \
User, \
@ -237,3 +238,16 @@ def get_statistics():
for vehicle in current_user.vehicles:
stats.append(tools.VehicleStats(vehicle))
return render_template('statistics.html', data=stats)
@app.route('/account/delete', methods=['GET', 'POST'])
@login_required
def delete_account():
form = DeleteAccountForm()
if form.validate_on_submit():
user_datastore.delete_user(current_user)
db.session.commit()
return redirect(url_for('index'))
return render_template('deleteAccountForm.html', form=form)

View File

@ -44,3 +44,7 @@ class EditVehicleForm(Form):
class DeleteVehicleForm(Form):
submit = SubmitField(label='Do it!')
class DeleteAccountForm(Form):
submit = SubmitField(label='Really delete my account!')

View File

@ -55,4 +55,12 @@
</tbody>
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">Account</div>
<div class="panel-body">
<a href='{{ url_for('delete_account') }}' class="btn btn-primary " role="button">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete
</a>
</div>
</div>
{% endblock %}

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 %}