From 41bc71c75c1756265491bb2919ef84f77b452f13 Mon Sep 17 00:00:00 2001 From: MeaTLoTioN Date: Sat, 4 Sep 2021 19:25:30 +0100 Subject: [PATCH] fix sorted listings and show list of entries for deletion --- mL-ham_logbook.mpy | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mL-ham_logbook.mpy b/mL-ham_logbook.mpy index 147dd69..c1f43c2 100755 --- a/mL-ham_logbook.mpy +++ b/mL-ham_logbook.mpy @@ -154,10 +154,13 @@ def delLogBook() : global db global handle writeln("|CL") - write("Enter the date of the entry to delete: ") + for LOG in sorted(db["logs"], reverse=True) : + if db["logs"][LOG]["reportedBy"] == handle : + writeln(LOG+" ") + write("|CREnter the date of the entry to delete: ") getDate = getstr(10,15,15,"") if getDate : - if db["logs"][getDate] : + if getDate in db["logs"] : del db["logs"][getDate] saveDB() writeln("Deleted: "+getDate) @@ -174,9 +177,9 @@ def viewLogBook() : found = False writeln("|CL|CR") - writeln("Date".ljust(16)+"Callsign".ljust(10)+"Name".ljust(22)+"Sig IN".ljust(8)+"Sig OUT".ljust(8)+"Notes".ljust(15)) - writeln("="*79) - for LOG in db["logs"] : + writeln(" "+"Date".ljust(15)+"Callsign".ljust(10)+"Name".ljust(22)+"Sig IN".ljust(8)+"Sig OUT".ljust(8)+"Notes".ljust(15)) + writeln(" "+"="*78) + for LOG in sorted(db["logs"], reverse=True) : if db["logs"][LOG]["reportedBy"] == handle : found = True contactCall = str(db["logs"][LOG]["contactCall"]) @@ -190,7 +193,7 @@ def viewLogBook() : else : notesAvailable = "N/A" - writeln(LOG.ljust(16)+contactCall.ljust(10)+theirName.ljust(22)+observedSig.ljust(8)+yourSig.ljust(8)+notesAvailable.ljust(15)) + writeln(" "+LOG.ljust(15)+contactCall.ljust(10)+theirName.ljust(22)+observedSig.center(8)+yourSig.center(8)+notesAvailable.ljust(15)) writeln("") #writeln(str(db["logs"])) if not found :