Replace entry with artifact and add entity
This commit is contained in:
@@ -30,7 +30,7 @@ module.exports = function (options) {
|
||||
]
|
||||
}).then(user => {
|
||||
if (user) {
|
||||
// TODO: Check if user already created a password reset entry to save on a db transaction
|
||||
// TODO: Check if user already created a password reset artifact to save on a db transaction
|
||||
return Promise.all([
|
||||
user.userEmails[0],
|
||||
user.userPasswordReset ? user.userPasswordReset : db.UserPasswordReset.create({
|
||||
@@ -84,7 +84,7 @@ module.exports = function (options) {
|
||||
pageTitle: "Password Reset Initiated - Mantra"
|
||||
})
|
||||
} else {
|
||||
next(`Failed to create a user password reset entry (user ${request.body.email} doesn't exist)`)
|
||||
next(`Failed to create a user password reset artifact (user ${request.body.email} doesn't exist)`)
|
||||
}
|
||||
}).catch (error => {
|
||||
next(error)
|
||||
|
||||
@@ -6,19 +6,19 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/t/:id')
|
||||
.post(function(request, response, next) {
|
||||
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||
}).then(async (translationEntryVersion) => {
|
||||
if (translationEntryVersion) {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
}).then(async (translationArtifactVersion) => {
|
||||
if (translationArtifactVersion) {
|
||||
// fork...
|
||||
const forkedTranslationEntryVersion = await db.TranslationEntryVersion.create({
|
||||
name: translationEntryVersion.name,
|
||||
entryVersionId: translationEntryVersion.entryVersionId,
|
||||
const forkedTranslationArtifactVersion = await db.TranslationArtifactVersion.create({
|
||||
name: translationArtifactVersion.name,
|
||||
artifactVersionId: translationArtifactVersion.artifactVersionId,
|
||||
userId: request.user.id,
|
||||
dialectId: translationEntryVersion.dialectId,
|
||||
forkedFromId: translationEntryVersion.id
|
||||
dialectId: translationArtifactVersion.dialectId,
|
||||
forkedFromId: translationArtifactVersion.id
|
||||
})
|
||||
if (forkedTranslationEntryVersion) {
|
||||
return response.redirect(`/v/${forkedTranslationEntryVersion.entryVersionId}/translations/${forkedTranslationEntryVersion.id}`)
|
||||
if (forkedTranslationArtifactVersion) {
|
||||
return response.redirect(`/v/${forkedTranslationArtifactVersion.artifactVersionId}/translations/${forkedTranslationArtifactVersion.id}`)
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
@@ -30,18 +30,18 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/e/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}).then(entryVersion => {
|
||||
if (entryVersion) {
|
||||
response.display("fork-entry-version", {
|
||||
}).then(artifactVersion => {
|
||||
if (artifactVersion) {
|
||||
response.display("fork-artifact-version", {
|
||||
user: request.user,
|
||||
pageTitle: "Add translation - Mantra",
|
||||
entryVersion: entryVersion
|
||||
artifactVersion: artifactVersion
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
@@ -64,13 +64,13 @@ module.exports = function (options) {
|
||||
})
|
||||
|
||||
if (dialect) {
|
||||
const entryVersion = await db.EntryVersion.findByPk(request.params.id, {
|
||||
const artifactVersion = await db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions,
|
||||
required: false,
|
||||
where: {
|
||||
dialectId: dialect.id,
|
||||
@@ -79,10 +79,10 @@ module.exports = function (options) {
|
||||
]
|
||||
})
|
||||
|
||||
if (entryVersion) {
|
||||
const forkedTranslationEntryVersion = await forkEntryVersion(entryVersion, dialect, request.user.id)
|
||||
if (forkedTranslationEntryVersion) {
|
||||
return response.redirect(`/v/${forkedTranslationEntryVersion.entryVersionId}/translations/${forkedTranslationEntryVersion.id}`)
|
||||
if (artifactVersion) {
|
||||
const forkedTranslationArtifactVersion = await forkArtifactVersion(artifactVersion, dialect, request.user.id)
|
||||
if (forkedTranslationArtifactVersion) {
|
||||
return response.redirect(`/v/${forkedTranslationArtifactVersion.artifactVersionId}/translations/${forkedTranslationArtifactVersion.id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,22 +90,22 @@ module.exports = function (options) {
|
||||
next()
|
||||
})
|
||||
|
||||
const forkEntryVersion = (entryVersion, dialect, userId) => {
|
||||
if (entryVersion.translationEntryVersions.length == 0) {
|
||||
// create a translationEntryVersion with a new dialect...
|
||||
return db.TranslationEntryVersion.create({
|
||||
const forkArtifactVersion = (artifactVersion, dialect, userId) => {
|
||||
if (artifactVersion.translationArtifactVersions.length == 0) {
|
||||
// create a translationArtifactVersion with a new dialect...
|
||||
return db.TranslationArtifactVersion.create({
|
||||
name: dialect.name,
|
||||
entryVersionId: entryVersion.id,
|
||||
artifactVersionId: artifactVersion.id,
|
||||
dialectId: dialect.id,
|
||||
userId: userId,
|
||||
})
|
||||
} else {
|
||||
return db.TranslationEntryVersion.create({
|
||||
name: entryVersion.translationEntryVersions[0].name,
|
||||
entryVersionId: entryVersion.translationEntryVersions[0].entryVersionId,
|
||||
return db.TranslationArtifactVersion.create({
|
||||
name: artifactVersion.translationArtifactVersions[0].name,
|
||||
artifactVersionId: artifactVersion.translationArtifactVersions[0].artifactVersionId,
|
||||
userId: userId,
|
||||
dialectId: entryVersion.translationEntryVersions[0].dialectId,
|
||||
forkedFromId: entryVersion.translationEntryVersions[0].id
|
||||
dialectId: artifactVersion.translationArtifactVersions[0].dialectId,
|
||||
forkedFromId: artifactVersion.translationArtifactVersions[0].id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/')
|
||||
.get(function(request, response, next) {
|
||||
db.Entry.findAll({
|
||||
db.Artifact.findAll({
|
||||
|
||||
}).then(entries => {
|
||||
response.display("library", {
|
||||
@@ -26,7 +26,7 @@ module.exports = function (options) {
|
||||
response.display("library-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Add Library - Mantra",
|
||||
entry: {
|
||||
artifact: {
|
||||
version: "1.0"
|
||||
}
|
||||
})
|
||||
@@ -43,20 +43,21 @@ module.exports = function (options) {
|
||||
}
|
||||
}).then(dialect => {
|
||||
if (dialect) {
|
||||
return db.Entry.create({
|
||||
return db.Artifact.create({
|
||||
name: request.body.name,
|
||||
url: request.body.url,
|
||||
dialectId: dialect.id,
|
||||
licenseId: "copyright",
|
||||
entryVersions: [
|
||||
artifactVersions: [
|
||||
{
|
||||
tag: request.body.version
|
||||
}
|
||||
]
|
||||
],
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryVersions,
|
||||
association: db.Artifact.ArtifactVersions,
|
||||
|
||||
}
|
||||
]
|
||||
@@ -65,9 +66,9 @@ module.exports = function (options) {
|
||||
response.redirect("/library/add") // TODO: Show error message on missing dialect...
|
||||
}
|
||||
|
||||
}).then(entry => {
|
||||
if (entry) {
|
||||
response.redirect(`/library/${entry.id}`)
|
||||
}).then(artifact => {
|
||||
if (artifact) {
|
||||
response.redirect(`/library/${artifact.id}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
@@ -82,24 +83,24 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.Entry.findByPk(request.params.id, {
|
||||
db.Artifact.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
},
|
||||
{
|
||||
association: db.Entry.EntryVersions
|
||||
association: db.Artifact.ArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(entry => {
|
||||
if (entry) {
|
||||
if (entry.entryVersions.length == 1) {
|
||||
response.redirect(`/v/${entry.entryVersions[0].id}`)
|
||||
}).then(artifact => {
|
||||
if (artifact) {
|
||||
if (artifact.artifactVersions.length == 1) {
|
||||
response.redirect(`/v/${artifact.artifactVersions[0].id}`)
|
||||
} else {
|
||||
response.display("entry", {
|
||||
response.display("artifact", {
|
||||
user: request.user,
|
||||
pageTitle: "Library - Mantra",
|
||||
entry: entry
|
||||
artifact: artifact
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,29 +22,29 @@ module.exports = function (options) {
|
||||
db.Project.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Project.ProjectEntryVersions,
|
||||
association: db.Project.ProjectArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.ProjectEntryVersion.EntryVersion,
|
||||
association: db.ProjectArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationEntryVersions,
|
||||
association: db.Project.ProjectTranslationArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.ProjectTranslationEntryVersion.TranslationEntryVersion,
|
||||
association: db.ProjectTranslationArtifactVersion.TranslationArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -81,7 +81,8 @@ module.exports = function (options) {
|
||||
.post(function(request, response, next) {
|
||||
db.Project.create({
|
||||
name: request.body.name,
|
||||
description: request.body.description
|
||||
description: request.body.description,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
}).then(project => {
|
||||
if (project) {
|
||||
response.redirect(`/projects/${project.id}`)
|
||||
@@ -93,31 +94,31 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
|
||||
router.route('/:id/add-entry')
|
||||
router.route('/:id/add-artifact')
|
||||
.get(function(request, response, next) {
|
||||
db.Project.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Project.ProjectEntryVersions
|
||||
association: db.Project.ProjectArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationEntryVersions
|
||||
association: db.Project.ProjectTranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
if (project) {
|
||||
const entries = await db.Entry.findAll({
|
||||
const entries = await db.Artifact.findAll({
|
||||
// Narrow it down to entries this user has admin ownership off...,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryVersions,
|
||||
association: db.Artifact.ArtifactVersions,
|
||||
limit: 1,
|
||||
required: true
|
||||
// TODO: Order by version...
|
||||
}
|
||||
]
|
||||
})
|
||||
response.display("project-add-entry", {
|
||||
response.display("project-add-artifact", {
|
||||
user: request.user,
|
||||
pageTitle: "Projects - Mantra",
|
||||
project: project,
|
||||
@@ -134,29 +135,29 @@ module.exports = function (options) {
|
||||
db.Project.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Project.ProjectEntryVersions,
|
||||
association: db.Project.ProjectArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.ProjectEntryVersion.EntryVersion,
|
||||
association: db.ProjectArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationEntryVersions,
|
||||
association: db.Project.ProjectTranslationArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.ProjectTranslationEntryVersion.TranslationEntryVersion,
|
||||
association: db.ProjectTranslationArtifactVersion.TranslationArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -168,19 +169,19 @@ module.exports = function (options) {
|
||||
}).then(async (project) => {
|
||||
if (project) {
|
||||
// TODO: Fi
|
||||
const entryVersion = await db.EntryVersion.findByPk(request.body.entryVersionId, {
|
||||
const artifactVersion = await db.ArtifactVersion.findByPk(request.body.artifactVersionId, {
|
||||
// Narrow it down to entries this user has admin ownership off...,
|
||||
})
|
||||
|
||||
if (entryVersion) {
|
||||
const projectEntryVersion = db.ProjectEntryVersion.create({
|
||||
if (artifactVersion) {
|
||||
const projectArtifactVersion = db.ProjectArtifactVersion.create({
|
||||
projectId: project.id,
|
||||
entryVersionId: entryVersion.id
|
||||
artifactVersionId: artifactVersion.id
|
||||
})
|
||||
|
||||
response.redirect(`/projects/${project.id}`)
|
||||
} else {
|
||||
response.redirect(`/projects/${project.id}/add-entry`)
|
||||
response.redirect(`/projects/${project.id}/add-artifact`)
|
||||
}
|
||||
|
||||
|
||||
@@ -197,24 +198,24 @@ module.exports = function (options) {
|
||||
db.Project.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Project.ProjectEntryVersions
|
||||
association: db.Project.ProjectArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationEntryVersions
|
||||
association: db.Project.ProjectTranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
if (project) {
|
||||
const translationEntryVersions = await db.TranslationEntryVersion.findAll({
|
||||
const translationArtifactVersions = await db.TranslationArtifactVersion.findAll({
|
||||
// Narrow it down to entries this user has admin ownership off...,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
required: true,
|
||||
// TODO: Order by version...
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -224,7 +225,7 @@ module.exports = function (options) {
|
||||
user: request.user,
|
||||
pageTitle: "Projects - Mantra",
|
||||
project: project,
|
||||
translationEntryVersions: translationEntryVersions
|
||||
translationArtifactVersions: translationArtifactVersions
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
@@ -237,30 +238,30 @@ module.exports = function (options) {
|
||||
db.Project.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Project.ProjectEntryVersions
|
||||
association: db.Project.ProjectArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationEntryVersions
|
||||
association: db.Project.ProjectTranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
if (project) {
|
||||
// TODO: Fi
|
||||
const translationEntryVersion = await db.TranslationEntryVersion.findByPk(request.body.translationEntryVersionId, {
|
||||
const translationArtifactVersion = await db.TranslationArtifactVersion.findByPk(request.body.translationArtifactVersionId, {
|
||||
// Narrow it down to entries this user has admin ownership off...,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
required: true
|
||||
// TODO: Order by version...
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
if (translationEntryVersion) {
|
||||
const projectTranslationEntryVersion = db.ProjectTranslationEntryVersion.create({
|
||||
if (translationArtifactVersion) {
|
||||
const projectTranslationArtifactVersion = db.ProjectTranslationArtifactVersion.create({
|
||||
projectId: project.id,
|
||||
translationEntryVersionId: translationEntryVersion.id
|
||||
translationArtifactVersionId: translationArtifactVersion.id
|
||||
})
|
||||
|
||||
response.redirect(`/projects/${project.id}`)
|
||||
@@ -285,29 +286,29 @@ module.exports = function (options) {
|
||||
required: true
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectEntryVersions,
|
||||
association: db.Project.ProjectArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.ProjectEntryVersion.EntryVersion,
|
||||
association: db.ProjectArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationEntryVersions,
|
||||
association: db.Project.ProjectTranslationArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.ProjectTranslationEntryVersion.TranslationEntryVersion,
|
||||
association: db.ProjectTranslationArtifactVersion.TranslationArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -362,29 +363,29 @@ module.exports = function (options) {
|
||||
|
||||
}).then(async (project) => {
|
||||
if (project) {
|
||||
db.TranslationEntryVersion.findAll({
|
||||
db.TranslationArtifactVersion.findAll({
|
||||
include: [
|
||||
// TODO: require translationEntryVersions in ProjectEntryVersion
|
||||
// TODO: require translationArtifactVersions in ProjectArtifactVersion
|
||||
{
|
||||
association: db.TranslationEntryVersion.ProjectTranslationEntryVersions,
|
||||
association: db.TranslationArtifactVersion.ProjectTranslationArtifactVersions,
|
||||
where: {
|
||||
projectId: request.params.id
|
||||
},
|
||||
required: true
|
||||
},
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.Artifact.Dialect
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Chapters,
|
||||
association: db.ArtifactVersion.Chapters,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.Chunks,
|
||||
@@ -399,22 +400,22 @@ module.exports = function (options) {
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationEntryVersion.Dialect
|
||||
association: db.TranslationArtifactVersion.Dialect
|
||||
}
|
||||
]
|
||||
}).then(translationEntryVersions => {
|
||||
}).then(translationArtifactVersions => {
|
||||
const workbook = new XL.Workbook();
|
||||
const cellWidth = 45
|
||||
const cellHeight = 25
|
||||
|
||||
translationEntryVersions.forEach((translationEntryVersion, index) => {
|
||||
const worksheet_name = `${index+1}-${translationEntryVersion.dialect.countryId}-${translationEntryVersion.dialect.languageId} - ${translationEntryVersion.entryVersion.entry.name}`.substring(0, 30);
|
||||
translationArtifactVersions.forEach((translationArtifactVersion, index) => {
|
||||
const worksheet_name = `${index+1}-${translationArtifactVersion.dialect.countryId}-${translationArtifactVersion.dialect.languageId} - ${translationArtifactVersion.artifactVersion.artifact.name}`.substring(0, 30);
|
||||
|
||||
// Don't have [ ] * ? : / \
|
||||
const worksheet = workbook.addWorksheet(worksheet_name.replace(/[`*?:'\[\]\\\/]/gi, ""))
|
||||
|
||||
worksheet.cell(2,2,2,3,true)
|
||||
.string(translationEntryVersion.entryVersion.entry.name)
|
||||
.string(translationArtifactVersion.artifactVersion.artifact.name)
|
||||
.style({
|
||||
font: {
|
||||
bold: true,
|
||||
@@ -426,7 +427,7 @@ module.exports = function (options) {
|
||||
})
|
||||
|
||||
worksheet.cell(4,2)
|
||||
.string(translationEntryVersion.entryVersion.entry.dialect.name)
|
||||
.string(translationArtifactVersion.artifactVersion.artifact.dialect.name)
|
||||
.style({
|
||||
font: {
|
||||
bold: true,
|
||||
@@ -438,7 +439,7 @@ module.exports = function (options) {
|
||||
})
|
||||
|
||||
worksheet.cell(4,3)
|
||||
.string(translationEntryVersion.dialect.name)
|
||||
.string(translationArtifactVersion.dialect.name)
|
||||
.style({
|
||||
font: {
|
||||
bold: true,
|
||||
@@ -448,15 +449,15 @@ module.exports = function (options) {
|
||||
wrapText: true
|
||||
}
|
||||
})
|
||||
// Meta data for the translation and entry
|
||||
// Meta data for the translation and artifact
|
||||
worksheet.cell(4,4)
|
||||
.string(translationEntryVersion.entryVersion.id)
|
||||
.string(translationArtifactVersion.artifactVersion.id)
|
||||
worksheet.cell(4,5)
|
||||
.string(translationEntryVersion.id)
|
||||
.string(translationArtifactVersion.id)
|
||||
|
||||
var cellIndex = 6
|
||||
for (const i in translationEntryVersion.entryVersion.chapters) {
|
||||
const chapter = translationEntryVersion.entryVersion.chapters[i]
|
||||
for (const i in translationArtifactVersion.artifactVersion.chapters) {
|
||||
const chapter = translationArtifactVersion.artifactVersion.chapters[i]
|
||||
const chunks = chapter.chunks.sort((a,b) => a.index - b.index)
|
||||
for (const j in chunks) {
|
||||
const chunk = chunks[j]
|
||||
|
||||
@@ -7,14 +7,14 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Chapters,
|
||||
association: db.ArtifactVersion.Chapters,
|
||||
required: true,
|
||||
limit: 1,
|
||||
// TODO: Order by chapter index
|
||||
@@ -22,9 +22,9 @@ module.exports = function (options) {
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationEntryVersion => {
|
||||
if (translationEntryVersion) {
|
||||
response.redirect(`/translate/${translationEntryVersion.id}/chapter/${translationEntryVersion.entryVersion.chapters[0].id}`)
|
||||
}).then(translationArtifactVersion => {
|
||||
if (translationArtifactVersion) {
|
||||
response.redirect(`/translate/${translationArtifactVersion.id}/chapter/${translationArtifactVersion.artifactVersion.chapters[0].id}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
@@ -44,21 +44,21 @@ module.exports = function (options) {
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Chapter.EntryVersion,
|
||||
association: db.Chapter.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions,
|
||||
required: true,
|
||||
where: {
|
||||
id: request.params.id
|
||||
}
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.Artifact.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -104,21 +104,21 @@ module.exports = function (options) {
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.EntryVersion,
|
||||
association: db.Chapter.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions,
|
||||
required: true,
|
||||
where: {
|
||||
id: request.params.id
|
||||
}
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.Artifact.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -133,7 +133,7 @@ module.exports = function (options) {
|
||||
if (chunk) {
|
||||
response.display("translate-chunk", {
|
||||
user: request.user,
|
||||
pageTitle: `Translate ${chunk.chapter.entryVersion.entry.name}`,
|
||||
pageTitle: `Translate ${chunk.chapter.artifactVersion.artifact.name}`,
|
||||
chunk: chunk,
|
||||
previousChunk: chunks.find(chunk => chunk.index == previousIndex),
|
||||
nextChunk: chunks.find(chunk => chunk.index == nextIndex)
|
||||
@@ -164,21 +164,21 @@ module.exports = function (options) {
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.EntryVersion,
|
||||
association: db.Chapter.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions,
|
||||
required: true,
|
||||
where: {
|
||||
id: request.params.id
|
||||
}
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.Artifact.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -196,7 +196,7 @@ module.exports = function (options) {
|
||||
translation = await db.Translation.create({
|
||||
chunkId: chunk.id,
|
||||
text: request.body.translatedText,
|
||||
translationEntryVersionId: request.params.id
|
||||
translationArtifactVersionId: request.params.id
|
||||
})
|
||||
}
|
||||
response.redirect(`/translate/${request.params.id}/chapter/${request.params.chapterId}/t/${Number(request.params.chunkIndex)+1}`)
|
||||
@@ -210,14 +210,14 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id/back')
|
||||
.post(function(request, response, next) {
|
||||
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Chapters,
|
||||
association: db.ArtifactVersion.Chapters,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
@@ -234,31 +234,31 @@ module.exports = function (options) {
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.Artifact.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then((translationEntryVersion) => {
|
||||
if (translationEntryVersion) {
|
||||
}).then((translationArtifactVersion) => {
|
||||
if (translationArtifactVersion) {
|
||||
// TODO: Create a backTranslation...
|
||||
backTranslatedEntry = {}
|
||||
backTranslatedArtifact = {}
|
||||
return db.BackTranslation.create({
|
||||
translationEntryVersionId: translationEntryVersion.id,
|
||||
entry: {
|
||||
name: translationEntryVersion.name + translationEntryVersion.entryVersion.entry.name,
|
||||
translationArtifactVersionId: translationArtifactVersion.id,
|
||||
artifact: {
|
||||
name: translationArtifactVersion.name + translationArtifactVersion.artifactVersion.artifact.name,
|
||||
url: `/translate/${request.params.id}`,
|
||||
dialectId: translationEntryVersion.dialectId,
|
||||
dialectId: translationArtifactVersion.dialectId,
|
||||
licenseId: "copyright", // Should be closed because it's a back translation not meant to be published
|
||||
entryVersions: [
|
||||
artifactVersions: [
|
||||
{
|
||||
tag: translationEntryVersion.entryVersion.tag,
|
||||
chapters: translationEntryVersion.entryVersion.chapters.map(chapter => {
|
||||
tag: translationArtifactVersion.artifactVersion.tag,
|
||||
chapters: translationArtifactVersion.artifactVersion.chapters.map(chapter => {
|
||||
return {
|
||||
name: chapter.chunks[0].translation.text, // TODO: This isn't important...
|
||||
chunks: chapter.chunks.map(chunk => {
|
||||
@@ -269,10 +269,10 @@ module.exports = function (options) {
|
||||
})
|
||||
}
|
||||
}),
|
||||
translationEntryVersions: [
|
||||
translationArtifactVersions: [
|
||||
{
|
||||
dialectId: translationEntryVersion.entryVersion.entry.dialect.id,
|
||||
name: translationEntryVersion.entryVersion.entry.dialect.name
|
||||
dialectId: translationArtifactVersion.artifactVersion.artifact.dialect.id,
|
||||
name: translationArtifactVersion.artifactVersion.artifact.dialect.name
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -281,13 +281,13 @@ module.exports = function (options) {
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.BackTranslation.Entry,
|
||||
association: db.BackTranslation.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryVersions,
|
||||
association: db.Artifact.ArtifactVersions,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Chapters,
|
||||
association: db.ArtifactVersion.Chapters,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.Chunks
|
||||
@@ -295,7 +295,7 @@ module.exports = function (options) {
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -308,7 +308,7 @@ module.exports = function (options) {
|
||||
}
|
||||
}).then(backTranslation => {
|
||||
if (backTranslation) {
|
||||
response.redirect(`/library/${backTranslation.entryId}`)
|
||||
response.redirect(`/library/${backTranslation.artifactId}`)
|
||||
} else {
|
||||
// TODO: Let user know we cannot back translate
|
||||
response.redirect(`/translate/${request.params.id}`)
|
||||
@@ -320,25 +320,25 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id/campaign')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.TranslationEntryVersionCampaigns,
|
||||
association: db.TranslationArtifactVersion.TranslationArtifactVersionCampaigns,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersionCampaign.Campaign,
|
||||
association: db.TranslationArtifactVersionCampaign.Campaign,
|
||||
required: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationEntryVersion => {
|
||||
if (translationEntryVersion) {
|
||||
if (translationEntryVersion.translationEntryVersionCampaings.length == 1) {
|
||||
response.redirect(`/campaigns/${translationEntryVersion.translationEntryVersionCampaings[0].campaignId}`)
|
||||
}).then(translationArtifactVersion => {
|
||||
if (translationArtifactVersion) {
|
||||
if (translationArtifactVersion.translationArtifactVersionCampaings.length == 1) {
|
||||
response.redirect(`/campaigns/${translationArtifactVersion.translationArtifactVersionCampaings[0].campaignId}`)
|
||||
} else {
|
||||
// TODO: Display translation entry campaign...
|
||||
// TODO: Display translation artifact campaign...
|
||||
next()
|
||||
}
|
||||
} else {
|
||||
@@ -349,36 +349,36 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id/campaign/create')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationEntryVersion.TranslationEntryVersionCampaigns,
|
||||
association: db.TranslationArtifactVersion.TranslationArtifactVersionCampaigns,
|
||||
required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersionCampaign.Campaign,
|
||||
association: db.TranslationArtifactVersionCampaign.Campaign,
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationEntryVersion => {
|
||||
if (translationEntryVersion) {
|
||||
}).then(translationArtifactVersion => {
|
||||
if (translationArtifactVersion) {
|
||||
response.display("campaign-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Campaign - Mantra",
|
||||
campaign: {
|
||||
name: `Campaign for ${translationEntryVersion.name} translation of ${translationEntryVersion.entryVersion.entry.name}`
|
||||
name: `Campaign for ${translationArtifactVersion.name} translation of ${translationArtifactVersion.artifactVersion.artifact.name}`
|
||||
},
|
||||
translationEntryVersions: [translationEntryVersion]
|
||||
translationArtifactVersions: [translationArtifactVersion]
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
|
||||
@@ -7,29 +7,29 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Chapters
|
||||
association: db.ArtifactVersion.Chapters
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(entryVersion => {
|
||||
if (entryVersion) {
|
||||
response.display("entry-version", {
|
||||
}).then(artifactVersion => {
|
||||
if (artifactVersion) {
|
||||
response.display("artifact-version", {
|
||||
user: request.user,
|
||||
pageTitle: "Entry - Mantra",
|
||||
entryVersion: entryVersion
|
||||
pageTitle: "Artifact - Mantra",
|
||||
artifactVersion: artifactVersion
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
@@ -41,26 +41,26 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id/chapters/add')
|
||||
.get(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Chapters
|
||||
association: db.ArtifactVersion.Chapters
|
||||
}
|
||||
]
|
||||
}).then(entryVersion => {
|
||||
if (entryVersion) {
|
||||
}).then(artifactVersion => {
|
||||
if (artifactVersion) {
|
||||
response.display("chapter-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Library - Mantra",
|
||||
entryVersion: entryVersion
|
||||
artifactVersion: artifactVersion
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
@@ -71,27 +71,27 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
.post(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Chapters
|
||||
association: db.ArtifactVersion.Chapters
|
||||
}
|
||||
]
|
||||
}).then(entryVersion => {
|
||||
}).then(artifactVersion => {
|
||||
const isString = typeof request.body.text === "string" || request.body.text instanceof String
|
||||
if (entryVersion && isString) {
|
||||
if (artifactVersion && isString) {
|
||||
const chunks = request.body.text.trim().split(/\r?\n\r?\n/)
|
||||
db.Chapter.create({
|
||||
name: chunks[0].trim(),
|
||||
entryVersionId: entryVersion.id,
|
||||
artifactVersionId: artifactVersion.id,
|
||||
chunks: chunks.map((chunk,index) => {
|
||||
return {
|
||||
text: chunk,
|
||||
@@ -106,12 +106,12 @@ module.exports = function (options) {
|
||||
]
|
||||
}).then(chapter => {
|
||||
if (chapter) {
|
||||
response.redirect(`/v/${chapter.entryVersionId}/chapters/${chapter.id}`)
|
||||
response.redirect(`/v/${chapter.artifactVersionId}/chapters/${chapter.id}`)
|
||||
} else {
|
||||
response.display("chapter-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Library - Mantra",
|
||||
entryVersion: entryVersion
|
||||
artifactVersion: artifactVersion
|
||||
})
|
||||
}
|
||||
}).catch(error => {
|
||||
@@ -134,10 +134,10 @@ module.exports = function (options) {
|
||||
association: db.Chapter.Chunks
|
||||
},
|
||||
{
|
||||
association: db.Chapter.EntryVersion,
|
||||
association: db.Chapter.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -157,28 +157,28 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
|
||||
router.route('/:id/translations/:translationEntryVersionId')
|
||||
router.route('/:id/translations/:translationArtifactVersionId')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationEntryVersion.findByPk(request.params.translationEntryVersionId, {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.translationArtifactVersionId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationEntryVersion.ForkedFrom
|
||||
association: db.TranslationArtifactVersion.ForkedFrom
|
||||
}
|
||||
]
|
||||
}).then(translationEntryVersion => {
|
||||
if (translationEntryVersion) {
|
||||
response.display("translation-entry-version", {
|
||||
}).then(translationArtifactVersion => {
|
||||
if (translationArtifactVersion) {
|
||||
response.display("translation-artifact-version", {
|
||||
user: request.user,
|
||||
pageTitle: "Translation Entry - Mantra",
|
||||
translationEntryVersion: translationEntryVersion,
|
||||
pageTitle: "Translation Artifact - Mantra",
|
||||
translationArtifactVersion: translationArtifactVersion,
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
@@ -190,26 +190,26 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id/translations/add')
|
||||
.get(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(entryVersion => {
|
||||
if (entryVersion) {
|
||||
}).then(artifactVersion => {
|
||||
if (artifactVersion) {
|
||||
response.display("translation-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Library - Mantra",
|
||||
entryVersion: entryVersion
|
||||
artifactVersion: artifactVersion
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
@@ -220,22 +220,22 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
.post(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.EntryApproval
|
||||
association: db.Artifact.ArtifactApproval
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(async (entryVersion) => {
|
||||
if (entryVersion) {
|
||||
}).then(async (artifactVersion) => {
|
||||
if (artifactVersion) {
|
||||
const dialectTokens = request.body.dialect?.split(":")
|
||||
if (dialectTokens?.length == 2) {
|
||||
const countryId = dialectTokens[0].split("-")[0]
|
||||
@@ -249,14 +249,15 @@ module.exports = function (options) {
|
||||
})
|
||||
|
||||
if (dialect) {
|
||||
const translationEntryVersion = await db.TranslationEntryVersion.create({
|
||||
const translationArtifactVersion = await db.TranslationArtifactVersion.create({
|
||||
name: dialect.name,
|
||||
entryVersionId: entryVersion.id,
|
||||
dialectId: dialect.id
|
||||
artifactVersionId: artifactVersion.id,
|
||||
dialectId: dialect.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
})
|
||||
|
||||
if (translationEntryVersion) {
|
||||
return response.redirect(`/v/${entryVersion.id}/translations/${translationEntryVersion.id}`)
|
||||
if (translationArtifactVersion) {
|
||||
return response.redirect(`/v/${artifactVersion.id}/translations/${translationArtifactVersion.id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -269,24 +270,24 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id/campaign/create')
|
||||
.get(function(request, response, next) {
|
||||
db.EntryVersion.findByPk(request.params.id, {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
||||
}
|
||||
]
|
||||
}).then(entryVersion => {
|
||||
if (entryVersion) {
|
||||
}).then(artifactVersion => {
|
||||
if (artifactVersion) {
|
||||
response.display("campaign-form", {
|
||||
user: request.user,
|
||||
pageTitle: "Campaign - Mantra",
|
||||
campaign: {
|
||||
name: `Campaign for ${entryVersion.translationEntryVersions.length} translations of ${entryVersion.entry.name}`
|
||||
name: `Campaign for ${artifactVersion.translationArtifactVersions.length} translations of ${artifactVersion.artifact.name}`
|
||||
},
|
||||
translationEntryVersions: entryVersion.translationEntryVersions
|
||||
translationArtifactVersions: artifactVersion.translationArtifactVersions
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
|
||||
Reference in New Issue
Block a user