Add versioning
This commit is contained in:
@@ -7,14 +7,14 @@ module.exports = function (options) {
|
||||
|
||||
router.route('/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationEntry.findByPk(request.params.id, {
|
||||
db.TranslationEntryVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationEntry.Entry,
|
||||
association: db.TranslationEntryVersion.EntryVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Chapters,
|
||||
association: db.EntryVersion.Chapters,
|
||||
required: true,
|
||||
limit: 1,
|
||||
// TODO: Order by chapter index
|
||||
@@ -22,9 +22,9 @@ module.exports = function (options) {
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationEntry => {
|
||||
if (translationEntry) {
|
||||
response.redirect(`/translate/${translationEntry.id}/chapter/${translationEntry.entry.chapters[0].id}`)
|
||||
}).then(translationEntryVersion => {
|
||||
if (translationEntryVersion) {
|
||||
response.redirect(`/translate/${translationEntryVersion.id}/chapter/${translationEntryVersion.entryVersion.chapters[0].id}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
@@ -44,18 +44,23 @@ module.exports = function (options) {
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Chapter.Entry,
|
||||
association: db.Chapter.EntryVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.TranslationEntries,
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
required: true,
|
||||
where: {
|
||||
id: request.params.id
|
||||
}
|
||||
},
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.EntryVersion.Entry,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -99,18 +104,23 @@ module.exports = function (options) {
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.Entry,
|
||||
association: db.Chapter.EntryVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.TranslationEntries,
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
required: true,
|
||||
where: {
|
||||
id: request.params.id
|
||||
}
|
||||
},
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
association: db.EntryVersion.Entry,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -122,7 +132,7 @@ module.exports = function (options) {
|
||||
const chunk = chunks.find(chunk => chunk.index == Number(request.params.chunkIndex))
|
||||
response.display("translate-chunk", {
|
||||
user: request.user,
|
||||
pageTitle: `Translate ${chunk.chapter.entry.name}`,
|
||||
pageTitle: `Translate ${chunk.chapter.entryVersion.entry.name}`,
|
||||
chunk: chunk,
|
||||
previousChunk: chunks.find(chunk => chunk.index == previousIndex),
|
||||
nextChunk: chunks.find(chunk => chunk.index == nextIndex)
|
||||
|
||||
Reference in New Issue
Block a user