From 170082e2c18add1b5812f6a7511614651cbaa09a Mon Sep 17 00:00:00 2001 From: Son Nguyen Kim Date: Wed, 25 Jan 2023 13:16:10 +0100 Subject: [PATCH] after deleting an alias, user should stay on the same page (#1546) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * after deleting an alias, user should stay on the same page * Fix delete alias mlec (#1547) * Specify how to create the certificates if they don't exist in readme (#1533) * Remove id= from get 🩹 * Add flash message level 🩹 * Rename transfer_mailbox back to new_mailbox in the create-mailbox part 🩹 Co-authored-by: rubencm * Fix delete alias mlec (#1552) * Specify how to create the certificates if they don't exist in readme (#1533) * Remove id= from get 🩹 * Add flash message level 🩹 * Rename transfer_mailbox back to new_mailbox in the create-mailbox part 🩹 * Linting files to pass test 🎨 Co-authored-by: rubencm Co-authored-by: mlec <42201667+mlec1@users.noreply.github.com> Co-authored-by: rubencm --- app/api/views/mailbox.py | 2 +- app/dashboard/views/index.py | 8 +++++++- app/dashboard/views/mailbox.py | 15 +++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/api/views/mailbox.py b/app/api/views/mailbox.py index e99fd82c..27475b86 100644 --- a/app/api/views/mailbox.py +++ b/app/api/views/mailbox.py @@ -86,7 +86,7 @@ def delete_mailbox(mailbox_id): """ user = g.user - mailbox = Mailbox.get(id=mailbox_id) + mailbox = Mailbox.get(mailbox_id) if not mailbox or mailbox.user_id != user.id: return jsonify(error="Forbidden"), 403 diff --git a/app/dashboard/views/index.py b/app/dashboard/views/index.py index 6bd66378..ceeef89e 100644 --- a/app/dashboard/views/index.py +++ b/app/dashboard/views/index.py @@ -150,7 +150,13 @@ def index(): flash(f"Alias {alias.email} has been disabled", "success") return redirect( - url_for("dashboard.index", query=query, sort=sort, filter=alias_filter) + url_for( + "dashboard.index", + query=query, + sort=sort, + filter=alias_filter, + page=page, + ) ) mailboxes = current_user.mailboxes() diff --git a/app/dashboard/views/mailbox.py b/app/dashboard/views/mailbox.py index e6f41edc..0be92f43 100644 --- a/app/dashboard/views/mailbox.py +++ b/app/dashboard/views/mailbox.py @@ -69,17 +69,20 @@ def mailbox_route(): transfer_mailbox = Mailbox.get(transfer_mailbox_id) if not transfer_mailbox or transfer_mailbox.user_id != current_user.id: - flash("You must transfer the aliases to a mailbox you own.") + flash( + "You must transfer the aliases to a mailbox you own.", "error" + ) return redirect(url_for("dashboard.mailbox_route")) if transfer_mailbox.id == mailbox.id: flash( - "You can not transfer the aliases to the mailbox you want to delete." + "You can not transfer the aliases to the mailbox you want to delete.", + "error", ) return redirect(url_for("dashboard.mailbox_route")) if not transfer_mailbox.verified: - flash("Your new mailbox is not verified") + flash("Your new mailbox is not verified", "error") return redirect(url_for("dashboard.mailbox_route")) # Schedule delete account job @@ -147,12 +150,12 @@ def mailbox_route(): elif not email_can_be_used_as_mailbox(mailbox_email): flash(f"You cannot use {mailbox_email}.", "error") else: - transfer_mailbox = Mailbox.create( + new_mailbox = Mailbox.create( email=mailbox_email, user_id=current_user.id ) Session.commit() - send_verification_email(current_user, transfer_mailbox) + send_verification_email(current_user, new_mailbox) flash( f"You are going to receive an email to confirm {mailbox_email}.", @@ -162,7 +165,7 @@ def mailbox_route(): return redirect( url_for( "dashboard.mailbox_detail_route", - mailbox_id=transfer_mailbox.id, + mailbox_id=new_mailbox.id, ) )