def getAllByEmployeeKeyUrlSafe(employeeKeyUrlSafe): accounts = ( AccountManager.query(AccountManager.employeeKeyUrlSafe == employeeKeyUrlSafe) .order(AccountManager.clientKeyUrlSafe) .fetch() ) return accounts
def update(request): employeeKeyUrlSafe = request.get("employeeKeyUrlSafe") accounts = AccountManagerService.getAll() # first delete all accounts associated with this employee for account in accounts: if account.employeeKeyUrlSafe == employeeKeyUrlSafe: accountKey = account.key accountKey.delete() # then add all accounts to be associated with this employee clients = ClientService.getAll() for client in clients: for i in range(len(clients)): currentClientKeyUrlSafe = request.get("client" + str(i)) if currentClientKeyUrlSafe == client.key.urlsafe(): account = AccountManager() account.clientKeyUrlSafe = client.key.urlsafe() account.employeeKeyUrlSafe = employeeKeyUrlSafe account.put() time.sleep(sleepTime)
def getAll(): accounts = AccountManager.query().order(AccountManager.clientKeyUrlSafe).fetch() return accounts