Back translations
This commit is contained in:
2
package-lock.json
generated
2
package-lock.json
generated
@@ -24,7 +24,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"../mantra-db-models": {
|
"../mantra-db-models": {
|
||||||
"version": "0.0.6",
|
"version": "0.0.6.3",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bcrypt": "^5.0.1",
|
"bcrypt": "^5.0.1",
|
||||||
|
|||||||
@@ -202,5 +202,115 @@ module.exports = function (options) {
|
|||||||
next(error)
|
next(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.route('/:id/back')
|
||||||
|
.post(function(request, response, next) {
|
||||||
|
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationEntryVersion.EntryVersion,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.EntryVersion.Chapters,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Chapter.Chunks,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Chunk.Translation,
|
||||||
|
required: true,
|
||||||
|
// TODO: Where text is not null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.EntryVersion.Entry,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entry.Dialect
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}).then((translationEntryVersion) => {
|
||||||
|
if (translationEntryVersion) {
|
||||||
|
// TODO: Create a backTranslation...
|
||||||
|
backTranslatedEntry = {}
|
||||||
|
return db.BackTranslation.create({
|
||||||
|
translationEntryVersionId: translationEntryVersion.id,
|
||||||
|
entry: {
|
||||||
|
name: translationEntryVersion.name + translationEntryVersion.entryVersion.entry.name,
|
||||||
|
url: `/translate/${request.params.id}`,
|
||||||
|
dialectId: translationEntryVersion.dialectId,
|
||||||
|
licenseId: "copyright", // Should be closed because it's a back translation not meant to be published
|
||||||
|
entryVersions: [
|
||||||
|
{
|
||||||
|
tag: translationEntryVersion.entryVersion.tag,
|
||||||
|
chapters: translationEntryVersion.entryVersion.chapters.map(chapter => {
|
||||||
|
return {
|
||||||
|
name: chapter.chunks[0].translation.text, // TODO: This isn't important...
|
||||||
|
chunks: chapter.chunks.map(chunk => {
|
||||||
|
return {
|
||||||
|
text: chunk.translation.text,
|
||||||
|
index: chunk.index
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
translationEntryVersions: [
|
||||||
|
{
|
||||||
|
dialectId: translationEntryVersion.entryVersion.entry.dialect.id,
|
||||||
|
name: translationEntryVersion.entryVersion.entry.dialect.name
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.BackTranslation.Entry,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entry.EntryVersions,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.EntryVersion.Chapters,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Chapter.Chunks
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.EntryVersion.TranslationEntryVersions
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}).then(backTranslation => {
|
||||||
|
if (backTranslation) {
|
||||||
|
response.redirect(`/library/${backTranslation.entryId}`)
|
||||||
|
} else {
|
||||||
|
// TODO: Let user know we cannot back translate
|
||||||
|
response.redirect(`/translate/${request.params.id}`)
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
next(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
@@ -20,4 +20,8 @@ block content
|
|||||||
form(action=`/fork/t/${translationEntryVersion.id}`, method="post")
|
form(action=`/fork/t/${translationEntryVersion.id}`, method="post")
|
||||||
button.btn.black(type="submit") fork
|
button.btn.black(type="submit") fork
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col.s12
|
||||||
|
form(action=`/translate/${translationEntryVersion.id}/back`, method="post")
|
||||||
|
button.btn.black(type="submit") back translate
|
||||||
//- TODO: Give summary of chapters...
|
//- TODO: Give summary of chapters...
|
||||||
|
|||||||
Reference in New Issue
Block a user