diff --git a/app/rollerverbrauch/__init__.py b/app/rollerverbrauch/__init__.py index aee7407..7da899b 100644 --- a/app/rollerverbrauch/__init__.py +++ b/app/rollerverbrauch/__init__.py @@ -239,12 +239,15 @@ def get_statistics(): 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(): - 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) diff --git a/app/rollerverbrauch/forms.py b/app/rollerverbrauch/forms.py index 6649433..1e20c47 100644 --- a/app/rollerverbrauch/forms.py +++ b/app/rollerverbrauch/forms.py @@ -47,4 +47,4 @@ class DeleteVehicleForm(Form): class DeleteAccountForm(Form): - submit = SubmitField(label='Do it!') + submit = SubmitField(label='Really delete my account!') diff --git a/app/rollerverbrauch/templates/account.html b/app/rollerverbrauch/templates/account.html index 415269a..cc1ed3a 100644 --- a/app/rollerverbrauch/templates/account.html +++ b/app/rollerverbrauch/templates/account.html @@ -58,7 +58,7 @@
Account
- + Delete
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 %}