Add ability to remove translator
This commit is contained in:
@@ -875,6 +875,21 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.TranslationChapter.TranslationChapterTranslators,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapterTranslator.Translator,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityEmail,
|
||||
include: [
|
||||
{
|
||||
association: db.EntityEmail.Email
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationChapter.TranslationChapterProofReaders,
|
||||
@@ -1068,5 +1083,188 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
|
||||
router.route('/:id/chapter/:chapterId/translator/:translatorId')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationChapterTranslator.findByPk(request.params.translatorId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapterTranslator.TranslationChapter,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapter.TranslationArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Artifact.Dialect
|
||||
},
|
||||
{
|
||||
association: db.Artifact.Owner,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: true,
|
||||
where: {
|
||||
userId: request.user?.id ?? null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Dialect
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.BackTranslationFrom
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationArtifactVersionEditor,
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationChapterTranslator.Translator,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityEmail,
|
||||
include: [
|
||||
{
|
||||
association: db.EntityEmail.Email
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationChapterTranslator => {
|
||||
if (translationChapterTranslator) {
|
||||
response.display("translate-chapter-translator-remove", {
|
||||
user: request.user,
|
||||
pageTitle: `Translator ${translationChapterTranslator.name}`,
|
||||
translationChapterTranslator: translationChapterTranslator
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
.post(function(request, response, next) {
|
||||
db.TranslationChapterTranslator.findByPk(request.params.translatorId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapterTranslator.TranslationChapter,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapter.TranslationArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Artifact.Dialect
|
||||
},
|
||||
{
|
||||
association: db.Artifact.Owner,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: true,
|
||||
where: {
|
||||
userId: request.user?.id ?? null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Dialect
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.BackTranslationFrom
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationArtifactVersionEditor,
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationChapterTranslator.Translator,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityEmail,
|
||||
include: [
|
||||
{
|
||||
association: db.EntityEmail.Email
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (translationChapterTranslator) => {
|
||||
if (translationChapterTranslator) {
|
||||
await translationChapterTranslator.destroy()
|
||||
response.redirect(`/translate/${translationChapterTranslator.translationChapter.translationArtifactVersion.id}/chapter/${translationChapterTranslator.translationChapter.id}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
|
||||
return router;
|
||||
};
|
||||
Reference in New Issue
Block a user