adding section for per person count #26

Merged
paradizelost merged 1 commits from work into main 2024-11-26 00:10:43 -06:00

View File

@ -141,6 +141,10 @@ for myaccount in accounts:
mycoverurl = mybook['resource']['coverUrl']['small'] mycoverurl = mybook['resource']['coverUrl']['small']
except: except:
mycoverurl = '' mycoverurl = ''
try:
myresourceid=mybook['resource']['id']
except:
myresourceid=''
duedate = datetime.datetime.strptime(mybook['dueDate'].split('T')[0],'%Y-%m-%d').date() duedate = datetime.datetime.strptime(mybook['dueDate'].split('T')[0],'%Y-%m-%d').date()
if datetime.date.today() > duedate: if datetime.date.today() > duedate:
overdue=True overdue=True
@ -153,7 +157,7 @@ for myaccount in accounts:
datetime.datetime.strptime(mybook['checkOutDate'].split('T')[0],'%Y-%m-%d').date(), datetime.datetime.strptime(mybook['checkOutDate'].split('T')[0],'%Y-%m-%d').date(),
duedate, duedate,
mybook['vendor'], mybook['vendor'],
mybook['resource']['id'], myresourceid,
mybook['resource']['title'], mybook['resource']['title'],
mybook['resource']['materialType'], mybook['resource']['materialType'],
mycoverurl, mycoverurl,
@ -199,9 +203,14 @@ returntable += """<form action="https://librarynotice.hamik.net/refresh.php">
td="</td><td>" td="</td><td>"
th="</th><th>" th="</th><th>"
#returntable = '<a href="https://librarynotice.hamik.net">Click to return to main list</a>' #returntable = '<a href="https://librarynotice.hamik.net">Click to return to main list</a>'
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Name'+ th +'Count</th></tr>'
for account in accounts:
accountcount = sum(b.person == account.person for b in allbooks)
if accountcount >0:
returntable += "<tr><td>" + account.person + td + str(accountcount) + "</td></tr>"
duesoon = [d for d in allbooks if (d.duedate < datetime.date.today() + datetime.timedelta(days=10)) and not (str(d.renewresult).lower() == 'None'.lower())] duesoon = [d for d in allbooks if (d.duedate < datetime.date.today() + datetime.timedelta(days=10)) and not (str(d.renewresult).lower() == 'None'.lower())]
if len(duesoon) >=1: if len(duesoon) >=1:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Name'+ th +'Count</th></tr>' returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
for type in mediatypes: for type in mediatypes:
typecount = sum(b.materialtype == type for b in duesoon) typecount = sum(b.materialtype == type for b in duesoon)
if typecount>0: if typecount>0:
@ -217,7 +226,7 @@ returnlist = [d for d in allbooks if (d.renewalcount == 3)]
if len(returnlist) == 0: if len(returnlist) == 0:
pass pass
else: else:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Name'+ th +'Count</th></tr>' returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
for type in mediatypes: for type in mediatypes:
typecount = sum(b.materialtype == type for b in returnlist) typecount = sum(b.materialtype == type for b in returnlist)
if typecount>0: if typecount>0:
@ -233,7 +242,7 @@ returnlist = [d for d in allbooks if (d.renewalcount == 2)]
if len(returnlist) == 0: if len(returnlist) == 0:
pass pass
else: else:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Name'+ th +'Count</th></tr>' returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
for type in mediatypes: for type in mediatypes:
typecount = sum(b.materialtype == type for b in returnlist) typecount = sum(b.materialtype == type for b in returnlist)
if typecount>0: if typecount>0:
@ -249,7 +258,7 @@ returnlist = [d for d in allbooks if (d.renewalcount == 1)]
if len(returnlist) == 0: if len(returnlist) == 0:
pass pass
else: else:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Name'+ th +'Count</th></tr>' returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
for type in mediatypes: for type in mediatypes:
typecount = sum(b.materialtype == type for b in returnlist) typecount = sum(b.materialtype == type for b in returnlist)
if typecount>0: if typecount>0:
@ -265,7 +274,7 @@ returnlist = [d for d in allbooks if (d.renewalcount == 0)]
if len(returnlist) == 0: if len(returnlist) == 0:
pass pass
else: else:
returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Name'+ th +'Count</th></tr>' returntable += tablestart + '<colgroup><col/><col/></colgroup><tr><th>Type'+ th +'Count</th></tr>'
for type in mediatypes: for type in mediatypes:
typecount = sum(b.materialtype == type for b in returnlist) typecount = sum(b.materialtype == type for b in returnlist)
if typecount>0: if typecount>0: