Add pledges
This commit is contained in:
@@ -7,6 +7,14 @@ module.exports = function (options) {
|
|||||||
router.route('/')
|
router.route('/')
|
||||||
.get(function(request, response, next) {
|
.get(function(request, response, next) {
|
||||||
db.Pledge.findAll({
|
db.Pledge.findAll({
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Pledge.TranslationArtifactVersionPledges
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Pledge.Entity
|
||||||
|
}
|
||||||
|
]
|
||||||
}).then(pledges => {
|
}).then(pledges => {
|
||||||
if (pledges) {
|
if (pledges) {
|
||||||
response.display("pledges", {
|
response.display("pledges", {
|
||||||
@@ -20,6 +28,47 @@ module.exports = function (options) {
|
|||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
next(error)
|
next(error)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
router.route('/:id')
|
||||||
|
.get(function(request, response, next) {
|
||||||
|
db.Pledge.findByPk(request.params.id, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Pledge.Entity
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Pledge.TranslationArtifactVersionPledges,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersionPledge.TranslationArtifactVersion,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.ArtifactVersion.Artifact
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}).then(pledge => {
|
||||||
|
if (pledge) {
|
||||||
|
response.display("pledge", {
|
||||||
|
user: request.user,
|
||||||
|
pageTitle: "Pledge - Mantra",
|
||||||
|
pledge: pledge
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
next(error)
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
return router;
|
return router;
|
||||||
|
|||||||
23
server/views/pledge.pug
Normal file
23
server/views/pledge.pug
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
extend templates/layout.pug
|
||||||
|
|
||||||
|
block content
|
||||||
|
.container
|
||||||
|
.center
|
||||||
|
-
|
||||||
|
const totalSatoshis = pledge.translationArtifactVersionPledges.reduce((accumulator, translationArtifactVersionPledge) => {
|
||||||
|
return accumulator + translationArtifactVersionPledge.satoshis
|
||||||
|
}, 0)
|
||||||
|
h1 #{totalSatoshis} sats Pledge
|
||||||
|
|
||||||
|
p.flow-text
|
||||||
|
small #{pledge.entity.name}
|
||||||
|
br
|
||||||
|
span= pledge.message
|
||||||
|
|
||||||
|
p.flow-text for completion of the following translations
|
||||||
|
|
||||||
|
each translationArtifactVersionPledge in pledge.translationArtifactVersionPledges
|
||||||
|
|
||||||
|
p.flow-text #{translationArtifactVersionPledge.translationArtifactVersion.name} - #{translationArtifactVersionPledge.translationArtifactVersion.artifactVersion.artifact.name} - #{translationArtifactVersionPledge.translationArtifactVersion.artifactVersion.tag}
|
||||||
|
br
|
||||||
|
small #{translationArtifactVersionPledge.satoshis} sats
|
||||||
@@ -4,3 +4,16 @@ block content
|
|||||||
.container
|
.container
|
||||||
.center
|
.center
|
||||||
h1 Pledges
|
h1 Pledges
|
||||||
|
|
||||||
|
each pledge in pledges
|
||||||
|
-
|
||||||
|
const totalSatoshis = pledge.translationArtifactVersionPledges.reduce((accumulator, translationArtifactVersionPledge) => {
|
||||||
|
return accumulator + translationArtifactVersionPledge.satoshis
|
||||||
|
}, 0)
|
||||||
|
p.flow-text
|
||||||
|
a(href=`/pledges/${pledge.id}`) #{totalSatoshis} sats for #{pledge.translationArtifactVersionPledges.length} translations
|
||||||
|
br
|
||||||
|
small
|
||||||
|
small.chip= pledge.entity.name
|
||||||
|
br
|
||||||
|
small= pledge.message
|
||||||
Reference in New Issue
Block a user