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