Commit Graph

6540 Commits

Author SHA1 Message Date
Rebecca Law
fdee6cbfb2 As per PR comments:
- Remove Organisation.services
- added backref='services' to Services.organisation relationship and removed redundant foreign_keys argument.
2019-08-14 13:23:20 +01:00
Rebecca Law
c4127d0508 Improve the data migration and downgrade script. 2019-08-14 11:01:22 +01:00
Rebecca Law
55dc7184cc Add organisation_id to Service.
This is the second commit in the series to add organisation_id to Service.
- Data migration to update services.organisation_id from data in organisation_to_service
 (The rollback will lose any updates to organisation unless the script is updated to set organistion_to_service from service.organisation_id )
- Update Service.organisation relationship to a ForeignKey relationship to Organisation.
- Update Organisation.services to a backref relationship to Service.
2019-08-13 17:25:30 +01:00
Rebecca Law
515d6602c1 Merge pull request #2583 from alphagov/add-org-id-to-services
Add org id to services
2019-08-13 11:05:29 +01:00
Rebecca Law
cc7008c129 Merge pull request #2584 from alphagov/fix-error-for-tech-failure
Update NotificationTechnicalFailureException
2019-08-13 09:59:57 +01:00
Rebecca Law
ae1bc54f9e Update NotificationTechnicalFailureException
- Change the NotificationTechnicalFailureException so that it only inherits from Exception.
- The notify_celery task should create the logging message on failure.
- Fix unit tests
- Remove named parameter when raising exception.
2019-08-12 16:51:39 +01:00
Rebecca Law
12f305bf86 - Migration to add Service.organisation_id
- Add oranisation_id to Service data model.
- Update methods to create service and associate service to organisation to set the organisation_id on the Service.
- Create the missing test, if the service user email matches a domain for an organisation then associate the service to the organisation and inherit crown and organisation_type from the organisation.
2019-08-12 16:03:02 +01:00
Katie Smith
6ea849298e Merge pull request #2580 from alphagov/set-bad-email-addresses-to-perm-fail
Set bad email addresses to permanent-failure
2019-08-12 16:03:01 +01:00
Leo Hemsted
9d8e8747d1 Merge pull request #2582 from alphagov/punycode
punycode encode emails before sending
2019-08-12 15:16:44 +01:00
Katie Smith
f4c476f0bc Merge pull request #2581 from alphagov/mini-revert
Revert "Change email status to permanent-failure if SES raises InvalidParameterValue"
2019-08-12 14:00:27 +01:00
Leo Hemsted
09d6c60ff1 punycode encode emails before sending
amazon SES only accepts domains encoded in punycode, an encoding that
converts utf-8 into an ascii encoding that browsers and mailservers
recognise.

We currently just send through emails as we store them (in full
unicode), which means any rogue characters break SES and cause us to
put the email in technical-failure. Most of these appear to be typos
and rogue control characters, but there is a small chance that it could
be a real domain (eg https://🅂𝖍𝐤ₛᵖ𝒓.ⓜ𝕠𝒃𝓲/🆆🆃🅵/).

We should encode to and reply-to-address emails as punycode to make
sure that they can always be sent. The chance that anyone actually uses
a unicode domain name for their email is probably pretty low, but we
should allow it for completeness.
2019-08-12 13:53:22 +01:00
Katie Smith
355fb07eb2 Revert "Change email status to permanent-failure if SES raises InvalidParameterValue"
This reverts commit 51716fbaf8.

Instead of relying on catching SES errors we will convert all emails to
punycode before sending instead.
2019-08-12 13:51:24 +01:00
Katie Smith
c99cd0d9a9 Merge pull request #2580 from alphagov/set-bad-email-addresses-to-perm-fail
Set bad email addresses to permanent-failure
2019-08-12 13:24:27 +01:00
Katie Smith
3b670a0dbe Delete unused delivery blueprint 2019-08-12 10:54:11 +01:00
Katie Smith
51716fbaf8 Change email status to permanent-failure if SES raises InvalidParameterValue
If SES raised an `InvalidParameterValue` error (because an email address
was wrong) we were logging an exception and setting the email status to
`technical-failure`. We now set it to `permanent-failure` instead and
change the log level to `info` - setting it to `permanent-failure` means
that people will know not to retry the message.
2019-08-12 10:24:59 +01:00
Katie Smith
6ab6f09b7b Merge pull request #2579 from alphagov/fix-migration-name
Rename migration file to match migration revision ID
2019-08-09 13:59:15 +01:00
Katie Smith
b31e431d4e Rename migration file to match migration revision ID
Because these were slightly different, the `check_if_new_migration`
script would always think there was a new migration to run and so we
were always testing the db migrations when deploying.
2019-08-09 12:41:19 +01:00
Katie Smith
a02bca141d Merge pull request #2577 from alphagov/fast-sms-retry
Retry deliver_sms task immediately if sending fails
2019-08-09 11:44:32 +01:00
Katie Smith
e449e234db Retry deliver_sms task immediately if sending fails
If the `deliver_sms` catches an exception when trying to send an SMS, we
want the first retry to happen immediately (because we will have
switched providers), then every retry after that to happen at the
standard intervals.
2019-08-08 09:34:38 +01:00
Rebecca Law
eda0640869 Merge pull request #2578 from alphagov/use-scheduled-for-date
Use scheduled_for datetime for purging CSV files
2019-08-08 09:33:39 +01:00
Rebecca Law
16fd12be6a If a job was created 7 days ago but scheduled to send 2 days later, the csv file will be deleted from S3 two days early.
For example if a file is uploaded on Aug 1, but scheduled for Aug 3, the csv file will be deleted 2 days before the notifications.
This will cause an error for on the jobs pages if the download report link is clicked.
2019-08-07 16:54:04 +01:00
Katie Smith
328832f21f Merge pull request #2574 from alphagov/upload-letters-permission
Add new 'upload_letters' permission
2019-08-05 15:06:49 +01:00
Katie Smith
f8035811a7 Add new 'upload_letters' permission 2019-08-05 12:02:43 +01:00
Andy Paine
daa437e42c Merge pull request #2573 from alphagov/use-paas-statsd-exporter
REP-340: Use PaaS statsd exporter
2019-08-05 11:22:35 +01:00
Andy Paine
088f234185 REP-340: Use PaaS statsd exporter
- We are running the statsd-exporter on the PaaS now so we can use the
  internal UDP route to talk to it
- Only update in preview and staging still so that we can get the
  dashboards fully up to date before switching prod
2019-08-05 10:36:58 +01:00
Leo Hemsted
4056e335cc Merge pull request #2572 from alphagov/utils-bump
bump utils
2019-08-02 13:04:57 +01:00
Leo Hemsted
9726edf68d bump utils
also remove the `read().splitlines()` pattern from csv.reader usage,
as it's redundant. also add .vscode to gitignore to accomodate my
hipster IDE choices, and add some lines to pytest.ini so just running
`py.test` uses some useful flags
2019-08-02 12:41:03 +01:00
Leo Hemsted
832ca8775f Merge pull request #2569 from alphagov/lower-dvla-zip-size
Lower the max dvla zip size from 500mb to 40mb
2019-07-31 16:14:26 +01:00
Rebecca Law
2b0ef807d6 Merge pull request #2568 from alphagov/add-nhs-trust-org
Add email and letter branding to the add organisation command
2019-07-30 14:49:22 +01:00
Rebecca Law
b39da01573 Remove white space from email branding column. 2019-07-30 14:34:23 +01:00
Leo Hemsted
2b06e810c5 Lower the max dvla zip size from 500mb to 40mb
There's a bug in pysftp that appears to cause quadratic performance loss. See https://github.com/paramiko/paramiko/issues/1141 for more details.

As a temporary band-aid fix, lower the size of the files we're sending.
2019-07-29 17:23:22 +01:00
Leo Hemsted
de42b1004d Merge pull request #2567 from alphagov/handle-405s
handle 405s
2019-07-29 16:28:27 +01:00
Rebecca Law
467d9780c1 Add email and letter branding to the add organisation command (by csv file) 2019-07-29 15:35:54 +01:00
Leo Hemsted
2c2eb2abad handle 405s
Handle werkzeug http errors separately. Also, improve the generic
`Exception` handler to be more flexible when exceptions don't look
like http errors.

note: because they're 405s the route isn't matched, so the v2 error
handlers don't trip properly. this might be an issue because the
internal endpoints expect a different return format. Might have to
think about how to handle this.
2019-07-26 13:26:20 +01:00
Pea (Malgorzata Tyczynska)
359016de6a Merge pull request #2565 from alphagov/migrate_org_types
Migrate org types
2019-07-26 10:51:42 +01:00
Pea Tyczynska
5977adef1c Add live to excluded environments in migration 2019-07-25 16:03:08 +01:00
Pea Tyczynska
38bb2c1cf6 Simpify org types migration script and introduce foreign key
Don't transform org types on prod
2019-07-24 17:55:56 +01:00
Katie Smith
d8d85db7c3 Merge pull request #2564 from alphagov/engagement-team-report
Add endpoint with data for report for the engagement team
2019-07-23 10:13:14 +01:00
Katie Smith
b4a6aecbb9 Add endpoint to return monthly notification stats per service
This will be used by notifications-admin to create a CSV report.
2019-07-23 10:00:50 +01:00
Katie Smith
81de71dc1f Add dao function that gets the required data 2019-07-23 10:00:50 +01:00
Pea Tyczynska
5b256fa64e Migrate all orgs and services onto new organisation types
Remove all mentions of generic 'nhs' organisation type.
2019-07-22 14:58:41 +01:00
Pea (Malgorzata Tyczynska)
da61bb3b06 Merge pull request #2557 from alphagov/more_org_types
Introduce new organisation types and organisation_types db table
2019-07-22 14:55:30 +01:00
Pea (Malgorzata Tyczynska)
c0966ad90d Merge pull request #2563 from alphagov/change_content_cancel_letter_job
Change content of error messages when letter job can't be cancelled.
2019-07-22 13:28:11 +01:00
Chris Hill-Scott
01c4ec3e68 Merge pull request #2554 from alphagov/dissociate-default-template-replies
Dissociate letter contact blocks before archiving
2019-07-22 11:55:29 +01:00
Pea (Malgorzata Tyczynska)
957cf46748 Change apostrophes to prettier ones
Co-Authored-By: Chris Hill-Scott <me@quis.cc>
2019-07-22 10:48:34 +01:00
Chris Hill-Scott
da1219fadf Let services have no default letter contact blocks
If they delete the default we’ll treat ‘Blank’ as the default on the
frontend.
2019-07-22 10:40:18 +01:00
Chris Hill-Scott
dd225fbc6e Dissociate letter contact blocks before archiving
Otherwise you can’t archive it.
2019-07-19 15:40:28 +01:00
Pea Tyczynska
edda816ffa Temporarily add generic 'nhs' 2019-07-19 15:13:24 +01:00
Pea Tyczynska
aa88252cf7 Drop making crown not nullable on downgrade as it would fail anyway 2019-07-18 17:05:24 +01:00
Pea Tyczynska
610bf5d149 For now include nhs type orgs in allowed organisation types 2019-07-18 17:05:24 +01:00