def display(date, tab): """ Displays the calendar page """ standardSlots = ["08:00AM", "08:15AM", "08:30AM", "08:45AM", "09:00AM", "09:15AM", "09:30AM", "09:45AM", "10:00AM", "10:15AM", "10:30AM", "10:45AM", "11:00AM", "11:15AM", "11:30AM", "11:45AM", "12:00PM", "12:15PM", "12:30PM", "12:45PM", "01:00PM", "01:15PM", "01:30PM", "01:45PM", "02:00PM", "02:15PM", "02:30PM", "02:45PM", "03:00PM", "03:15PM", "03:30PM", "03:45PM", "04:00PM", "04:15PM", "04:30PM", "04:45PM", "05:00PM", "05:15PM", "05:30PM", "05:45PM", "06:00PM", "06:15PM", "06:30PM", "06:45PM", "07:00PM"] schedule = [] #list of dicts of lists, days -> timeslot -> appointment list locations = None roles = None for day in range(util.DAYS_IN_WEEK): schedule.append({}) #the beginning of the week - the week is either given or the current week is used startDate = util.startOfWeek(util.toDatetime(date) if date else util.today()) tab = int(tab) #build a list of maps of time to appointments with some default values #prepopulated so they are always displayed for day in schedule: for timeslot in standardSlots: day[timeslot] = [] #get a database connection conn = services.getConnection() #get all the locations and roles locations = services.getLocations(conn) roles = sorted(services.getRoles(conn)) #get all the appointments for the week and add them to the schedule for appointment in services.getAppointments(conn, startDate): time = appointment.getFTime() weekday = appointment.time.weekday() #if the appointment is not scheduled for one of the standard times #then add that time slot if time not in schedule[weekday]: schedule[weekday][time] = [] schedule[weekday][time].append(appointment) conn.close() #format and return the page return build(locations, roles, schedule, startDate, tab)
def display(): """ Displays a list of all the staff members """ connection = services.getConnection() roleMap = {} #build role map for role in services.getRoles(connection): roleMap[role.roleId] = role.name #get all the staff staffList = services.getAllStaff(connection) connection.close() return _render(staffList, roleMap)
def run(): #YYYY-MM-DD HH:MM:SS #--------------------------SETUP------------------------------------------ conn = services.getConnection() staff = [ model.staff.StaffMember("test1", 1, False), model.staff.StaffMember("test2", 1, True), model.staff.StaffMember("test3", 2, True) ] apps = [ model.appointment.Appointment("2010-12-25 11:00:00", "test1", "Albany"), model.appointment.Appointment("2010-12-23 00:00:00", "test1", "Corvallis"), model.appointment.Appointment("2010-12-21 00:00:00", "test2", "Albany"), model.appointment.Appointment(util.toDatetime("2010-12-25 00:00:00"), "test3", "Albany"), model.appointment.Appointment("2010-12-24 00:00:00", "test3", "Corvallis"), model.appointment.Appointment("2010-11-24 00:00:00", "test3", "Corvallis") ] objs = [] for a in apps: services.deleteAppointment(conn, a.time, a.staffName) for s in staff: services.deleteStaff(conn, s.name) for s in staff: objs.append(s) for a in apps: objs.append(a) for o in objs: o.flush(conn) #-----------------------------ALL STAFF----------------------------------- #all staff results = filterList( services.getAllStaff(conn), staff ) print "all staff", len(results) == 3 #only role 1 results = filterList( services.getAllStaff(conn, roleId = 1), staff ) print "role 1 staff", len(results) == 2 #only active results = filterList( services.getAllStaff(conn, active=True), staff ) print "active staff", len(results) == 2 #only inactive, role 1 results = filterList( services.getAllStaff(conn, active=False, roleId = 1), staff ) print "inactive, role 1 staff", len(results) == 1 #------------------------------ALL APPOINTMENTS--------------------------- #all appointments results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00"))), apps ) print "all appointments", len(results) == 5 #only role 1 results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00")), roleId = 1), apps ) print "role 1 appointments", len(results) == 3 #only Albany results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00")), location = "Albany"), apps ) print "Albany appointments", len(results) == 3 #only Corvallis role 2 results = filterList( services.getAppointments(conn, util.startOfWeek(util.toDatetime("2010-12-25 00:00:00")), location = "Corvallis", roleId = 2), apps ) print "role 2 corvallis appointments", len(results) == 1 #---------------------------------ROLES------------------------------------- print "3 Roles found", len( services.getRoles(conn) ) == 3 #---------------------------CLEAN UP-------------------------------------- for a in apps: services.deleteAppointment(conn, a.time, a.staffName) for s in staff: services.deleteStaff(conn, s.name)