Ejemplo n.º 1
0
def users_user_id_get(userId):
    """ method to retrieve user using user id """
    try:
        user = User.get(userId)
        buildings = Building.scan(ownerId__eq=userId)
        #add ownedBuildings to the user object without having it reflect in the model
        user.__dict__["attribute_values"].update({"ownedBuildings": []}) 
        #look at all the builings the user owns
        for building in buildings:
            #add the builings to the ownedBuildings list
            user.__dict__["attribute_values"]["ownedBuildings"].append(building.attribute_values["id"])
    except Exception as inst:
        print(inst.args)
        return 'User with id=%s does not exist.' % (userId)
    return user.attribute_values
Ejemplo n.º 2
0
def users_user_id_get(userId):
    """ method to retrieve user using user id """
    try:
        user = User.get(userId)
        buildings = Building.scan(ownerId__eq=userId)
        #add ownedBuildings to the user object without having it reflect in the model
        user.__dict__["attribute_values"].update({"ownedBuildings": []})
        #look at all the builings the user owns
        for building in buildings:
            #add the builings to the ownedBuildings list
            user.__dict__["attribute_values"]["ownedBuildings"].append(
                building.attribute_values["id"])
    except Exception as inst:
        print(inst.args)
        return 'User with id=%s does not exist.' % (userId)
    return user.attribute_values
Ejemplo n.º 3
0
def buildings_get() -> str:
    resultList = []
    for item in Building.scan():
        resultList.append(item.attribute_values)
    return resultList
Ejemplo n.º 4
0
def buildings_delete() -> str:
    temp = []
    for item in Building.scan():
        temp.append(item.delete())
    return "%s items deleted." % len(temp)
def buildings_get():
    """ method to get all buildings """
    resultlist = []	
    for item in Building.scan():
        resultlist.append(item.attribute_values)
    return resultlist
def buildings_delete():
    """ method to delete all buildings """
    temp = []
    for item in Building.scan():
        temp.append(item.delete())
    return "%s items deleted." % len(temp)
Ejemplo n.º 7
0
def buildings_get():
    """ method to get all buildings """
    resultlist = []
    for item in Building.scan():
        resultlist.append(item.attribute_values)
    return resultlist
Ejemplo n.º 8
0
def buildings_delete():
    """ method to delete all buildings """
    temp = []
    for item in Building.scan():
        temp.append(item.delete())
    return "%s items deleted." % len(temp)
Ejemplo n.º 9
0
def buildings_get() -> str:
    resultList = []
    for item in Building.scan():
        resultList.append(item.attribute_values)
    return resultList
Ejemplo n.º 10
0
def buildings_delete() -> str:
    temp = []
    for item in Building.scan():
        temp.append(item.delete())
    return "%s items deleted." % len(temp)