From 5ae37eef8251fd9aa709f50658dc5ed26c19e1aa Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 1 Feb 2023 19:31:29 +0000 Subject: [PATCH] Fix to not create an extra wallet --- core/views/wallets.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/views/wallets.py b/core/views/wallets.py index 0d8ecd0..0b9f426 100644 --- a/core/views/wallets.py +++ b/core/views/wallets.py @@ -274,7 +274,9 @@ def walletedit(request, path=None): actual_saved = [] def get_next_empty(): - latest = Wallet.objects.filter(walletname__startswith="20").latest('walletname') + """Gets the next most number for a new wallet just after the most recent one in the + db. But if it has no date set, then ignore it as it was only just created""" + latest = Wallet.objects.filter(walletname__startswith="20",walletdate__isnull=False).latest('walletname') next = int(latest.walletname[5:]) + 1 return f"{latest.walletname[:4]}:{next:02d}" @@ -456,6 +458,7 @@ def walletedit(request, path=None): form = FilesForm() if request.method == "POST": + # print(f'--- POST processing starts {wallet=} {path=}') if "psg" in request.POST: # handle metadata form formj = WalletForm(request.POST) # Beware. All fields returned as strings. Must re-type them as lists etc. before using or re-saving