From df3292df37eacf157f93b7fc163e608b39c0b5a6 Mon Sep 17 00:00:00 2001 From: Son NK Date: Sat, 6 Jul 2019 17:50:03 +0200 Subject: [PATCH] user can delete email alias --- app/dashboard/templates/dashboard/index.html | 28 +++++++++++++++----- app/dashboard/views/index.py | 10 +++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/dashboard/templates/dashboard/index.html b/app/dashboard/templates/dashboard/index.html index 43437132..b240fd89 100644 --- a/app/dashboard/templates/dashboard/index.html +++ b/app/dashboard/templates/dashboard/index.html @@ -39,7 +39,7 @@ Enable/Disable Email Forwarding - Created At + Delete @@ -104,8 +104,16 @@ - {{ gen_email.created_at | dt }} +
+ + + + + +
+ {% endfor %} @@ -212,10 +220,18 @@ e.clearSelection(); }); - // the modal does not get close when user clicks outside of modal - // necessary for obligatory modal such as the one displayed when user enable/display email forwarding - notie.setOptions({ - overlayClickDismiss: false, + $(".delete-email").on("click", function (e) { + notie.confirm({ + text: "Once an email alias is deleted, people/apps " + + "who used to contact you via this email cannot reach you any more," + + " please confirm", + cancelCallback: () => { + // nothing to do + }, + submitCallback: () => { + $(this).closest("form").submit(); + } + }); }); $(".custom-switch-input").change(function (e) { diff --git a/app/dashboard/views/index.py b/app/dashboard/views/index.py index b2fa08b2..7dfd3611 100644 --- a/app/dashboard/views/index.py +++ b/app/dashboard/views/index.py @@ -66,6 +66,16 @@ SimpleLogin team. ) db.session.commit() + elif request.form.get("form-name") == "delete-email": + gen_email_id = request.form.get("gen-email-id") + gen_email: GenEmail = GenEmail.get(gen_email_id) + + LOG.d("delete gen email %s", gen_email) + email = gen_email.email + GenEmail.delete(gen_email.id) + db.session.commit() + flash(f"Email alias {email} has been deleted", "success") + return redirect(url_for("dashboard.index")) client_users = (