Create a campaign for a translation
This commit is contained in:
@@ -12,11 +12,49 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
|
||||
router.route('/create')
|
||||
.post(function(request, response, next) {
|
||||
console.log(request.body)
|
||||
next()
|
||||
router.route('/:id')
|
||||
.get(function(request, response, next) {
|
||||
db.Campaign.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.Campaign.TranslationArtifactVersionCampaigns,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersionCampaign.TranslationArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.ArtifactVersion.Artifact
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(campaign => {
|
||||
if (campaign) {
|
||||
response.display("campaign", {
|
||||
user: request.user,
|
||||
pageTitle: "Campaign - Mantra",
|
||||
campaign: campaign
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
|
||||
// router.route('/create')
|
||||
// .post(function(request, response, next) {
|
||||
// console.log(request.body)
|
||||
// next()
|
||||
// })
|
||||
|
||||
return router;
|
||||
};
|
||||
@@ -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