Example #1
0
def run():
    dbConn = services.getConnection()

    # clear outs existing employees
    services.deleteStaff(dbConn, "test1")
    services.deleteStaff(dbConn, "test2")

    # create a new employee
    first = model.staff.StaffMember("test1", 1, True, "street", "city", "OR", "zip", "phone")

    first.flush(dbConn)

    # check if it is created
    firstCheck = services.getStaff(dbConn, "test1")

    print "created", first
    print "found  ", firstCheck
    print "created and found ", first == firstCheck

    # update employee
    first.name = "test2"
    first.roleId = 2
    first.isActive = False
    first.street = "newStreet"
    first.city = "newCity"
    first.state = "WA"
    first.zip = "newZip"
    first.phone = "newPhone"

    first.flush(dbConn, "test1")

    secondCheck = services.getStaff(dbConn, "test2")

    print "updated", first
    print "found  ", secondCheck
    print "updated and found ", first == secondCheck

    # delete employee
    services.deleteStaff(dbConn, "test2")

    thirdCheck = services.getStaff(dbConn, "test2")

    print "deleted and gone ", thirdCheck == None

    dbConn.close()
Example #2
0
def isNameConflict(name):
	"""
	Returns an html snipit saying whether or not there is a staff member with the same name
	"""
	result = ""
	connection = services.getConnection()
	
	#look for any conflict
	staff = services.getStaff(connection, name)
	
	#if there is a conflict return an error message
	if staff:
		result = "There is already a staff member named %s" % name
		
	return result