Adding owner (for multiple enity association)
This commit is contained in:
@@ -40,7 +40,13 @@ module.exports = function (options) {
|
|||||||
userId: request.user.id,
|
userId: request.user.id,
|
||||||
dialectId: translationArtifactVersion.dialectId,
|
dialectId: translationArtifactVersion.dialectId,
|
||||||
forkedFromId: translationArtifactVersion.id,
|
forkedFromId: translationArtifactVersion.id,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
||||||
return {
|
return {
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
@@ -73,6 +79,14 @@ module.exports = function (options) {
|
|||||||
association: db.TranslationChapter.TranslationChunks,
|
association: db.TranslationChapter.TranslationChunks,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -163,7 +177,24 @@ module.exports = function (options) {
|
|||||||
artifactVersionId: artifactVersion.id,
|
artifactVersionId: artifactVersion.id,
|
||||||
dialectId: dialect.id,
|
dialectId: dialect.id,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
entityId: entityId
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return db.TranslationArtifactVersion.create({
|
return db.TranslationArtifactVersion.create({
|
||||||
@@ -172,7 +203,25 @@ module.exports = function (options) {
|
|||||||
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
|
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
dialectId: artifactVersion.translationArtifactVersions[0].dialectId,
|
dialectId: artifactVersion.translationArtifactVersions[0].dialectId,
|
||||||
forkedFromId: artifactVersion.translationArtifactVersions[0].id
|
forkedFromId: artifactVersion.translationArtifactVersions[0].id,
|
||||||
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,12 +55,26 @@ module.exports = function (options) {
|
|||||||
tag: request.body.version
|
tag: request.body.version
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Artifact.ArtifactVersions,
|
association: db.Artifact.ArtifactVersions,
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Artifact.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -83,7 +83,24 @@ module.exports = function (options) {
|
|||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
name: request.body.name,
|
name: request.body.name,
|
||||||
description: request.body.description,
|
description: request.body.description,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Project.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}).then(project => {
|
}).then(project => {
|
||||||
if (project) {
|
if (project) {
|
||||||
response.redirect(`/projects/${project.id}`)
|
response.redirect(`/projects/${project.id}`)
|
||||||
@@ -424,7 +441,13 @@ module.exports = function (options) {
|
|||||||
return {
|
return {
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
translationArtifactVersionId: projectTranslationArtifactVersion.translationArtifactVersionId,
|
translationArtifactVersionId: projectTranslationArtifactVersion.translationArtifactVersionId,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
satoshis: request.body.satoshis
|
satoshis: request.body.satoshis
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -434,12 +457,36 @@ module.exports = function (options) {
|
|||||||
description: request.body.description,
|
description: request.body.description,
|
||||||
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
||||||
defaultSatoshis: request.body.satoshis,
|
defaultSatoshis: request.body.satoshis,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
translationArtifactVersionCampaigns: translationArtifactVersionCampaigns
|
translationArtifactVersionCampaigns: translationArtifactVersionCampaigns
|
||||||
}, {
|
}, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Campaign.TranslationArtifactVersionCampaigns
|
association: db.Campaign.TranslationArtifactVersionCampaigns,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersionCampaign.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Campaign.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -308,7 +308,13 @@ module.exports = function (options) {
|
|||||||
artifactVersionId: translationArtifactVersion.artifactVersionId,
|
artifactVersionId: translationArtifactVersion.artifactVersionId,
|
||||||
dialectId: translationArtifactVersion.dialect.id,
|
dialectId: translationArtifactVersion.dialect.id,
|
||||||
backTranslationFromId: translationArtifactVersion.id,
|
backTranslationFromId: translationArtifactVersion.id,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
||||||
return {
|
return {
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
@@ -332,6 +338,14 @@ module.exports = function (options) {
|
|||||||
association: db.TranslationChapter.TranslationChunks
|
association: db.TranslationChapter.TranslationChunks
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersionCampaign.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -450,19 +464,49 @@ module.exports = function (options) {
|
|||||||
description: request.body.description,
|
description: request.body.description,
|
||||||
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
||||||
defaultSatoshis: request.body.satoshis,
|
defaultSatoshis: request.body.satoshis,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
translationArtifactVersionCampaigns: [
|
translationArtifactVersionCampaigns: [
|
||||||
{
|
{
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
translationArtifactVersionId: translationArtifactVersion.id,
|
translationArtifactVersionId: translationArtifactVersion.id,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
satoshis: request.body.satoshis
|
satoshis: request.body.satoshis
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Campaign.TranslationArtifactVersionCampaigns
|
association: db.Campaign.TranslationArtifactVersionCampaigns,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersionCampaign.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Campaign.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
@@ -573,19 +617,49 @@ module.exports = function (options) {
|
|||||||
const pledge = await db.Pledge.create({
|
const pledge = await db.Pledge.create({
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
message: request.body.message,
|
message: request.body.message,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
translationArtifactVersionPledges: [
|
translationArtifactVersionPledges: [
|
||||||
{
|
{
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
translationArtifactVersionId: translationArtifactVersion.id,
|
translationArtifactVersionId: translationArtifactVersion.id,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
satoshis: request.body.satoshis
|
satoshis: request.body.satoshis
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, {
|
}, {
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Pledge.TranslationArtifactVersionPledges
|
association: db.Pledge.TranslationArtifactVersionPledges,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersionPledge.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Pledge.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -286,7 +286,13 @@ module.exports = function (options) {
|
|||||||
name: dialect.name,
|
name: dialect.name,
|
||||||
artifactVersionId: artifactVersion.id,
|
artifactVersionId: artifactVersion.id,
|
||||||
dialectId: dialect.id,
|
dialectId: dialect.id,
|
||||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
owner: {
|
||||||
|
ownerEntities: [
|
||||||
|
{
|
||||||
|
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
translationChapters: artifactVersion.chapters.map(chapter => {
|
translationChapters: artifactVersion.chapters.map(chapter => {
|
||||||
return {
|
return {
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
@@ -310,6 +316,14 @@ module.exports = function (options) {
|
|||||||
association: db.TranslationChapter.TranslationChunks
|
association: db.TranslationChapter.TranslationChunks
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersionPledge.Owner,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user