change how deleting log entries works, now just choose a number of the item to delete, also add seconds to log entries

This commit is contained in:
MeaTLoTioN 2021-11-26 10:51:48 +00:00
parent efa3e0a58f
commit 5104864dd5

View File

@ -137,16 +137,16 @@ def addLogBook() :
#writeln(str(db)) #writeln(str(db))
#writeln("|PA") #writeln("|PA")
ts = calendar.timegm(time.gmtime()) ts = calendar.timegm(time.gmtime())
now = datetime.now().strftime('%Y-%m-%d %H:%M') now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
writeln("|CL") writeln("|CL")
write("Enter the date for this log entry (YYYY-MM-DD HH:MM): ") write("Enter the date for this log entry (YYYY-MM-DD HH:MM:SS): ")
getDate = getstr(1,16,16,now) getDate = getstr(1,16,16,now)
if not getDate : if not getDate :
return isNull() return isNull()
write("Enter the call-sign of the person you made contact with: ") write("Enter the call-sign of the person you made contact with: ")
getCall = getstr(2,10,10,db["users"][handle]["callsign"]) getCall = getstr(2,10,10,"")
if not getCall : if not getCall :
return isNull() return isNull()
@ -203,24 +203,29 @@ def addLogBook() :
def delLogBook() : def delLogBook() :
global db global db
global handle global handle
tmpDB = []
found = False found = False
writeln("|CL") writeln("|CL")
for LOG in sorted(db["logs"], reverse=True) : for LOG in sorted(db["logs"], reverse=True) :
if db["logs"][LOG]["reportedBy"] == handle : if db["logs"][LOG]["reportedBy"] == handle :
found = True found = True
writeln(LOG) tmpDB.append(LOG)
if found : if found :
write("|CREnter the date of the entry to delete: ") L = len(tmpDB)
for I in range(L) :
writeln("["+str(I+1)+"] "+tmpDB[I])
write("|CREnter the number of the entry to delete: ")
getDate = getstr(1,16,16,"") getDate = getstr(1,16,16,"")
if getDate : if getDate :
if getDate in db["logs"] : NUM = int(getDate) - 1
del db["logs"][getDate] if tmpDB[NUM] in db["logs"] :
del db["logs"][tmpDB[NUM]]
saveDB() saveDB()
writeln("Deleted: "+getDate) writeln("Deleted: "+getDate)
writeln("|PA") writeln("|PA")
else : else :
writeln("No log entry with that date, please check and try again.") writeln("No log entry with that date, please check and try again.")
writeln("|PA") writeln("|PA")
else: else:
writeln("") writeln("")
writeln("No records to delete. Aborted.".center(71)) writeln("No records to delete. Aborted.".center(71))