def hackspace(): rawData = flask.request.form projectID = 11 updateJsonString = json.dumps({"tileIDList": [5], "layerID": 2}) entryType = "updateTile" returnMessage = DivcoDataStore.addToProjectHistory(projectID, entryType, updateJsonString) print(updateJsonString) response = {} response["result"] = returnMessage["status"] return jsonResponse(response) ## DO ONCE FOR SERVER SETUP # DivcoDataStore.initDivco() # CREATE NEW PROJECT # CLEAR AND RESET PROJECT # DivcoDataStore.initDivco() # doReset = True # if doReset: ## TEST FLOW # entryType = "createTile" # rawEntryArgs = r'{"label":"tile_1","parentID":null}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "createTile" # rawEntryArgs = r'{"label":"tile_2","parentID":1}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "updateTile" # rawEntryArgs = r'{"tileID":1,"label":"TILE_1","status":3}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "deleteTile" # rawEntryArgs = r'{"tileID":2}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "createTile" # rawEntryArgs = r'{"label":"tile_3","parentID":1}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "createTile" # rawEntryArgs = r'{"label":"tile_4","parentID":1}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "createTile" # rawEntryArgs = r'{"label":"tile_5","parentID":1}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) # entryType = "reorderTile" # rawEntryArgs = r'{"tileID":5,"order":1}' # DivcoDataStore.addToProjectHistory(pID, entryType, rawEntryArgs) response = {} return jsonResponse(response)
def updateTile(): authToken = AuthModule.validateCookie() rawData = flask.request.form projectID = int(rawData.get("projectID")) updateJsonString = rawData.get("tileData") entryType = "updateTile" returnMessage = DivcoDataStore.addToProjectHistory(projectID, entryType, updateJsonString) response = {} response["result"] = returnMessage["status"] return jsonResponse(response, authToken)
def importProject(pID): authToken = AuthModule.validateCookie() DivcoDataStore.clearProject(pID) activeUserData = DivcoDataStore.getUserByLoginSession(authToken) DivcoDataStore.createNewProject(activeUserData.key.id, "Stub", pID) rawData = flask.request.form projectHistory = rawData.get("projectHistory") maxUsedTileID = 0 reader = csv.reader(io.StringIO(projectHistory)) next(reader) for i, row in enumerate(reader): entryType = row[1] entryArgs = row[2] entryTileID = json.loads(entryArgs).get("tileID") if entryTileID: maxUsedTileID = max(entryTileID, maxUsedTileID) if i % 20 == 0: print(i, entryType, entryArgs) DivcoDataStore.addToProjectHistory(pID, entryType, entryArgs) with DSC.transaction(): projectMetaItem = DSC.get(DSC.key('projectMeta', pID)) projectMetaItem.update({'tileCounter': maxUsedTileID}) DSC.put(projectMetaItem) response = {} response["debug"] = projectHistory return jsonResponse(response)
def createTile(): authToken = AuthModule.validateCookie() rawData = flask.request.form projectID = int(rawData.get("projectID")) updateJsonString = rawData.get("tileData") entryType = "createTile" returnMessage = DivcoDataStore.addToProjectHistory(projectID, entryType, updateJsonString) transTileChange = map(lambda node: DivcoDataStore.getTransFormat(node), returnMessage["tileChange"]) response = {} response["result"] = returnMessage["status"] response["dataChange"] = list(transTileChange) return jsonResponse(response, authToken)