Project ownership handling
This commit is contained in:
@@ -82,19 +82,16 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.Project.Owner,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: true,
|
||||
required: false,
|
||||
where: {
|
||||
userId: request.user?.id ?? null
|
||||
}
|
||||
@@ -174,6 +171,31 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
@@ -239,6 +261,31 @@ module.exports = function (options) {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
@@ -292,6 +339,31 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
@@ -332,6 +404,31 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.Project.ProjectTranslationArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
@@ -375,6 +472,31 @@ module.exports = function (options) {
|
||||
{
|
||||
association: db.Project.Campaign,
|
||||
required: true
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(project => {
|
||||
@@ -423,6 +545,31 @@ module.exports = function (options) {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(project => {
|
||||
@@ -483,6 +630,31 @@ module.exports = function (options) {
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.Project.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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
@@ -559,7 +731,30 @@ module.exports = function (options) {
|
||||
router.route('/:id/spreadsheet')
|
||||
.post(function(request, response, next) {
|
||||
db.Project.findByPk(request.params.id, {
|
||||
|
||||
include: [
|
||||
{
|
||||
association: db.Project.Owner,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: false,
|
||||
where: {
|
||||
userId: request.user?.id ?? null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (project) => {
|
||||
if (project) {
|
||||
db.TranslationArtifactVersion.findAll({
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
extend templates/layout.pug
|
||||
|
||||
block content
|
||||
-
|
||||
const isOwnedByUser = project.owner.ownerEntities.some(ownerEntity => {
|
||||
return ownerEntity.entity.entityUsers.some(entityUser => {
|
||||
return entityUser.userId == user?.id
|
||||
})
|
||||
})
|
||||
.container
|
||||
.center
|
||||
h1= project.name
|
||||
@@ -19,15 +25,17 @@ block content
|
||||
h2 Entries
|
||||
each projectArtifactVersion in project.projectArtifactVersions
|
||||
p.flow-text= projectArtifactVersion.artifactVersion.artifact.name
|
||||
.row
|
||||
.col.s12
|
||||
a.btn.black(href=`/projects/${project.id}/add-artifact`) add from library
|
||||
if isOwnedByUser
|
||||
.row
|
||||
.col.s12
|
||||
a.btn.black(href=`/projects/${project.id}/add-artifact`) add from library
|
||||
.divider
|
||||
h2 Translation
|
||||
each projectTranslationArtifactVersion in project.projectTranslationArtifactVersions
|
||||
p.flow-text #{projectTranslationArtifactVersion.translationArtifactVersion.name} - #{projectTranslationArtifactVersion.translationArtifactVersion.artifactVersion.artifact.name}
|
||||
.row
|
||||
.col.s12
|
||||
a.btn.black(href=`/projects/${project.id}/add-translation`) add translation
|
||||
if isOwnedByUser
|
||||
.row
|
||||
.col.s12
|
||||
a.btn.black(href=`/projects/${project.id}/add-translation`) add translation
|
||||
//- TODO: Show project translation artifact versions
|
||||
//- TODO: Show project artifact versions
|
||||
Reference in New Issue
Block a user