Commit Graph

2591 Commits

Author SHA1 Message Date
Rebecca Law
03deb804b0 -Fix typo
- return template from dao not the history
2018-01-10 13:32:54 +00:00
Rebecca Law
e59d6d470e Fix the problem with updating the reply_to or service_letter_contact_id for templates.
The history was not being updated properly, we think this is because the declaritive attribute is not being set propery by the property.
When reply_to: None it will update the service_letter_contact_id, but not the service_letter_contact, we think when the history_meta is build the history class and checking if the value is updated it depends which attribute it is checking first.

In order to fix this issue, there is a new dao method to update the reply_to on the Template and insert a new Template history.
2018-01-10 12:40:14 +00:00
Rebecca Law
cc839562da Fix the template history when updating the reply_to for a template.
It seems selecting the service_letter_contact in the validation method was causing SQLAlchemy to persist the object. When the dao was called to save the object nothing was different so we didn't persist the history object.

It may be time to take another look at how we version. :(
2018-01-09 16:41:58 +00:00
Alexey Bezhan
d82801fa5d Remove unused PERFORMANCE_PLATFORM_TOKEN config variable 2018-01-09 10:45:03 +00:00
Alexey Bezhan
e02c8339e7 Remove cloudfoundry config parsing logic
By replacing user-provided services with manifest environment variables
we avoid the need to set the application environment variables from the
service data.

Most of the variable names already match the service JSON keys, but we
need to rename the ones that don't (eg MMG and Firetext `api_key`) this
is done in a separate credentials PR.
2018-01-09 10:45:03 +00:00
Rebecca Law
1634bfb7ad Use the default reply_to from template 2018-01-08 17:11:41 +00:00
Rebecca Law
a052020f84 - simplify if statement
- use the template.get_reply_to_text() in send_notification, it's already using the right thing.
2018-01-08 16:54:19 +00:00
Rebecca Law
d6683d9630 If template has a default address use that address ELSE the address is blank. 2018-01-08 15:54:58 +00:00
Rebecca Law
5be5e17e46 Because life is difficult today...
Need to alter the column to nullable and remove reference to the column in any code. Next PR will drop column
2018-01-05 15:55:02 +00:00
Richard Chapman
b90ee832a7 Moved the SQL Alchemy config from staging to all environments
During database upgrades and database fail overs there has been errors
because the database connection stays open, when a query is run the
query fails and the connection is re-established. To avoid these errors
shorter timeouts have been used to keep the connections from getting
stale.

-  SQLALCHEMY_POOL_TIMEOUT timeout idle connections after 30 secs
- Updated SQLALCHEMY_POOL_RECYCLE to recycle the connection every 5 mins

See guide on optimistic disconnect handling - using the pool recycle
as a way to manage this:
http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-optimistic
2018-01-05 05:53:40 +00:00
Rebecca Law
0c5625fb8b Fix the schema for reply_to and added reply_to_text. 2018-01-04 15:56:58 +00:00
Rebecca Law
6e6f388f88 Merge branch 'master' into update_template_schema 2018-01-04 11:45:36 +00:00
Rebecca Law
6a3831eace Added a boolean column to templates called is_letter_contact_blank.
If is_letter_contact_blank then the user has set the letter contact block to be blank on purpose
ELSE IF is_letter_contact_blank is false THEN use the template default
IF template default is blank THEN the service_letter_contact is blank use the service default
2018-01-04 11:33:10 +00:00
Katie Smith
83711a9a0d Remove the delivery receipt callback for letters
This has been removed because the services only see one status.

Pivotal story: https://www.pivotaltracker.com/story/show/153674962
2018-01-03 16:41:10 +00:00
Rebecca Law
33e8e55dc6 Update the tests and revert adding the service_letter_contact_id 2018-01-03 15:30:26 +00:00
Rebecca Law
8732506138 Add reply_to in the template schema 2018-01-03 15:10:16 +00:00
Katie Smith
644b110a8d Group letters into a max number of files for sending to DVLA
Grouping the letters into a maximum number of files is necessary because
the SQS task needs to be under a certain size. We also compress the task
when sending.
2018-01-03 11:31:22 +00:00
Chris Hill-Scott
a6a44987a1 Allow admin to domain to use for invite links
When we’re doing user research we often:
- start the task by inviting the participant to a service on Notify
- have them use a prototype version of the admin app, hosted on a
  different domain

Currently we can’t do both of these things together, because the invite
emails always send people to `notifications.service.gov.uk` (because
it’s the API that sends the emails, and the prototype admin app points
at the production API).

This commit changes the API to optionally allow an instance of the admin
app to specify which domain should be used when generating invite links.
2018-01-03 10:47:16 +00:00
Alexey Bezhan
7df9fdf42a Normalize outbound SMS sender number in notifications API
Some of the tests don't set up a service sms_sender, so we need to
check if it's None before trying to format the number.
2018-01-03 10:32:34 +00:00
Alexey Bezhan
d5b6bd85fe Normalize outbound SMS sender number in one off notifications 2018-01-03 10:32:34 +00:00
Alexey Bezhan
545ff7dda6 Normalize outbound SMS number for job notifications
Replaces 0 with 44 in UK SMS sender number to make it possible to
respond to the SMS from an international number.
2018-01-03 10:32:34 +00:00
Leo Hemsted
9debc96c8c exclude non-pdfs from collate task
and fix celery kwargsg
2018-01-02 10:39:21 +00:00
Leo Hemsted
309b4d7d33 add collate-letter-pdfs task
add collate-letter-pdfs task (name pending). This retrieves a list of
letter pdf files (just the metadata, not the actual data) from s3, and
loops through them, calling the ftp task zip-and-send-letter-pdfs. It
groups them up by adding them to lists while counting the total
filesize, if it gets over a certain filesize (currently set to 500mb)
it breaks at that chunk, sends off that list of files to the ftp app,
and then starts building up a new list.

DVLA have a hard 2gb limit on how big the zip files we can send is -
however we're going to be limited by the amount of memory on the ftp
app well before we get around to handling 2gb of pdf data - so the
limit is 500mb for now. We'll adjust it after we see how ftp performs.
2018-01-02 10:39:21 +00:00
Richard Chapman
20d5a946f6 Add back in SQLALCHEMY config changes on staging
SQL Alchemy config changes were made to decrease the downtime of the
application. The last test only had 1 min of downtime in the upgrade
period i.e. 40 mins. Tested without the config changes to double
check the change had the desired effect. Adding back in so we can test
the changes under load and performance test outside of upgrade.
2017-12-22 08:21:53 +00:00
Ken Tsang
3ca97f67c9 Change live-letters-pdf to production-letters-pdf 2017-12-21 14:57:37 +00:00
Richard Chapman
66ae4ea9f2 Revert the SQLALCHEMY config changes on staging
SQL Alchemy config changes were made to decrease the downtime of the
application. The last test only had 1 min of downtime in the upgrade
period i.e. 40 mins. Reverting the changes so that the same process
can be followed to ensure the changes had the desired effect.
2017-12-21 11:31:38 +00:00
Richard Chapman
018d342408 Merge branch 'master' into rc_database_connection_settings 2017-12-20 15:59:07 +00:00
Leo Hemsted
e8967c5b05 tweak log output 2017-12-20 14:40:07 +00:00
Richard Chapman
2bc4c8ac39 Added SQLALCHEMY settings to staging for db connections
- Updated SQLALCHEMY_POOL_TIMEOUT timeout idle connections after  30 secs
- Updated SQLALCHEMY_POOL_RECYCLE to receyle the connection every 5 mins
2017-12-20 14:22:23 +00:00
Leo Hemsted
a0b87396ef change token expiry err msg for clarity 2017-12-20 13:57:34 +00:00
Leo Hemsted
9297c6d430 log user agents on api call auth.
this'll be useful for trying to figure out which services are using what
2017-12-20 13:57:34 +00:00
Leo Hemsted
687cf8526b log service id and api key id during auth
example log line:
```
API AuthError: AuthError({'token': ['Invalid token: signature, api token is not valid']}, 403, service_id=3e1ed7ea-8a05-4b4e-93ec-d7bebfea6cae, api_key_id=None)"
```
2017-12-20 13:57:34 +00:00
Leo Hemsted
e0c73256a6 log auth errors from the v2 api
(will help with tracking down client problems)
2017-12-20 13:57:12 +00:00
Rebecca Law
6fcfea7fce Merge branch 'master' of github.com:alphagov/notifications-api into populate-monthly-letter-usages 2017-12-20 09:59:30 +00:00
Rebecca Law
9051061519 Merge branch 'master' into populate-monthly-letter-usages 2017-12-19 16:55:22 +00:00
Venus Bailey
f0ea47aa05 Merge branch 'master' into vb-remove-ip-whitelist 2017-12-19 16:47:51 +00:00
Venus Bailey
56722c104c Merge branch 'master' into vb-remove-ip-whitelist 2017-12-19 15:33:28 +00:00
venusbb
a35b04f5e7 Enable MMG inbound blocking 2017-12-19 15:00:51 +00:00
Rebecca Law
a559338fe9 Merge branch 'master' into populate-monthly-letter-usages 2017-12-19 14:25:43 +00:00
Rebecca Law
cdbf34eddb Change order of query 2017-12-19 13:50:21 +00:00
Rebecca Law
e599db2684 Update the query 2017-12-19 13:47:24 +00:00
Rebecca Law
c5c40a0866 Merge branch 'master' into populate-monthly-letter-usages 2017-12-19 13:28:00 +00:00
Ken Tsang
8103540261 Renamed run-letter-pdfs to trigger-letter-pdfs-for-day
- also set optional date_to_process argument for dao_get_count_of_letters_to_process_for_date to None, so it's set in the code instead
2017-12-19 13:23:55 +00:00
Ken Tsang
3a4b8673bc Update upload_letters_pdf to use config setting for letter processing deadline 2017-12-19 13:23:55 +00:00
Ken Tsang
88f3c17463 Trigger collate-letter-pdfs-for-day task if notis to process 2017-12-19 13:23:55 +00:00
Ken Tsang
441651bbd1 Add get_count_of_letters_to_process to notifications_dao
- will get the letter notifications from day before >= letter processing deadline (17:30)
- letters_as_pdf permission is required in the service
2017-12-19 13:23:55 +00:00
Venus Bailey
6fb1e3ce96 Merge branch 'master' into vb-remove-ip-whitelist 2017-12-19 10:24:46 +00:00
Alexey Bezhan
87b56567b2 Set job notifications reply_to_text from the template.reply_to
When creating notification objects from the job sets the reply_to_text
from template's reply_to if it's present. Otherwise uses the service
default.
2017-12-19 10:23:24 +00:00
Alexey Bezhan
a98e5247b8 Update notificaiton API endpoints to use template's reply_to
Sets the reply_to_text on notification from the template value if
it's set.
2017-12-19 10:23:24 +00:00
Alexey Bezhan
3b0790f950 Add Template.get_reply_to_text helper method
Returns either template's reply_to text if set or the related field
from the default service record.

Return value can be used as default for `Notification.reply_to_text`
when per-notification value is not provided.
2017-12-19 10:23:24 +00:00