def buildings_post():
    """ method to post a new building """
    #body = request.get_data()
    #body = json.loads(body.decode("utf-8"))
    newid = str(uuid.uuid4())
    newobj = Building(id=newid)
    #if body["ownerId"]:
    #    newobj.ownerId = body["ownerId"]
    newobj.save()
    return newobj.attribute_values
Ejemplo n.º 2
0
def buildings_post():
    """ method to post a new building """
    body = request.get_data()
    body = json.loads(body.decode("utf-8"))
    
    # Check that the owner exists
#    try:
#    	owner = User.get(body["ownerId"])
#    except Excpetion as e:
#    	return 'The owner specified does not exist'
    
    newid = str(uuid.uuid4())
    newobj = Building(id=newid)
    if "ownerId" in body:
        newobj.ownerId = body["ownerId"]
    newobj.save()
    return newobj.attribute_values
Ejemplo n.º 3
0
def buildings_post():
    """ method to post a new building """
    body = request.get_data()
    body = json.loads(body.decode("utf-8"))

    # Check that the owner exists
    #    try:
    #    	owner = User.get(body["ownerId"])
    #    except Excpetion as e:
    #    	return 'The owner specified does not exist'

    newid = str(uuid.uuid4())
    newobj = Building(id=newid)
    if "ownerId" in body:
        newobj.ownerId = body["ownerId"]
    newobj.save()
    return newobj.attribute_values
Ejemplo n.º 4
0
def buildings_post() -> str:
    newID = str(uuid.uuid4())
    newObj = Building(id=newID)
    newObj.save()
    return newObj.attribute_values
Ejemplo n.º 5
0
from storageModels import Sensor, Building

mySens = Sensor(sensorId='yet another id',
                sensorType='type',
                buildingId='theHASH',
                roomId='another hash',
                data=['data', 'moredata'])
mySens.save()

newBuilding = Building(id='one other id something',
                       buildingId='1',
                       building='Franks shop',
                       rooms=['a', 'b'],
                       owner=1,
                       users=['a', 'b'],
                       sensors=['a', 'b'],
                       robots=['a', 'b'])
newBuilding.save()
Ejemplo n.º 6
0
def buildings_post() -> str:
    newID = str(uuid.uuid4())
    newObj = Building(id=newID)
    newObj.save()
    return newObj.attribute_values
Ejemplo n.º 7
0
from storageModels import Sensor, Building


mySens = Sensor(sensorId = 'yet another id',
                sensorType='type',
                buildingId = 'theHASH',
                roomId = 'another hash',
                data=['data', 'moredata'])
mySens.save()


newBuilding = Building(id = 'one other id something',
                       buildingId = '1',
                       building='Franks shop',
                       rooms = ['a', 'b'],
                       owner = 1,
                       users = ['a', 'b'],
                       sensors = ['a', 'b'],
                       robots = ['a', 'b'])
newBuilding.save()