Adding owner (for multiple enity association)
This commit is contained in:
@@ -40,7 +40,13 @@ module.exports = function (options) {
|
||||
userId: request.user.id,
|
||||
dialectId: translationArtifactVersion.dialectId,
|
||||
forkedFromId: translationArtifactVersion.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
@@ -73,6 +79,14 @@ module.exports = function (options) {
|
||||
association: db.TranslationChapter.TranslationChunks,
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
@@ -163,7 +177,24 @@ module.exports = function (options) {
|
||||
artifactVersionId: artifactVersion.id,
|
||||
dialectId: dialect.id,
|
||||
userId: userId,
|
||||
entityId: entityId
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: entityId,
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
} else {
|
||||
return db.TranslationArtifactVersion.create({
|
||||
@@ -172,7 +203,25 @@ module.exports = function (options) {
|
||||
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
|
||||
userId: userId,
|
||||
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
|
||||
}
|
||||
],
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
}
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
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,
|
||||
name: request.body.name,
|
||||
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 => {
|
||||
if (project) {
|
||||
response.redirect(`/projects/${project.id}`)
|
||||
@@ -424,7 +441,13 @@ module.exports = function (options) {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
translationArtifactVersionId: projectTranslationArtifactVersion.translationArtifactVersionId,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
satoshis: request.body.satoshis
|
||||
}
|
||||
})
|
||||
@@ -434,12 +457,36 @@ module.exports = function (options) {
|
||||
description: request.body.description,
|
||||
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
||||
defaultSatoshis: request.body.satoshis,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
translationArtifactVersionCampaigns: translationArtifactVersionCampaigns
|
||||
}, {
|
||||
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,
|
||||
dialectId: translationArtifactVersion.dialect.id,
|
||||
backTranslationFromId: translationArtifactVersion.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
translationChapters: translationArtifactVersion.translationChapters.map(translationChapter => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
@@ -332,6 +338,14 @@ module.exports = function (options) {
|
||||
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,
|
||||
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
||||
defaultSatoshis: request.body.satoshis,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
translationArtifactVersionCampaigns: [
|
||||
{
|
||||
creatorId: request.user.id,
|
||||
translationArtifactVersionId: translationArtifactVersion.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
satoshis: request.body.satoshis
|
||||
}
|
||||
]
|
||||
}, {
|
||||
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({
|
||||
creatorId: request.user.id,
|
||||
message: request.body.message,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
}
|
||||
]
|
||||
},
|
||||
translationArtifactVersionPledges: [
|
||||
{
|
||||
creatorId: request.user.id,
|
||||
translationArtifactVersionId: translationArtifactVersion.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
satoshis: request.body.satoshis
|
||||
}
|
||||
]
|
||||
}, {
|
||||
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,
|
||||
artifactVersionId: artifactVersion.id,
|
||||
dialectId: dialect.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
owner: {
|
||||
ownerEntities: [
|
||||
{
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
}
|
||||
]
|
||||
},
|
||||
translationChapters: artifactVersion.chapters.map(chapter => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
@@ -310,6 +316,14 @@ module.exports = function (options) {
|
||||
association: db.TranslationChapter.TranslationChunks
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersionPledge.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user