def create(): o = json.load(request.body) user_name = o['userName'] name = o['name'] description = o['description'] layers = o['layers'] point = o['point'] overlays = o['overlays'] baselayer = o['baselayer'] user_name = o['userName'] ws = model.Workspace() ws.name = name ws.description = description ws.layers = layers ws.overlays = overlays ws.baselayer = baselayer ws.user_name = user_name ws.point = WKTSpatialElement(Point(point['x'], point['y']).wkt,96) ws.public = True ws.date = datetime.now() repo.Workspace(db_session).create_update(ws) repo_user = repo.User(db_session) user = repo_user.read(user_name) user.workspaces.append(ws) repo_user.create_update(user) return vo.success(True)
def update(): o = json.load(request.body) id = o['id'] name = o['name'] description = o['description'] layers = o['layers'] point = o['point'] overlays = o['overlays'] baselayer = o['baselayer'] repo_ws = repo.Workspace(db_session) ws = repo_ws.read(id) ws.name = name ws.description = description ws.layers = layers ws.overlays = overlays ws.baselayer = baselayer ws.point = WKTSpatialElement(Point(point['x'], point['y']).wkt,96) ws.public = True ws.date = datetime.now() repo_ws.create_update(ws) return vo.success(True)
def delete(id): repo_ws= repo.Workspace(db_session) ws = repo_ws.read(id) repo_ws.delete(ws) return vo.success(True)