From 59f2a9cf1e849cd25d59587682562eee52058be4 Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Sat, 27 Apr 2019 20:22:27 -0400 Subject: [PATCH] Forgetting a logged-in account now works --- brutaldon/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/brutaldon/views.py b/brutaldon/views.py index 119fe02..370a7c5 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -207,11 +207,12 @@ def forget_account(request, account_name): if not accounts_dict or not account_name in accounts_dict.keys(): return False del accounts_dict[account_name] - if len(accounts) == 0: + if len(accounts_dict) == 0: request.session.flush() return True else: - key = accounts_dict.keys()[0] + set_trace() + key = [*accounts_dict][0] request.session['active_user'] = accounts_dict[key]['user'] try: account = Account.objects.get(id=accounts_dict[key]['account_id']) @@ -1177,11 +1178,11 @@ def accounts(request, id=None): if switch_accounts(request, to_account): return redirect(home) else: - return redirect(accounts) + return redirect("accounts") elif request.POST.get('forget'): account = Account.objects.get(id=id).username forget_account(request, account) - return redirect(accounts) + return redirect("accounts") else: accounts = [x for x in request.session.get('accounts_dict').values()] return render(request, 'accounts/list.html',