Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)