-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4414 from NMDSdevopsServiceAdm/test
Test > Live: registration bug fixes, admin inactive emails, CQC main service change, parent requests main page
- Loading branch information
Showing
53 changed files
with
2,515 additions
and
323 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
migrations/20211209165709-addReviewAndInReviewColumnsToApprovalsTable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict'; | ||
|
||
const table = { | ||
tableName: 'Approvals', | ||
schema: 'cqc', | ||
}; | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.sequelize.transaction(async (transaction) => { | ||
await Promise.all([ | ||
queryInterface.addColumn( | ||
table, | ||
'Reviewer', | ||
{ | ||
type: Sequelize.DataTypes.TEXT, | ||
allowNull: true, | ||
}, | ||
{ transaction }, | ||
), | ||
queryInterface.addColumn( | ||
table, | ||
'InReview', | ||
{ | ||
type: Sequelize.DataTypes.BOOLEAN, | ||
defaultValue: false, | ||
}, | ||
{ transaction }, | ||
), | ||
]); | ||
}); | ||
}, | ||
|
||
down: async (queryInterface) => { | ||
await queryInterface.seqeulize.transaction(async (transaction) => { | ||
await Promise.all([ | ||
queryInterface.removeColumn(table, 'Reviewer', { transaction }), | ||
queryInterface.removeColumn(table, 'InReview', { transaction }), | ||
]); | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.query( | ||
`ALTER TYPE cqc."enum_Approvals_Status" ADD VALUE IF NOT EXISTS 'In progress'`, | ||
); | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
const query = `DELETE FROM pg_enum WHERE enumlabel = cqc."enum_Approvals_Status" | ||
AND enumtypid = (SELECT oid FROM pg_type WHERE typname = cqc."enum_Approvals_Status)`; | ||
return queryInterface.sequelize.query(query); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
up: async (queryInterface) => { | ||
return queryInterface.sequelize.query( | ||
'UPDATE cqc."Establishment" SET "Archived" = true WHERE "Status" = \'REJECTED\';', | ||
); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const models = require('../../../models'); | ||
|
||
const updateStatus = async (req, res) => { | ||
try { | ||
const { uid, status, reviewer, inReview } = req.body; | ||
const establishment = await models.establishment.findByUid(uid); | ||
|
||
if (!establishment) { | ||
return res.status(400).send({ error: 'Workplace could not be found' }); | ||
} | ||
|
||
const approval = await models.Approvals.findbyEstablishmentId(establishment.id, 'CqcStatusChange'); | ||
|
||
if (!approval) { | ||
return res.status(400).send({ error: 'CQC status change request could not be found' }); | ||
} | ||
|
||
if (approval.InReview && reviewer && approval.Reviewer !== reviewer) { | ||
return res.status(400).send({ error: 'This CQC status change request is already being reviewed' }); | ||
} | ||
|
||
approval.Status = status; | ||
approval.Reviewer = reviewer; | ||
approval.InReview = inReview; | ||
await approval.save(); | ||
|
||
res.status(200).send(); | ||
} catch (error) { | ||
console.log(error); | ||
res.status(500).send(); | ||
} | ||
}; | ||
|
||
const router = require('express').Router(); | ||
|
||
router.route('/').post(updateStatus); | ||
|
||
module.exports = router; | ||
module.exports.updateStatus = updateStatus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.