From ef55b4e479759e378e9c6d39c218b9e71b1fdc03 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Tue, 24 May 2016 23:55:58 +0200 Subject: [PATCH 1/2] First step --- app/rollerverbrauch/__init__.py | 13 ++++++++++++- app/rollerverbrauch/forms.py | 4 ++++ app/rollerverbrauch/templates/account.html | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/rollerverbrauch/__init__.py b/app/rollerverbrauch/__init__.py index 3581461..b960590 100644 --- a/app/rollerverbrauch/__init__.py +++ b/app/rollerverbrauch/__init__.py @@ -27,7 +27,8 @@ from rollerverbrauch.forms import \ CreatePitstopForm, \ EditVehicleForm, \ DeleteVehicleForm, \ - SelectVehicleForm + SelectVehicleForm, \ + DeleteAccountForm from rollerverbrauch.entities import \ User, \ @@ -217,3 +218,13 @@ 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(): + return redirect(url_for('get_account_page')) + + return render_template('deleteVehicleForm.html', form=form, vehicle=vehicle) diff --git a/app/rollerverbrauch/forms.py b/app/rollerverbrauch/forms.py index 7e5bd3c..6649433 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='Do it!') diff --git a/app/rollerverbrauch/templates/account.html b/app/rollerverbrauch/templates/account.html index 8cec4de..73ba1d7 100644 --- a/app/rollerverbrauch/templates/account.html +++ b/app/rollerverbrauch/templates/account.html @@ -53,4 +53,12 @@ {% endfor %} +
+
Account
+ +
{% endblock %} From da7c40c78b7f8d1f4f7ce486a9feae5572dbf7b7 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Wed, 25 May 2016 09:40:20 +0200 Subject: [PATCH 2/2] Merge branch 'index_page' into implement_delete_account --- app/rollerverbrauch/__init__.py | 7 +++++-- app/rollerverbrauch/forms.py | 2 +- app/rollerverbrauch/templates/account.html | 2 +- .../templates/deleteAccountForm.html | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 app/rollerverbrauch/templates/deleteAccountForm.html 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
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 %}