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;
|
||||
};
|
||||
@@ -7,10 +7,13 @@ block content
|
||||
|
||||
.row
|
||||
.col.s12
|
||||
form.row(action=`/campaigns/create`, method="post")
|
||||
form.row(action=urlEndpoint, method="post")
|
||||
.col.s12.input-field
|
||||
input#name(type="text", name="name", value=campaign.name)
|
||||
label(for="name") Campaign Name
|
||||
label(for="name") Name
|
||||
.col.s12.input-field
|
||||
input#description(type="text", name="description", value=campaign.description)
|
||||
label(for="description") Description
|
||||
if project
|
||||
input(type="hidden", name="projectId", value=project.id)
|
||||
.col.s12.input-field
|
||||
|
||||
11
server/views/campaign.pug
Normal file
11
server/views/campaign.pug
Normal file
@@ -0,0 +1,11 @@
|
||||
extend templates/layout.pug
|
||||
|
||||
block content
|
||||
.container
|
||||
.center
|
||||
h1= campaign.name
|
||||
p.flow-text= campaign.description
|
||||
|
||||
.divider
|
||||
each translationArtifactVersionCampaign in campaign.translationArtifactVersionCampaigns
|
||||
p.flow-text #{translationArtifactVersionCampaign.translationArtifactVersion.name} - #{translationArtifactVersionCampaign.translationArtifactVersion.artifactVersion.artifact.name} - #{translationArtifactVersionCampaign.translationArtifactVersion.artifactVersion.tag} - #{translationArtifactVersionCampaign.satoshis} sats
|
||||
Reference in New Issue
Block a user