Create a campaign for a translation
This commit is contained in:
@@ -387,6 +387,60 @@ module.exports = function (options) {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
.post(function(request, response, next) {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationArtifactVersionCampaigns,
|
||||
required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersionCampaign.Campaign,
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (translationArtifactVersion) => {
|
||||
if (translationArtifactVersion) {
|
||||
// TODO: Create campaign...
|
||||
const campaign = await db.Campaign.create({
|
||||
name: request.body.name,
|
||||
description: request.body.description,
|
||||
// defaultSatoshis: [request.body.satoshis].flat()[0],
|
||||
defaultSatoshis: request.body.satoshis,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
translationArtifactVersionCampaigns: [
|
||||
{
|
||||
translationArtifactVersionId: translationArtifactVersion.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
satoshis: request.body.satoshis
|
||||
}
|
||||
]
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.Campaign.TranslationArtifactVersionCampaigns
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
response.redirect(`/campaigns/${campaign.id}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
|
||||
return router;
|
||||
};
|
||||
Reference in New Issue
Block a user