def populateMonthVisitTable(): allPatronVisitsDates = databaseFunctions.getAllVisitPatronVisitDates() allPatronsVisitsTimes = databaseFunctions.getAllVisitPatronVisitTimes() monthVisitsTable = [0] * 12 for visit in allPatronVisitsDates: currentIndex = 0 for i in range(0, 12): dateTimeStart = visit thisVisit = datetime.strptime(dateTimeStart, "%m/%d/%Y") currentTime = datetime.now(pytz.timezone('US/Central')) today = date(currentTime.year, currentTime.month, currentTime.day) today = today + relativedelta(months=-i) start = date(today.year, today.month, 1) end = date.today() evaluateVisit = date(thisVisit.year, thisVisit.month, thisVisit.day) if timeInRange(start, end, evaluateVisit): monthVisitsTable[len(monthVisitsTable) - 1 - currentIndex] += 1 break else: currentIndex += 1 return monthVisitsTable
def populateWeeksVisitTable(): allPatronVisitsDates = databaseFunctions.getAllVisitPatronVisitDates() allPatronsVisitsTimes = databaseFunctions.getAllVisitPatronVisitTimes() weekVisitsTable = [0] * 7 for visit in allPatronVisitsDates: currentIndex = 0 for i in range(0, 7): dateTimeStart = visit thisVisit = datetime.strptime(dateTimeStart, "%m/%d/%Y") currentTime = datetime.now(pytz.timezone('US/Central')) today = date(currentTime.year, currentTime.month, currentTime.day) margin = timedelta(days=i) evaluateVisit = date(thisVisit.year, thisVisit.month, thisVisit.day) if today - margin <= evaluateVisit: weekVisitsTable[len(weekVisitsTable) - 1 - currentIndex] += 1 break else: currentIndex += 1 return weekVisitsTable
def populateTodaysVisitsTable(): allPatronVisitsDates = databaseFunctions.getAllVisitPatronVisitDates() allPatronsVisitsTimes = databaseFunctions.getAllVisitPatronVisitTimes() todaysTimes = [] for i in range(0, len(allPatronVisitsDates)): dateTimeStart = allPatronVisitsDates[i] currentTime = datetime.now(pytz.timezone('US/Central')) today = date(currentTime.year, currentTime.month, currentTime.day) thisVisit = datetime.strptime(dateTimeStart, "%m/%d/%Y") if thisVisit.day == today.day and thisVisit.month == today.month and thisVisit.year == today.year: todaysTimes.append(allPatronsVisitsTimes[i]) todaysVisitsTable = [0] * 12 for visit in todaysTimes: currentLowerBoundHourCheck = 0 currentUpperBoundHourCheck = 2 currentRangeIndex = 0 for i in range(0, 12): if (currentUpperBoundHourCheck > 23): currentUpperBoundHourCheck = 23 start = time(currentLowerBoundHourCheck, 0) end = time(currentUpperBoundHourCheck, 0) thisVisit = datetime.strptime(visit, "%H:%M") checkTime = time(thisVisit.hour, thisVisit.minute) if timeInRange(start, end, checkTime): todaysVisitsTable[currentRangeIndex] += 1 break currentLowerBoundHourCheck += 2 currentUpperBoundHourCheck += 2 currentRangeIndex += 1 return todaysVisitsTable
def patronViewMaster(): if not session.get('isLoggedIn'): return redirect('login') try: patronTable = {} patronTable['id'] = databaseFunctions.getAllPatronIds() patronTable[ 'accountType'] = databaseFunctions.getAllPatronAccountTypes() patronTable['firstName'] = databaseFunctions.getAllPatronFirstNames() patronTable['lastName'] = databaseFunctions.getAllPatronLastNames() patronTable['email'] = databaseFunctions.getAllPatronEmails() patronTable[ 'phoneNumber'] = databaseFunctions.getAllPatronPhoneNumbers() patronTable['gender'] = databaseFunctions.getAllPatronGenders() patronTable['address'] = databaseFunctions.getAllPatronAddresses() patronTable['city'] = databaseFunctions.getAllPatronCities() patronTable['zipCode'] = databaseFunctions.getAllPatronZipCodes() patronTable['state'] = databaseFunctions.getAllPatronStates() patronTable['waiver'] = databaseFunctions.getAllPatronWaivers() patronTable[ 'isBelayCertified'] = databaseFunctions.getAllPatronBelayCertifications( ) patronTable[ 'belayStartDate'] = databaseFunctions.getAllPatronBelayStartDates( ) patronTable[ 'belayEndDate'] = databaseFunctions.getAllPatronBelayEndDates() patronTable[ 'isLeadClimbCertified'] = databaseFunctions.getAllPatronLeadClimbCertifications( ) patronTable[ 'leadClimbStartDate'] = databaseFunctions.getAllPatronLeadClimbStartDates( ) patronTable[ 'leadClimbEndDate'] = databaseFunctions.getAllPatronLeadClimbEndDates( ) patronTable['isSuspended'] = databaseFunctions.getAllPatronSuspensions( ) patronTable[ 'suspendedStartDate'] = databaseFunctions.getAllPatronSuspensionStartDates( ) patronTable[ 'suspendedEndDate'] = databaseFunctions.getAllPatronSuspensionEndDates( ) patronTable['listServ'] = databaseFunctions.getAllPatronListServ() patronTable[ 'waiverSignDate'] = databaseFunctions.getAllPatronWaiverSignDate() for i in range(len(patronTable['id'])): if float(patronTable['id'][i]) < 0: patronTable['id'][i] = "G" + str(patronTable['id'][i]) patronTable = [ dict(id=i, accountType=aT, firstName=f, lastName=l, email=e, phoneNumber=p, gender=g, address=a, city=c, zipCode=z, state=s, waiver=w, isBelayCertified=b, belayStartDate=bsd, belayEndDate=bed, isLeadClimbCertified=lcc, leadClimbStartDate=lcsd, leadClimbEndDate=lced, isSuspended=su, suspendedStartDate=ss, suspendedEndDate=se, listServ=ls, waiverSignDate=wS) for i, aT, f, l, e, p, g, a, c, z, s, w, b, bsd, bed, lcc, lcsd, lced, su, ss, se, ls, wS in zip( patronTable['id'], patronTable['accountType'], patronTable['firstName'], patronTable['lastName'], patronTable['email'], patronTable['phoneNumber'], patronTable['gender'], patronTable['address'], patronTable['city'], patronTable['zipCode'], patronTable['state'], patronTable['waiver'], patronTable['isBelayCertified'], patronTable['belayStartDate'], patronTable['belayEndDate'], patronTable['isLeadClimbCertified'], patronTable['leadClimbStartDate'], patronTable['leadClimbEndDate'], patronTable['isSuspended'], patronTable['suspendedStartDate'], patronTable['suspendedEndDate'], patronTable['listServ'], patronTable['waiverSignDate']) ] except: patronTable = {} try: visitTable = {} visitTable['Id'] = databaseFunctions.getAllVisitIds() visitTable['PatronId'] = databaseFunctions.getAllVisitPatronIds() visitTable[ 'PatronFirstName'] = databaseFunctions.getAllVisitPatronFirstNames( ) visitTable[ 'PatronLastName'] = databaseFunctions.getAllVisitPatronLastNames() visitTable[ 'PatronVisitDate'] = databaseFunctions.getAllVisitPatronVisitDates( ) visitTable[ 'PatronVisitTime'] = databaseFunctions.getAllVisitPatronVisitTimes( ) for i in range(len(visitTable['PatronId'])): if float(visitTable['PatronId'][i]) < 0: visitTable['PatronId'][i] = "G" + str( visitTable['PatronId'][i]) visitTable = [ dict(id=i, patronId=pI, patronFirstName=f, patronLastName=l, patronVistDate=d, patronVisitTime=t) for i, pI, f, l, d, t in zip(visitTable['Id'], visitTable['PatronId'], visitTable['PatronFirstName'], visitTable['PatronLastName'], visitTable['PatronVisitDate'], visitTable['PatronVisitTime']) ] except: visitTable = {} try: patronMinorTable = {} patronMinorTable[ 'FirstName'] = databaseFunctions.getAllPatronMinorFirstNames() patronMinorTable[ 'LastName'] = databaseFunctions.getAllPatronMinorLastNames() patronMinorTable[ 'PatronId'] = databaseFunctions.getAllPatronMinorPatronIds() for i in range(len(patronMinorTable['PatronId'])): if float(patronMinorTable['PatronId'][i]) < 0: patronMinorTable['PatronId'][i] = "G" + str( patronMinorTable['PatronId'][i]) patronMinorTable = [ dict(firstName=f, lastName=l, patronId=p) for f, l, p in zip( patronMinorTable['FirstName'], patronMinorTable['LastName'], patronMinorTable['PatronId']) ] except: patronMinorTable = {} return render_template('viewPatronManager.html', patronTable=patronTable, visitTable=visitTable, patronMinorTable=patronMinorTable)