Skip to content

Commit

Permalink
Merge pull request #163 from AtelierdeParis/feature/152-badge-applica…
Browse files Browse the repository at this point in the history
…tion

feat: add badge
  • Loading branch information
baptadn authored Jan 17, 2025
2 parents 50a9597 + f377d66 commit cf98804
Show file tree
Hide file tree
Showing 17 changed files with 685 additions and 305 deletions.
10 changes: 10 additions & 0 deletions back/api/application/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@
"config": {
"policies": ["is-admin"]
}
},
{
"method": "GET",
"path": "/applications/preselected/:id/count",
"handler": "application.getPreselectedApplicationsCount",
"config": {
"policies": [],
"operationId": "getPreselectedApplicationsCount",
"description": "Get the number of preselected applications for a specific application"
}
}
]
}
15 changes: 15 additions & 0 deletions back/api/application/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,19 @@ module.exports = {

return applications
},
async getPreselectedApplicationsCount(ctx) {
const { id } = ctx.params
const applications = await strapi.services.application.find(
{
id,
status: ['validated', 'confirmed'],
},
[
'id',
],
)


return { count: applications?.length || 0 }
},
}
68 changes: 68 additions & 0 deletions back/api/application/documentation/1.0.0/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,74 @@
}
]
}
},
"/applications/preselected/{id}/count": {
"get": {
"deprecated": false,
"description": "Get the number of preselected applications for a specific application",
"responses": {
"200": {
"description": "response",
"content": {
"application/json": {
"schema": {
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"summary": "",
"tags": [
"Application"
],
"parameters": [
{
"name": "id",
"in": "path",
"description": "",
"deprecated": false,
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
},
"components": {
Expand Down
8 changes: 8 additions & 0 deletions back/api/campaign/config/routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@
"policies": []
}
},
{
"method": "GET",
"path": "/campaigns/:id/send-admin-preselections-email",
"handler": "campaign.sendAdminPreselectionsEmail",
"config": {
"policies": []
}
},
{
"method": "GET",
"path": "/campaigns/:id/redirect-to-export",
Expand Down
7 changes: 7 additions & 0 deletions back/api/campaign/controllers/campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ module.exports = {
const campaign = await strapi.services.campaign.findOne({ id: ctx.params.id })
await strapi.services.campaign.sendEspacePreselectionEmail(campaign.id)

return ctx.send({ success: true })
},
async sendAdminPreselectionsEmail(ctx) {
const campaign = await strapi.services.campaign.findOne({ id: ctx.params.id })
await strapi.services.campaign.sendAdminPreselectionsEmail(campaign)


return ctx.send({ success: true })
},
async redirectToExport(ctx) {
Expand Down
68 changes: 68 additions & 0 deletions back/api/campaign/documentation/1.0.0/campaign.json
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,74 @@
]
}
},
"/campaigns/{id}/send-admin-preselections-email": {
"get": {
"deprecated": false,
"description": "",
"responses": {
"200": {
"description": "response",
"content": {
"application/json": {
"schema": {
"properties": {
"foo": {
"type": "string"
}
}
}
}
}
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"default": {
"description": "unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"summary": "",
"tags": [
"Campaign"
],
"parameters": [
{
"name": "id",
"in": "path",
"description": "",
"deprecated": false,
"required": true,
"schema": {
"type": "string"
}
}
]
}
},
"/campaigns/{id}/redirect-to-export": {
"get": {
"deprecated": false,
Expand Down
14 changes: 9 additions & 5 deletions back/api/campaign/services/campaign.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ module.exports = {
},
{
campaing_title: campaign.title,
url_btn: `${process.env.FRONT_URL}/api/pdfs/selected/${campaign.id}`,
url_btn: `${process.env.FRONT_URL}/api/pdfs/campaign/${campaign.id}`,
},
true,
)
Expand Down Expand Up @@ -204,10 +204,14 @@ module.exports = {
{
user_name: place.name,
campaign_name: campaign.title,
espaces: Object.values(place.espaces).map(espace => ({
...espace,
disponibilities: espace.disponibilities.filter(d => d.is_validated)
})),
espaces: Object.values(place.espaces)
.filter(espace => {
return espace.disponibilities && espace.disponibilities.length > 0
})
.map(espace => ({
...espace,
disponibilities: espace.disponibilities.filter(d => d.is_validated)
})),
user_type: 'place',
},
)
Expand Down
Loading

0 comments on commit cf98804

Please sign in to comment.