Beispiel #1
0
    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)
Beispiel #2
0
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)