From 138b42fca6a2f339e9c949e5347c93d85251c055 Mon Sep 17 00:00:00 2001 From: Jojo144 Date: Sun, 1 Oct 2023 20:19:55 +0200 Subject: [PATCH] Add backward compatibility for last_selected_payer --- ihatemoney/web.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ihatemoney/web.py b/ihatemoney/web.py index e59182e1d..2afcb312a 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -646,11 +646,15 @@ def list_bills(): # Used for CSRF validation csrf_form = EmptyForm() # set the last selected payer as default choice if exists - if ( - "last_selected_payer_per_project" in session - and g.project.id in session["last_selected_payer_per_project"] - ): - bill_form.payer.data = session["last_selected_payer_per_project"][g.project.id] + if "last_selected_payer_per_project" in session: + if g.project.id in session["last_selected_payer_per_project"]: + bill_form.payer.data = session["last_selected_payer_per_project"][ + g.project.id + ] + # for backward compatibility, should be removed at some point + else: + if "last_selected_payer" in session: + bill_form.payer.data = session["last_selected_payer"] # Each item will be a (weight_sum, Bill) tuple. # TODO: improve this awkward result using column_property: