def backupWeekOf(type, weekOf): startTime = datetime.datetime.combine(weekOf, datetime.time(8, 45)) endTime = startTime + datetime.timedelta(minutes=db.getResourceDuration(type)) weekstr = db.getResourceName(type) + " for the week of " + weekOf.strftime("%Y-%m-%d") + "\n\n" weekstr += ",M,T,W,Th,F\n" for i in range(0, db.getResourceSlotCount(type)): weekstr += backupTimeslot(type, weekOf.date(), startTime.time()) startTime = startTime + datetime.timedelta(minutes=db.getResourceDuration(type) + 5) endTime = endTime + datetime.timedelta(minutes=db.getResourceDuration(type) + 5) return weekstr
def generateSchedulePage(weekOf, type): nextWeek = lastWeek = datetime.datetime.combine(weekOf, datetime.time(0, 0)) nextWeek = nextWeek + datetime.timedelta(weeks=1) nextWeekStr = nextWeek.strftime("%Y-%m-%d") lastWeek = lastWeek - datetime.timedelta(weeks=1) lastWeekStr = lastWeek.strftime("%Y-%m-%d") yield u""" <div id="schedule"> <div id="scheduleHeader"><div class="smallbutton" onclick="window.location='%(last)s'"><a href="%(last)s">←</a></div> <span id='schedTitle'>Schedule for week of %(week)s</span> <div class="smallbutton" onclick="window.location='%(next)s'"><a href="%(next)s">→</a></div></div> <br /> <table id="scheduleTable" cellpadding="0px" cellspacing="4px"> <tr> <td class="tHide"></td> <td class="tHeader">Monday</td> <td class="tHeader">Tuesday</td> <td class="tHeader">Wednesday</td> <td class="tHeader">Thursday</td> <td class="tHeader">Friday</td> </tr>""" % { "week": weekOf.strftime("%B %d, %Y"), "last": "?date=" + lastWeekStr, "next": "?date=" + nextWeekStr, } startTime = datetime.datetime.combine(weekOf, datetime.time(8, 45)) endTime = startTime + datetime.timedelta(minutes=db.getResourceDuration(type)) for i in range(0, db.getResourceSlotCount(type)): yield """ <tr> <td class="tTime">%(startTime)s - %(endTime)s</td> %(daySlots)s </tr> """ % { "startTime": startTime.strftime("%I:%M"), "endTime": endTime.strftime("%I:%M"), "daySlots": generateDaySlots(weekOf, startTime.time(), type), } startTime = startTime + datetime.timedelta(minutes=db.getResourceDuration(type) + 5) endTime = endTime + datetime.timedelta(minutes=db.getResourceDuration(type) + 5)