Commit Graph

7984 Commits

Author SHA1 Message Date
Pea Tyczynska
e0c73ac342 Send daily email with letter and sheet volumes to DVLA 2021-02-23 15:13:19 +00:00
Pea Tyczynska
6dab63130d Make import order alphabetical 2021-02-23 15:13:19 +00:00
Pea Tyczynska
c8ffebcce8 Query to get letter and sheet volumes
So we can send daily email with these volumes to DVLA.
2021-02-23 15:13:18 +00:00
Pea Tyczynska
88233543c3 Add email template for daily letter volumes 2021-02-23 15:13:18 +00:00
David McDonald
d7426c0c42 Merge pull request #3158 from alphagov/mnos-prod
Turn on o2 and three mnos in prod
2021-02-23 14:26:58 +00:00
David McDonald
c03ad82227 Turn on o2 and three mnos in prod
Supporting infrastructure is ready for these two mnos
2021-02-23 13:56:47 +00:00
Ben Thorner
71bf89bf0c Merge pull request #3150 from alphagov/refresh-dev-tasks
Simplify README and consolidate scripts
2021-02-22 13:20:49 +00:00
Ben Thorner
f2c6a49ab6 Update install instructions for Postgres
This apps works with v11, but not with v13. Adding '|| true' in the
Makefile means the 'bootstrap' rule can be run multiple times, even
if the DB already exists.
2021-02-22 12:41:35 +00:00
Rebecca Law
965a2ff0cb Merge pull request #3145 from alphagov/add-caching-send-to-provider
Add caching and remove extra call to database
2021-02-22 08:53:20 +00:00
Leo Hemsted
079e1cd034 Merge pull request #3156 from alphagov/cronitor
make sure status is always set by finally block
2021-02-19 10:04:55 +00:00
Leo Hemsted
6a859982d0 make sure status is always set by finally block
confusingly, some errs are not subclasses of Exception (things like sys.exit()). Lets make sure the status is always set so cronitor knows what to ping.
2021-02-18 18:27:41 +00:00
Leo Hemsted
b2cf8cc5de Merge pull request #3152 from alphagov/retry-bug-fix
Retry bug fix
2021-02-18 13:42:11 +00:00
Rebecca Law
b464894325 update to check for instance of SerialisedService 2021-02-18 12:54:22 +00:00
Leo Hemsted
0088bcd98b only retry if the broadcast message task is in sending
previously we would retry if the task was queued up for retry but the
status is in "received-ack" or "received-err". We don't expect that a
task will be retried after getting this status, but if there are
duplicate tasks that could happen. Lets plan for the worst by saying
"only process a retry if the task is currently in sending".

this way, if a duplicate task is on retry and the first task goes
through succesfully, the duplicate task will give up.
2021-02-18 12:03:36 +00:00
Leo Hemsted
90e82aff3e properly log the lambda response correctly
boto returns a `StreamingBody`[1] response rather than a json struct.
We're currently just logging things like "Error calling lambda
o2-1-proxy with function error <botocore.response.StreamingBody object
at 0x7f74cd6e02e8>" which is obviously less than ideal. Also make the
tests properly reflect this - annoyingly it appears like we can't use
moto to reliably test this interface as the moto `mock_lambda` decorator
needs you to be running inside a docker container??

[1] https://botocore.amazonaws.com/v1/documentation/api/latest/reference/response.html#botocore.response.StreamingBody
2021-02-18 11:51:38 +00:00
Ben Thorner
126d810d5a Merge pull request #3147 from alphagov/remove-redundant-task
Remove redundant (renamed) letters task
2021-02-18 10:49:46 +00:00
Katie Smith
ac11de89d3 Merge pull request #3144 from alphagov/🚮-an-email
Stop emailing Notify when an MOU is signed
2021-02-18 09:20:36 +00:00
Ben Thorner
5ff7c2013e Swap FLASK_DEBUG for FLASK_ENV
This achieves the same thing and gets rid of the warning about being
in a production environment when the app starts up.
2021-02-18 09:11:16 +00:00
Katie Smith
c77e73b26f Fix failing test
This was passing locally, but failing on Concourse due to a different
order of TemplateHistory items being returned. This changes the
test so that it can't randomly fail based on the order of template
history items returned.
2021-02-18 09:07:21 +00:00
Katie Smith
c59e0091ee Stop emailing Notify when an MOU is signed
We've decided we don't get any value from these emails any more, so this
stops us (Notify support) receiving them. We still let teams know an MOU
has been signed.
2021-02-18 09:07:19 +00:00
Ben Thorner
af95ad68ea Move bootstrap tasks into the Makefile
This is more consistent with how we run all other tasks. Note that
the virtual env setup is not generally applicable, and developers
of this repo should follow the guidance in the README.
2021-02-18 09:01:32 +00:00
Ben Thorner
dc6fb1d1f2 Remove unused single test script 2021-02-18 09:01:31 +00:00
Ben Thorner
5ad821428b Make instructions to run app/tests more concise 2021-02-18 09:01:30 +00:00
Ben Thorner
273fd339ac Clarify setup instructions for environment.sh 2021-02-18 09:01:29 +00:00
Ben Thorner
de6ed47239 Revise section about AWS setup
This is covered in Wiki in more detail.
2021-02-18 09:01:28 +00:00
Ben Thorner
89dc7218fe Remove section about virtualenv
This is covered generically in the Wiki [1].

[1]: https://github.com/alphagov/notifications-manuals/wiki/Getting-Started#development-environment
2021-02-18 09:01:27 +00:00
Ben Thorner
ba4d399982 Switch to 'make' for running app processes
These are simple enough that they don't need their own scripts.
2021-02-18 09:01:26 +00:00
Ben Thorner
4c0aea50ae Remove redundant Docker tasks
Nothing and no one uses these.
2021-02-18 09:01:25 +00:00
Rebecca Law
933bad857a Merge pull request #3146 from alphagov/use-number-for-international-text
Send text messages from a number for international
2021-02-17 13:31:42 +00:00
Rebecca Law
77b76ea0a4 Rename variable, it's a better name now. 2021-02-17 13:15:29 +00:00
Ben Thorner
474b93f183 Remove redundant (renamed) letters task
This was renamed in [1], and enough time has elapsed that instances
of the task should all have finished processing.

[1]: 5d6f2da155
2021-02-17 12:57:50 +00:00
Rebecca Law
88036befcf Merge branch 'master' into add-caching-send-to-provider 2021-02-17 12:40:18 +00:00
Rebecca Law
e77534fb17 Send text message that are to an international number from a number rather than "Notify"
Update `send_user_2fa_code` to send from number when recipient is international
Update `update_user_attribute` to send from number when recipient is international
2021-02-17 12:14:47 +00:00
Chris Hill-Scott
8e8601338e Merge pull request #3136 from alphagov/validate-template-length-broadcast-api
Validate content length on broadcast API
2021-02-17 11:34:29 +00:00
Rebecca Law
dd686bd7a8 Add caching and remove extra call to database
Add caching by using the SeriralisedTemplate and SerialisedService objects
Removed extra call to the database to fetch the notification after the commit by saving the created_at and key_type to a local variable. After the update to the notification to mark it as sending the db.session is committed. Any reference to the the Notification data model after that will require a query to fetch the object again because it is considered "dirty" or out of date.
Added name, sms_prefix and email branding to SerialisedService.
Refactor the get_html_options to work with the SerialisedService object.
Removed the need to validate and format the to field by using `normalised_to`, since when persisting the notification the `normalised_to` field has already had this done.
Removed the validate and format for reply_to_text for email reply_to, this has been done when the email address has been added via the frontend, no need to validate this address every time a services sends an email.
2021-02-16 14:53:58 +00:00
David McDonald
75f8db19eb Merge pull request #3120 from alphagov/update-service-broadcast-settings
Update service broadcast settings
2021-02-16 14:50:18 +00:00
Leo Hemsted
24dbcaa137 Merge pull request #3143 from alphagov/flake8
flake8
2021-02-16 12:35:09 +00:00
Leo Hemsted
bbab7437f4 flake8 2021-02-16 12:23:02 +00:00
Leo Hemsted
f00cd16c27 Merge pull request #3139 from alphagov/broadcasts-prod
enable cell broadcast on prod for vodafone only
2021-02-16 11:50:43 +00:00
David McDonald
abb3b3307c Fix flake8 2021-02-16 10:31:12 +00:00
David McDonald
6fcda6debb Make set_as_broadcast_service use a single DB commit
We don't want things in a half state if there is an error during the
method. Therefore, we move it all into a single function that is wrapped
in a transaction.

Note, we copy the approach of
https://github.com/alphagov/notifications-api/blob/master/app/dao/services_dao.py#L293
by having a single new dao function that does all the DB work.
2021-02-16 10:31:11 +00:00
David McDonald
f9c87bafa3 Add go_live_at timestamp to set_as_broadcast_service
Note, I haven't added anything for the `go_live_user` because it doesn't
quite make sense because here a user isn't requesting to go live. So
there should be no reason to record this.

We will in time though want to add audit events to capture every change
to the service broadcast settings, that will actually capture who has
done what.
2021-02-16 10:31:10 +00:00
David McDonald
42163813fe Hardcode service broadcast channel that API shows
We are in a weird situation where at the moment, we have services with
the broadcast permission that do not have a row in the
service_broadcast_settings table and therefore do not have defined
whether they should send messages on the 'test' or 'severe' channel.

We currently get around this when we send broadcast messages out as
such:
https://github.com/alphagov/notifications-api/blob/master/app/celery/broadcast_message_tasks.py#L51

We need to something equivalent for the broadcast channel that the API
says the service is on. In time, when we have added a row in the
service_broadcast_settings table for every service with the broadcast
permission then we can remove both of these two hardcodings.

Note, one option would have been to move the default of `test` on to the
`Service` model rather than having it in both the
broadcast_message_tasks file and the `ServiceSchema` class. However, I
went for the quickest thing which was to add it here.
2021-02-16 10:31:09 +00:00
David McDonald
d846ed79d2 Improve tests and remove unneeded code
Some of the fixtures weren't needed so have been removed.

I've also moved from using `client.post` to using `admin_request.post`
which saves a bit of code too.

Also one small assertion tidied up to make it a bit stronger regarding
permissions.
2021-02-16 10:31:09 +00:00
David McDonald
4f7afa3fbe Set provider restriction 2021-02-16 10:31:08 +00:00
David McDonald
cb70b81ea4 make service live or training 2021-02-16 10:31:07 +00:00
David McDonald
9f4b82f074 Make service a member of the broadcast organisation
We will use this to easily identify all our broadcast services. There
could be other ways to deal with finding and seeing all broadcast
services but this is a good and easy way to start.
2021-02-16 10:31:06 +00:00
David McDonald
cdcbd1e238 Set count as live to false for broadcast services
We think it would be a security risk to show the name of services
involved in emergency alerts as they be responsible for things such as
counter terrorism.

On top of that, showing broadcast services in the list of all services
could enable someone to use that information to try and trick an admin
into letting them access of a particular service given the fact they
know the name of it
2021-02-16 10:31:05 +00:00
David McDonald
54b9d20f73 Give broadcast permission to broadcast services 2021-02-16 10:31:04 +00:00
David McDonald
3f16549f64 Use sample_broadcast_service for update test
We can use the `sample_broadcast_service` as this gives us a broadcast
service with service broadcast settings already for us to update rather
than needing to create our own settings db row
2021-02-16 10:31:03 +00:00