From 0d0468e45c94a2df7733837276c4bb788af68632 Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Fri, 7 Jan 2022 00:27:14 +0200 Subject: [PATCH] Add creator --- server/router/fork/index.js | 3 +++ server/router/library/index.js | 1 + server/router/projects/index.js | 4 ++++ server/router/translate/index.js | 4 ++++ server/router/versions/index.js | 2 ++ 5 files changed, 14 insertions(+) diff --git a/server/router/fork/index.js b/server/router/fork/index.js index c9dc0b4..415319e 100644 --- a/server/router/fork/index.js +++ b/server/router/fork/index.js @@ -11,6 +11,7 @@ module.exports = function (options) { if (translationArtifactVersion) { // fork... const forkedTranslationArtifactVersion = await db.TranslationArtifactVersion.create({ + creatorId: request.user.id, name: translationArtifactVersion.name, artifactVersionId: translationArtifactVersion.artifactVersionId, userId: request.user.id, @@ -100,6 +101,7 @@ module.exports = function (options) { if (artifactVersion.translationArtifactVersions.length == 0) { // create a translationArtifactVersion with a new dialect... return db.TranslationArtifactVersion.create({ + creatorId: userId, name: dialect.name, artifactVersionId: artifactVersion.id, dialectId: dialect.id, @@ -108,6 +110,7 @@ module.exports = function (options) { }) } else { return db.TranslationArtifactVersion.create({ + creatorId: userId, name: artifactVersion.translationArtifactVersions[0].name, artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId, userId: userId, diff --git a/server/router/library/index.js b/server/router/library/index.js index 8e8c9ce..4a982ac 100644 --- a/server/router/library/index.js +++ b/server/router/library/index.js @@ -44,6 +44,7 @@ module.exports = function (options) { }).then(dialect => { if (dialect) { return db.Artifact.create({ + creatorId: request.user.id, name: request.body.name, url: request.body.url, dialectId: dialect.id, diff --git a/server/router/projects/index.js b/server/router/projects/index.js index 6a9148e..12082c4 100644 --- a/server/router/projects/index.js +++ b/server/router/projects/index.js @@ -80,6 +80,7 @@ module.exports = function (options) { }) .post(function(request, response, next) { db.Project.create({ + creatorId: request.user.id, name: request.body.name, description: request.body.description, entityId: request.user.individualEntityUser.entityUser.entityId @@ -175,6 +176,7 @@ module.exports = function (options) { if (artifactVersion) { const projectArtifactVersion = db.ProjectArtifactVersion.create({ + creatorId: request.user.id, projectId: project.id, artifactVersionId: artifactVersion.id }) @@ -260,6 +262,7 @@ module.exports = function (options) { if (translationArtifactVersion) { const projectTranslationArtifactVersion = db.ProjectTranslationArtifactVersion.create({ + creatorId: request.user.id, projectId: project.id, translationArtifactVersionId: translationArtifactVersion.id }) @@ -407,6 +410,7 @@ module.exports = function (options) { } }) const campaign = await db.Campaign.create({ + creatorId: request.user.id, name: request.body.name, description: request.body.description, // defaultSatoshis: [request.body.satoshis].flat()[0], diff --git a/server/router/translate/index.js b/server/router/translate/index.js index 3b42c02..0edb22f 100644 --- a/server/router/translate/index.js +++ b/server/router/translate/index.js @@ -194,6 +194,7 @@ module.exports = function (options) { await chunk.translation.save() } else { translation = await db.Translation.create({ + creatorId: request.user.id, chunkId: chunk.id, text: request.body.translatedText, translationArtifactVersionId: request.params.id @@ -249,6 +250,7 @@ module.exports = function (options) { // TODO: Create a backTranslation... backTranslatedArtifact = {} return db.BackTranslation.create({ + creatorId: request.user.id, translationArtifactVersionId: translationArtifactVersion.id, artifact: { name: translationArtifactVersion.name + translationArtifactVersion.artifactVersion.artifact.name, @@ -413,6 +415,7 @@ module.exports = function (options) { if (translationArtifactVersion) { // TODO: Create campaign... const campaign = await db.Campaign.create({ + creatorId: request.user.id, name: request.body.name, description: request.body.description, // defaultSatoshis: [request.body.satoshis].flat()[0], @@ -537,6 +540,7 @@ module.exports = function (options) { if (translationArtifactVersion) { // TODO: Create campaign... const pledge = await db.Pledge.create({ + creatorId: request.user.id, message: request.body.message, entityId: request.user.individualEntityUser.entityUser.entityId, translationArtifactVersionPledges: [ diff --git a/server/router/versions/index.js b/server/router/versions/index.js index b5bf222..fab4290 100644 --- a/server/router/versions/index.js +++ b/server/router/versions/index.js @@ -90,6 +90,7 @@ module.exports = function (options) { if (artifactVersion && isString) { const chunks = request.body.text.trim().split(/\r?\n\r?\n/) db.Chapter.create({ + creatorId: request.user.id, name: chunks[0].trim(), artifactVersionId: artifactVersion.id, chunks: chunks.map((chunk,index) => { @@ -250,6 +251,7 @@ module.exports = function (options) { if (dialect) { const translationArtifactVersion = await db.TranslationArtifactVersion.create({ + creatorId: request.user.id, name: dialect.name, artifactVersionId: artifactVersion.id, dialectId: dialect.id,