add sysop ability to export own or all logs

This commit is contained in:
MeaTLoTioN 2021-09-05 17:53:46 +01:00
parent 6cd3b1e86b
commit 9207306197

View File

@ -281,30 +281,53 @@ def viewLogBook() :
def exportLogBook() :
global db
global handle
secLevel = mci2str('SL')
filter = handle
who = ""
if secLevel == "255" :
gotoxy(22,19)
write("View [A]ll or [S]elf only: ")
ch = onekey(chr(13) + 'AS', False)
if ch == "S" :
pass
write("SELF")
if ch == "A" :
filter = "all"
who = "ReportedBy,"
write("ALL")
callsign = db["users"][handle]["callsign"]
tempFile = script_path+"/"+"mL-ham_logbook_"+callsign.lower()+".csv"
fHandle = open(tempFile, "w")
fHandle.write("Date,Callsign,Name,RST IN,RST OUT,Notes\n")
fHandle.write(who+"Date,Callsign,Name,RST IN,RST OUT,Notes\n")
found = False
for LOG in sorted(db["logs"], reverse=False) :
if db["logs"][LOG]["reportedBy"] == handle :
if (filter == "all") or (db["logs"][LOG]["reportedBy"] == handle) :
found = True
reportedBy = str(db["logs"][LOG]["reportedBy"])
contactCall = str(db["logs"][LOG]["contactCall"])
observedSig = str(db["logs"][LOG]["observedSig"])
yourSig = str(db["logs"][LOG]["yourSig"])
theirName = str(db["logs"][LOG]["theirName"])
notes = str(db["logs"][LOG]["notes"])
fHandle.write(LOG+","+contactCall+","+theirName+" "+observedSig+","+yourSig+","+notes+"\n")
if who != "" :
showWho = reportedBy+","
else :
showWho = ""
fHandle.write(showWho+LOG+","+contactCall+","+theirName+" "+observedSig+","+yourSig+","+notes+"\n")
fHandle.close()
if found :
menucmd('F3',tempFile)
writeln("|15File exported|07")
writeln("|PA")
else :
writeln("|15Sorry, no records to export. Aborted.|07")
writeln("|PA")
os.remove(tempFile)
writeln("File exported")
writeln("|PA")
if not found :
writeln("Sorry, no records to export. Aborted.")
writeln("|PA")
def checkConfig(S = None) :