Commit Graph

5635 Commits

Author SHA1 Message Date
Katie Smith
51a18ef0b4 Merge pull request #2160 from alphagov/update-service-schema
Update service schema to add letter_logo_filename
2018-10-19 10:05:54 +01:00
Leo Hemsted
4dbedd02a3 Merge pull request #2167 from alphagov/compare-to-uuid
compare service id to UUID
2018-10-18 13:20:15 +01:00
Leo Hemsted
e7dad9436f compare service id to UUID
it doesn't match a string 😩
I couldn't think of a good way to test this in a unit test, since
it involves changing the service id on all of the components of a
service.
2018-10-18 12:19:10 +01:00
Katie Smith
e7f0a414ce Update service schema to add letter_logo_filename
Added the filename of a service's letter logo to the service schema. We want
this in the schema so that it is possible to call
`current_service.letter_logo_filename` from notifications-admin and to pass this value
through to template-preview.
2018-10-18 08:48:06 +01:00
Leo Hemsted
e0056aad3f Merge pull request #2164 from alphagov/fix-bucket-names
make sure validation_failed notifications still return pdf
2018-10-17 17:04:25 +01:00
Leo Hemsted
3589f1dd63 remove some use of calling fixtures directly
also experiment with giving the fixtures a different name, so we can be
sure that they won't be called in functions. Open to change on this.
2018-10-17 16:38:46 +01:00
Leo Hemsted
c63b147a2d make sure validation_failed notifications still return pdf
it's useful to see them, and previously it was crashing.
2018-10-17 16:09:30 +01:00
Leo Hemsted
162ed0ba5f remove dupes from cfg 2018-10-17 15:29:39 +01:00
Leo Hemsted
126092948b Merge pull request #2076 from alphagov/use_sanitised_pdf
Use sanitised pdfs for sending and handle invalid pdfs
2018-10-17 13:31:55 +01:00
Leo Hemsted
7bf68e3664 fix failed sanitise flow
the move from virus scan to validation failed function was called with
the wrong variables, and had some internal logic that was slightly
wrong.

Also, Don't use `update_notification_by_id` for notifications if they
are not in `created`, `sending`, `pending`, or `sent`. It silently
doesn't update them. I didn't want to do a deeper investigation into
the reasons behind this terrifying state machine as part of this commit
so I just changed the functions to call `dao_update_notification`
manually
2018-10-16 17:30:39 +01:00
Leo Hemsted
9606513e1f exclude CYSP from sanitise
we know their content is already good, but they slightly exceed the
margins. Until they deploy their fixed template, lets not valiate them
2018-10-16 17:30:39 +01:00
Pea Tyczynska
e22e7245fe Use sanitised pdfs for sending and handle invalid pdfs, details below:
- pass new, sanitised pdf for sending
- move invalid pdfs to a newly created bucket
- set status fro notifications that failed pdf validation to a new status validation-failed
- adjust existing tests
2018-10-16 17:30:35 +01:00
Katie Smith
cd563283d5 Merge pull request #2159 from alphagov/add-dvla-org-filename
Add filename to dvla_organisation table
2018-10-16 16:32:16 +01:00
Katie Smith
52095c9c8c Add filename to dvla_organisation table
Added a filename column to the dvla_organisation table and populated it
with the filenames that are currently hard-coded in template-preview.
The filenames for letter logos are going to be stored in the database,
instead of in template-preview.
2018-10-15 10:37:34 +01:00
Chris Hill-Scott
617cec8a79 Merge pull request #2152 from alphagov/brighton-hove
Add letter org for Brighton and Hove
2018-10-12 10:54:15 +01:00
Chris Hill-Scott
8f9ee7f7ad Add letter org for Brighton and Hove 2018-10-12 10:36:41 +01:00
Chris Hill-Scott
4d8b09e027 Merge pull request #2143 from alphagov/encode-invites
Bump utils to 30.5.4
2018-10-09 15:20:21 +01:00
Chris Hill-Scott
8af5cbab86 Bump utils to 30.5.4 2018-10-09 15:08:54 +01:00
Leo Hemsted
f55b4ef594 Merge pull request #2142 from alphagov/revert-2131-celery4
Revert "Celery 4"
2018-10-09 14:28:07 +01:00
Leo Hemsted
2ed50e760f Revert "Celery 4" 2018-10-09 13:27:49 +01:00
Chris Hill-Scott
72358899ad Merge pull request #2136 from alphagov/bump-utils-30.5.3
Bump utils to 30.5.3
2018-10-05 16:15:25 +01:00
Leo Hemsted
ba7cf10393 Merge pull request #2131 from alphagov/celery4
Celery 4
2018-10-05 16:03:44 +01:00
Chris Hill-Scott
a1a4bad0e6 Bump utils to 30.5.3 2018-10-05 15:30:03 +01:00
Chris Hill-Scott
b4f7dca60f Merge pull request #2135 from alphagov/utils-30.5.2
Bump utils to 30.5.2
2018-10-05 14:15:46 +01:00
Chris Hill-Scott
2708515f18 Bump utils to 30.5.2 2018-10-05 13:43:17 +01:00
Leo Hemsted
2edb7f39e6 fix reqs file 2018-10-05 10:28:12 +01:00
Leo Hemsted
bfc4343b0e remove pip-accel and make sure commands work if you're in a venv
remove pip-accel - it's not been updated in two years, and pins our
version of pip to a version that is several breaking changes old.

make sure commands work if you're already in a venv - mostly by
checking for presence of $VIRTUAL_ENV, and ensuring we use the correct
pip to install packages. Also clean up the commands a bit.
2018-10-04 15:52:51 +01:00
Katie Smith
1bbcedf150 Merge pull request #2130 from alphagov/return-postage
Return postage from the monthly-usage endpoint
2018-10-04 14:03:46 +01:00
Leo Hemsted
640f00b0e8 install celery with sqs support
you need to `pip install celery[sqs]` to get the additional
dependencies that celery needs to use SQS queues - there are two libs -
boto3 and pycurl.

pycurl is a bunch of python handles around curl, so needs to be
installed from source so it can link to your curl/ssl libs. On paas and
in docker this works fine (needed to add `libcurl4-openssl-dev` to the
docker container), but on macos it can't find openssl. We need to pass
a couple of flags in:

* set the environment variable PYCURL_SSL_LIBRARY=openssl
* pass in the global options `build_ext` and `-I{openssl_headers_path}`.

As shown here:
https://github.com/pycurl/pycurl/issues/530#issuecomment-395403253

Env var is no biggie, but using any install-option flags disables
wheels for the whole pip install run. (See
https://github.com/pypa/pip/issues/2677 and
https://github.com/pypa/pip/issues/4118 for more context on the
install-options flags). A whole bunch of our dependencies don't
install nicely from source (but do from wheel), so this commit installs
pycurl separately as an initial step, with the requisite flags, and
then installs the rest of the requirements as before.

I've updated the makefile and bootstrap.sh files to reflect this, but
if you run `pip install -r requirements.txt` from scratch you will run
into issues.
2018-10-03 14:11:30 +01:00
Leo Hemsted
6ca2b8277c import exception from botocore
boto (2) is no longer a dependency
2018-10-03 14:11:30 +01:00
Leo Hemsted
e0551547d2 wait 20 seconds between long polls 2018-10-03 14:11:30 +01:00
Leo Hemsted
1786f99400 construct celery queues once in the base config
previously, we were confusing things by appending to CELERY_QUEUES in
both dev and test configs - these are executed at import time, so the
list contained all queues twice, regardless of what config you're
actually using.

Fortunately, the -Q command that we supply the workers with overrides
this config option, so other environments weren't affected. Given that,
we can tidy up this code by just declaring it in the base config every
time
2018-10-03 14:11:30 +01:00
Leo Hemsted
4b7ed9db2f upgrade celery to 4.2.0
celery 4.2.0 no longer requires boto2, so we can get rid of that
patched version.
2018-10-03 14:11:18 +01:00
Katie Smith
236bbc5f28 Return postage from the monthly-usage endpoint
We were already returning the month, notification_type, billing_units
and rate from the /monthly-usage billing endpoint. This adds in the
postage too so that we can display postage details on the usage page of
admin.
2018-10-03 13:07:46 +01:00
Leo Hemsted
0843503b7a Merge pull request #2123 from alphagov/estimate-deliv-date
letter estimated delivery now takes postage into account
2018-10-03 11:44:52 +01:00
Leo Hemsted
cffc697e7f letter estimated delivery now takes postage into account 2018-09-28 17:30:25 +01:00
Katie Smith
ebc7f3e16b Merge pull request #2122 from alphagov/update-requirements
Update requirements
2018-09-28 16:45:37 +01:00
Katie Smith
c2a6fc0439 Merge pull request #2112 from alphagov/add-postage-to-pk
Add postage to ft_billing primary key
2018-09-28 16:45:29 +01:00
Rebecca Law
d5d84eb5ee Update requirements 2018-09-28 16:37:40 +01:00
Katie Smith
71d28035dd Update ft_billing with real postage data
* Changed update_fact_billing DAO function to update the table with the
real data for postage instead of hard-coding in 'second'.
* Added a test for the create nightly billing task to test that rows
with different postage are being inserted correctly.
2018-09-28 16:32:18 +01:00
Katie Smith
f41e0f05ec Make postage column part of ft_billing primary key
Now that the postage column is populated and there are no null values,
it can be added to the composite primary key of ft_billing.
2018-09-28 16:19:49 +01:00
Katie Smith
f034c26e19 Merge pull request #2121 from alphagov/fix-failing-test
Remove test
2018-09-28 15:14:03 +01:00
Katie Smith
0aedbff750 Remove test
Removed the occasionally failing test to check how ft_billing upserts
postage data. This test will be re-added once the postage column has been
added to the primary key.
2018-09-28 15:00:29 +01:00
Katie Smith
07f152e59e Merge pull request #2111 from alphagov/add-ft-billing-postage-column
Add ft_billing postage column
2018-09-28 14:48:46 +01:00
Katie Smith
6727f0e0f5 Update ft_billing DAO functions to use postage
* Updated the 'fetch_billing_data_for_day' DAO function to take postage into
account
* Updated the 'update_fact_billing' DAO function to insert postage for
new rows. When updating rows which are identical apart from the postage, the
original row will be kept. (This behaviour will change once postage is
added to the primary key - at this point, upserting will add a new row.)
* Also changed some fixtures / test set up functions to take postage
into account
2018-09-28 13:52:17 +01:00
Katie Smith
0b5da2b8ad Update command to migrate data to ft_billing
Updated the 'migrate-data-to-ft-billing' command to populate the new
postage column of ft_billing. This will be populated with the
postage of the notification for letters, or 'none' for email or sms. We
need to ensure there are no null values in postage so that the postage
column can become part of the primary key later.

Also updated the query to get the right rate letter rate now that we are
updating rates in the letter_rates table.
2018-09-28 13:52:17 +01:00
Katie Smith
0936060f5d Add postage column to ft_billing
Added a new varchar column, postage, to ft_billing. This is nullable and
not part of the composite primary key for now, but this will change
later.
2018-09-28 13:52:10 +01:00
Katie Smith
48db3a5e11 Delete unused functions
These deleted functions were only used for the old billing endpoints
which no longer exist.
2018-09-28 13:47:20 +01:00
Katie Smith
335aeb386f Update FactBilling model to reflect current database state
The FactBilling model and the ft_billing database table have diverged
slightly - this makes some minor changes to the model columns so that
the model matches the table (which appears to be the correct version).

The ft_billing table is currently like this:

       Column       |            Type             | Modifiers | Storage  | Stats target | Description
--------------------+-----------------------------+-----------+----------+--------------+-------------
 bst_date           | date                        | not null  | plain    |              |
 template_id        | uuid                        | not null  | plain    |              |
 service_id         | uuid                        | not null  | plain    |              |
 notification_type  | text                        | not null  | extended |              |
 provider           | text                        | not null  | extended |              |
 rate_multiplier    | integer                     | not null  | plain    |              |
 international      | boolean                     | not null  | plain    |              |
 rate               | numeric                     | not null  | main     |              |
 billable_units     | integer                     |           | plain    |              |
 notifications_sent | integer                     |           | plain    |              |
 updated_at         | timestamp without time zone |           | plain    |              |
 created_at         | timestamp without time zone | not null  | plain    |              |
Indexes:
    "ft_billing_pkey" PRIMARY KEY, btree (bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international, rate)
    "ix_ft_billing_bst_date" btree (bst_date)
    "ix_ft_billing_service_id" btree (service_id)
    "ix_ft_billing_template_id" btree (template_id)
2018-09-28 13:47:20 +01:00
Katie Smith
82f07de200 Merge pull request #2116 from alphagov/update-first-class-rates-dates
Update first class letter rate start dates
2018-09-28 13:45:45 +01:00