-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BRP-5: Re-route duplicate application requests to separate email address. #769
base: master
Are you sure you want to change the base?
Changes from all commits
34ebc8e
4ac026d
f5a366c
63bdbc8
410f936
a08087d
9f65044
24fa5d7
b67f39f
14b05d5
26f999f
c564341
c08e1d1
17deefc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,7 @@ unit_tests: &unit_tests | |
|
||
sonar_scanner: &sonar_scanner | ||
pull: if-not-exists | ||
image: quay.io/ukhomeofficedigital/sonar-scanner-node:549b75f593f28da1c4a0a6f79877ec69d3b21037 | ||
image: quay.io/ukhomeofficedigital/sonar-scanner-nodejs:latest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s usually good idea to avoid latest as it will keep updating the image for every deployment to the latest one. Ideally it’ll be good to take a specific sha There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you give this one a try |
||
commands: | ||
- sonar-scanner -Dproject.settings=./sonar-project.properties | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{<partials-page}} | ||
{{$journeyHeader}} | ||
{{#t}}journeys.collection.header{{/t}} | ||
{{/journeyHeader}} | ||
{{$content}} | ||
{{<partials-form}} | ||
|
||
{{$form}} | ||
{{#radio-group}}previous-submission{{/radio-group}} | ||
<fieldset id="previous-submission-reference-group" class="panel-indent"> | ||
<div class="form-group"> | ||
{{#input-text}}submission-reference{{/input-text}} | ||
</div> | ||
</fieldset> | ||
|
||
{{#input-submit}}continue{{/input-submit}} | ||
{{/form}} | ||
{{/partials-form}} | ||
{{/content}} | ||
{{/partials-page}} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -6,12 +6,43 @@ const StatsD = require('hot-shots'); | |||||
const client = new StatsD(); | ||||||
const Model = require('../models/email'); | ||||||
|
||||||
const {customAlphabet} = require('nanoid'); | ||||||
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | ||||||
const nanoid = customAlphabet(alphabet, 9); | ||||||
|
||||||
function errorChecked(key, data) { | ||||||
if (data[key + '-checkbox']) { | ||||||
return key; | ||||||
} | ||||||
} | ||||||
|
||||||
function setSubmissionReference(data) { | ||||||
// This function is responsible for storing a submission referene if one is required | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
// Did the user say this is a resubmission? | ||||||
if (data['previous-submission'] === 'yes') { | ||||||
// Yes they did - Mark this as a resubmission for easier assessment when sending the email to caseworkers | ||||||
data['is-resubmission'] = true; | ||||||
// Did the user provide a reference for their previous submission? | ||||||
// If they did, we should keep it the same | ||||||
// If they did not, we should not populate the reference in | ||||||
// the emails that are sent out so ensure this remains undefined | ||||||
data['submission-reference'] = (data['submission-reference'] ? data['submission-reference'] : undefined); | ||||||
} else { | ||||||
data['is-resubmission'] = false; | ||||||
// It's a new submission so generate a reference | ||||||
data['submission-reference'] = nanoid(); | ||||||
} | ||||||
} | ||||||
|
||||||
function addSubmissionReference(data) { | ||||||
// If we do not already have a submission reference, create one and store it in our data object | ||||||
// We may want to re-use this later | ||||||
setSubmissionReference(data); | ||||||
// Ensure there's a space in front of it, since this is being appended to the end of the email subject | ||||||
return !!data['submission-reference'] ? ` Ref: ${data['submission-reference']}` : ''; | ||||||
} | ||||||
|
||||||
function checkedErrors(data) { | ||||||
const checked = _.filter(_.keys(data), valueKey => { | ||||||
return errorChecked(valueKey, data); | ||||||
|
@@ -20,10 +51,10 @@ function checkedErrors(data) { | |||||
} | ||||||
|
||||||
const serviceMap = { | ||||||
'/not-arrived': () => { | ||||||
'/not-arrived': data => { | ||||||
return { | ||||||
template: 'delivery', | ||||||
subject: 'Form submitted: Your BRP hasn\'t arrived.' | ||||||
subject: `Form submitted: Your BRP hasn\'t arrived.${addSubmissionReference(data)}` | ||||||
}; | ||||||
}, | ||||||
'/correct-mistakes': data => { | ||||||
|
@@ -34,26 +65,26 @@ const serviceMap = { | |||||
const suffix = data.triage ? '-triage' : ''; | ||||||
return { | ||||||
template: 'error' + suffix, | ||||||
subject: 'Form submitted: Report a problem with your new BRP (' + subjectErrors + ')' | ||||||
subject: `Form submitted: Report a problem with your new BRP (${subjectErrors}).${addSubmissionReference(data)}` | ||||||
}; | ||||||
}, | ||||||
'/lost-stolen': data => { | ||||||
const suffix = (data['inside-uk'] === 'yes') ? '-uk' : '-abroad'; | ||||||
return { | ||||||
template: 'lost-or-stolen' + suffix, | ||||||
subject: 'Form submitted: Report a lost or stolen BRP.' | ||||||
subject: `Form submitted: Report a lost or stolen BRP.${addSubmissionReference(data)}` | ||||||
}; | ||||||
}, | ||||||
'/collection': () => { | ||||||
'/collection': data => { | ||||||
return { | ||||||
template: 'collection', | ||||||
subject: 'Form submitted: Report a collection problem.' | ||||||
subject: `Form submitted: Report a collection problem.${addSubmissionReference(data)}` | ||||||
}; | ||||||
}, | ||||||
'/someone-else': () => { | ||||||
'/someone-else': data => { | ||||||
return { | ||||||
template: 'someone-else', | ||||||
subject: 'Form submitted: Report someone else collecting your BRP.' | ||||||
subject: `Form submitted: Report someone else collecting your BRP.${addSubmissionReference(data)}` | ||||||
}; | ||||||
} | ||||||
}; | ||||||
|
@@ -62,6 +93,8 @@ module.exports = superclass => class Emailer extends superclass { | |||||
saveValues(req, res, callback) { | ||||||
super.saveValues(req, res, () => { | ||||||
const data = _.pick(req.sessionModel.toJSON(), _.identity); | ||||||
|
||||||
// Generate a reference for this submission | ||||||
const service = serviceMap[req.baseUrl] && serviceMap[req.baseUrl](data); | ||||||
|
||||||
if (!service) { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use-strict'; | ||
|
||
module.exports = { | ||
'previous-submission': { | ||
mixin: 'radio-group', | ||
validate: ['required'], | ||
className: ['inline', 'form-group'], | ||
legend: { | ||
className: 'visuallyhidden' | ||
}, | ||
options: [{ | ||
value: 'yes', | ||
toggle: 'previous-submission-reference-group' | ||
}, { | ||
value: 'no' | ||
}] | ||
}, | ||
'submission-reference': { | ||
validate: [ {type: 'regex', arguments: /^[A-Za-z0-9]{9}$|(^$)+/g }], | ||
dependent: { | ||
field: 'previous-submission', | ||
value: 'yes' | ||
} | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"previous-submission": { | ||
"header": "Have you previously submitted this request?" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{<partials-page}} | ||
{{$journeyHeader}} | ||
{{#t}}journeys.error.header{{/t}} | ||
{{/journeyHeader}} | ||
{{$content}} | ||
{{<partials-form}} | ||
|
||
{{$form}} | ||
{{#radio-group}}previous-submission{{/radio-group}} | ||
<fieldset id="previous-submission-reference-group" class="panel-indent"> | ||
<div class="form-group"> | ||
{{#input-text}}submission-reference{{/input-text}} | ||
</div> | ||
</fieldset> | ||
|
||
{{#input-submit}}continue{{/input-submit}} | ||
{{/form}} | ||
{{/partials-form}} | ||
{{/content}} | ||
{{/partials-page}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{<partials-page}} | ||
{{$journeyHeader}} | ||
{{#t}}journeys.lost.header{{/t}} | ||
{{/journeyHeader}} | ||
{{$content}} | ||
{{<partials-form}} | ||
|
||
{{$form}} | ||
{{#radio-group}}previous-submission{{/radio-group}} | ||
<fieldset id="previous-submission-reference-group" class="panel-indent"> | ||
<div class="form-group"> | ||
{{#input-text}}submission-reference{{/input-text}} | ||
</div> | ||
</fieldset> | ||
|
||
{{#input-submit}}continue{{/input-submit}} | ||
{{/form}} | ||
{{/partials-form}} | ||
{{/content}} | ||
{{/partials-page}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{<partials-page}} | ||
{{$journeyHeader}} | ||
{{#t}}journeys.delivery.header{{/t}} | ||
{{/journeyHeader}} | ||
{{$content}} | ||
{{<partials-form}} | ||
|
||
{{$form}} | ||
{{#radio-group}}previous-submission{{/radio-group}} | ||
<fieldset id="previous-submission-reference-group" class="panel-indent"> | ||
<div class="form-group"> | ||
{{#input-text}}submission-reference{{/input-text}} | ||
</div> | ||
</fieldset> | ||
|
||
{{#input-submit}}continue{{/input-submit}} | ||
{{/form}} | ||
{{/partials-form}} | ||
{{/content}} | ||
{{/partials-page}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{<partials-page}} | ||
{{$journeyHeader}} | ||
{{#t}}journeys.someone-else.header{{/t}} | ||
{{/journeyHeader}} | ||
{{$content}} | ||
{{<partials-form}} | ||
|
||
{{$form}} | ||
{{#radio-group}}previous-submission{{/radio-group}} | ||
<fieldset id="previous-submission-reference-group" class="panel-indent"> | ||
<div class="form-group"> | ||
{{#input-text}}submission-reference{{/input-text}} | ||
</div> | ||
</fieldset> | ||
|
||
{{#input-submit}}continue{{/input-submit}} | ||
{{/form}} | ||
{{/partials-form}} | ||
{{/content}} | ||
{{/partials-page}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it doesn't work just add a comment saying usually good practice is to have a version number a sha pointing to the image because you don't want to grab the latest one in case it gets updated