def getProjectList(self): activeAuthToken = AuthModule.validateCookie() activeUserData = DivcoDataStore.getUserByLoginSession(activeAuthToken) projectList = self.getAllUserProject(activeUserData.key.id) return jsonResponse(projectList, activeAuthToken)
def deleteProject(self): activeAuthToken = AuthModule.validateCookie() activeUserData = DivcoDataStore.getUserByLoginSession(activeAuthToken) rawData = flask.request.form projectID = int(rawData.get("projectID")) DivcoDataStore.clearProject(projectID) return jsonResponse({ "msg" : "projectDeleted" }, activeAuthToken)
def createNewProject(self): activeAuthToken = AuthModule.validateCookie() activeUserData = DivcoDataStore.getUserByLoginSession(activeAuthToken) rawData = flask.request.form name = rawData.get("name") pID = DivcoDataStore.createNewProject(activeUserData.key.id, name) return jsonResponse({ "msg" : "projectCreated", "debug" : pID }, activeAuthToken)
def getUserData(self): authToken = AuthModule.validateCookie(True) if authToken != None: activeUserData = DivcoDataStore.getUserByLoginSession(authToken) if activeUserData: activeUser = {"userID": activeUserData.key.id, "userName" : activeUserData["name"]} else: activeUser = {} else: activeUser = {} return jsonResponse(activeUser, 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)