diff --git a/app/rollerverbrauch/__init__.py b/app/rollerverbrauch/__init__.py index 19a6f99..7da899b 100644 --- a/app/rollerverbrauch/__init__.py +++ b/app/rollerverbrauch/__init__.py @@ -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) diff --git a/app/rollerverbrauch/forms.py b/app/rollerverbrauch/forms.py index 7e5bd3c..1e20c47 100644 --- a/app/rollerverbrauch/forms.py +++ b/app/rollerverbrauch/forms.py @@ -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!') diff --git a/app/rollerverbrauch/templates/account.html b/app/rollerverbrauch/templates/account.html index 756216e..cc1ed3a 100644 --- a/app/rollerverbrauch/templates/account.html +++ b/app/rollerverbrauch/templates/account.html @@ -55,4 +55,12 @@ +
+
Account
+
+ + Delete + +
+
{% endblock %} diff --git a/app/rollerverbrauch/templates/deleteAccountForm.html b/app/rollerverbrauch/templates/deleteAccountForm.html new file mode 100644 index 0000000..f28dd7a --- /dev/null +++ b/app/rollerverbrauch/templates/deleteAccountForm.html @@ -0,0 +1,18 @@ +{% extends "layout.html" %} + +{% block body %} +
+
+
+
+

Delete account for '{{current_user.email}}'?

+ This cannot be undone! +
+ {{ form.hidden_tag() }} + {{ render_field_with_errors(form.submit) }} +
+
+
+
+
+{% endblock %}