Commit Graph

3246 Commits

Author SHA1 Message Date
Katie Smith
70cdcfff55 Include list of users_with_permission in all folders response
This adds a list of user_ids of the users who have permission to view a folder
to the `get_template_folders_for_service` endpoint.
2019-02-27 12:56:26 +00:00
Katie Smith
d981abf18e Allow user folder permissions to be updated
Updated the endpoint for `.set_permissions` to update a user's folder
permissions as well as permissions for a service. User folder
permissions are optional for now, since Admin is not currently passing
this data through.
2019-02-27 12:56:26 +00:00
Leo Hemsted
38f0ea6cca remove functions to not talk about 7 days
remind us that data retention is flexible
2019-02-26 17:57:35 +00:00
Pea Tyczynska
211d3741ba Send confirmation emails to users when team manager edits their
email address  or mobile number.
2019-02-26 16:30:29 +00:00
Katie Smith
bcb1c483ca Change permissions endpoint to accept data in new format
The data posted to the `set_permissions` endpoint is currently sent as a
list of permissions:
`[{'permission': MANAGE_SETTINGS}, {'permission': MANAGE_TEMPLATES}]`.

This endpoint is going to also be used for folder permissions, so the
data now needs to be nested:

`{'permissions': [{'permission': MANAGE_SETTINGS}, {'permission': MANAGE_TEMPLATES}]}`

This changes the set_permissions endpoint to accept data in either
format. Once admin is sending data in the new format, the code can be
simplified.
2019-02-25 16:01:24 +00:00
Alexey Bezhan
2932b44eb8 Add retries for SES callbacks for recent notifications
We've seen errors caused by what we suspect is a race condition when
SES callback processing tries to look up the notification before the
sender worker has saved notification reference from the SES POST
response to the database.

This adds a retry for SES callback task if the notification was not
found and the message is less than 10 minutes old and removes the
error log message for notifications older than 3 days (since they
might no longer exist in the notifications table and would've been
marked as failure by then either way).

In order to be able to call retry and silence the error log based on
notification time this change inlines `process_ses_response` and
`update_notification_by_reference` functions into the celery task.
It also removes a lot of defensive error-handling that doesn't appear
to have been triggered in the last few months (for things like missing
keys in SES callback data).
2019-02-25 10:36:37 +00:00
Leo Hemsted
a617ccca9d allow pending notifications to influence switchover.
Currently we switch if:

* status = delivered and updated_at - sent_at > threshold
* status = sending and now - sent_at > threshold

firetext can leave notifications in the pending state, which is
equivalent to sending in terms of how we should handle it, so this
commit changes the second case to allow pending as well as sending.
2019-02-21 16:30:42 +00:00
Rebecca Law
331414d379 Merge pull request #2357 from alphagov/remove-edit-folder-permission
Remove the need for the edit_folders service permission.
2019-02-15 13:19:48 +00:00
Chris Hill-Scott
f679731af8 Also store consent to research against a service
It makes most sense to collect this at the same time as the estimated
volumes. Which means we need to store it somewhere; we can’t put it
straight into the ticket.
2019-02-15 10:08:22 +00:00
Chris Hill-Scott
ecdf076506 Store anticipated volumes as integers
This will make it easier to do analysis on the data. Almost all users
are submitting data in a numerical format now anyway, because we ask the
question in a sensible way.
2019-02-15 10:08:22 +00:00
Chris Hill-Scott
17e32fa5f6 Add fields to record a service’s estimated volumes
When a service go live we ask people for their estimated sending
volumes. At the moment we only put this in the ticket, and store it in
a spreadsheet.

This means that a service can
- say they want to go live
- say they are sending 100,000 emails per year
- not have created any email templates
- still see ‘create templates’ as ‘completed’ in the go live checklist

If we store this data against the service we can collect it earlier, and
then use it to determine automatically what kind of templates the user
needs to create before their go live checklist can be considered
complete.
2019-02-15 10:08:22 +00:00
Leo Hemsted
06f9e445f7 remove dvla_organisation from database
downgrade re-populates all static data but leaves all services with 001
(HM Government) branding
2019-02-14 14:27:59 +00:00
Leo Hemsted
53ecaa3230 remove dvla_organisation
it's been superceeded by letter branding
2019-02-13 15:02:18 +00:00
Leo Hemsted
afc5c96927 Don't fallback to dvla_organisation if letter branding unset
The template preview app now accepts a null value for the `filename` 
parameter. If a service doesn't have a letter branding option set, 
previously we defaulted to their dvla_organisation (probably HM 
Government). Now, we pass through None, so that we generate letters 
without any logo or branding.
2019-02-13 11:58:54 +00:00
Pea Tyczynska
08663b386c Don't test whether deleting service doesn't delete service permission
types. As we found it unncessarry.
2019-02-12 14:38:35 +00:00
Pea Tyczynska
8ef581de69 Remove service.postage and choose_postage permission from the code and tests 2019-02-11 18:20:34 +00:00
Rebecca Law
38a599c758 Remove the need for the edit_folders service permission.
We need another PR to remove it from ServicePermissionTypes and remove the data in service_permissions.
2019-02-11 17:26:17 +00:00
Leo Hemsted
478de8bb8e fix new services being assigned to wrong letter branding
when creating a service, the api accepts a `service_domain` field that
it uses to populate the letter branding - if the service domain is
known to match an existing letter branding option, use that
automatically. However, the admin currently doesn't know about this
field yet so doesn't pass anything through - the api erroneously
searches the DB for letter branding with a domain of None - which they
currently all have.

This meant that when services were created, their letter branding was
set to the most recent row in the DB (that matched None).
2019-02-11 11:46:33 +00:00
Chris Hill-Scott
aab36157a5 Test for HTML response in the schema
Because we test for the other properties in the schema.

Also sets `additionalProperties` to `False` so we’re forced to update
the schemas if we make similar changes in the future. This means
removing `created_by` from the test data because it’s not returned by
the real response.
2019-02-08 13:10:42 +00:00
Chris Hill-Scott
f185dbecbe Return rendered HTML when previewing a template
If you’re trying to show what a Notify email will look like in your
caseworking system all the API gives you at the moment is raw markdown
(with the placeholders replaced).

This isn’t that useful if your caseworkers have no idea what markdown
is. If we also give teams the HTML then they can embed this in their
systems, and the people using those systems will be able to see how
headings, bulleted lists, etc. look.
2019-02-07 17:43:46 +00:00
Pea Tyczynska
5b9e6c2086 Set postage on basis of postage argument or template postage 2019-02-06 13:23:09 +00:00
Pea (Malgorzata Tyczynska)
6c63339025 Merge pull request #2334 from alphagov/set_postage_on_new_templates
Set postage to second class when creating new letter template
2019-02-01 12:17:03 +00:00
Chris Hill-Scott
679a7df9dd Merge pull request #2285 from alphagov/folders-for-new-services
Give folders to new services by default
2019-02-01 10:57:39 +00:00
Pea Tyczynska
821a7ccbac Update requirements with flake8 and subdependencies and fix over-indents 2019-01-31 15:08:23 +00:00
Pea Tyczynska
ccd5a758f0 Set postage to second class when creating new letter template
Also get rid of checks for CHOOSE_POSTAGE permission when creating
and updating a template.
2019-01-30 16:26:49 +00:00
Chris Hill-Scott
4b1336b405 Give folders to new services by default
Step 1 of 2 of turning on folders for all services.

We think it’s a feature which will be useful for the majority of
services, and we think we’ve done enough research to know that it’s
mature enough to release to all services.
2019-01-29 12:30:41 +00:00
Leo Hemsted
1cd498dd39 make integrity check more restrictive
previously, it was too loose - checking `"name" in str(exc)` returns
false positives.

By changing from three if statements to a loop we can cut down on
unnecessary code (and ensure that the returned objects are consistent),
and by using the full check constraint name we can be sure that we're
only capturing exactly the right errors. Additionally, don't return
the original data in the error message - it's obvious what the name is
because it'll be populated in the form you just filled in.
2019-01-28 17:01:13 +00:00
Rebecca Law
4dbb54b5e7 Added an endpoint to get letter-branding by id. 2019-01-25 16:05:55 +00:00
Rebecca Law
e030c2be88 Removing platform_default as a concept. No service actually wants to send letters with the default hm-government logo so we are going to remove it as a constraint.
However, until we can create a letter without a logo, we will still default to hm-government, because the dvla_organisation is set on the service.
This does simplify the code.
Also removed the inserts to letter_branding in the data migration file, because we can deploy this before the rest of the work is finished. But we will need to do it later.
2019-01-25 15:03:01 +00:00
Rebecca Law
7ee1d67df7 Added endpoints for letter-branding. 2019-01-24 17:39:48 +00:00
Rebecca Law
0b7fca4167 Merge branch 'master' into letter-branding 2019-01-24 16:39:30 +00:00
Rebecca Law
f8eb72a537 Adding rest endpoints for letter-branding 2019-01-24 16:38:52 +00:00
Rebecca Law
a66b078065 Change the mock 2019-01-24 11:13:50 +00:00
Rebecca Law
e4ea208d06 Use the letter_branding logo if it exists otherwise fall back to the dvla_organisation logo. 2019-01-23 12:51:09 +00:00
Rebecca Law
f11aa55e0b Adding new data models for letter branding. 2019-01-22 17:27:00 +00:00
Leo Hemsted
f5198bf71d remove unnecessary job_types arg from remove_csv_files celery tasks 2019-01-22 10:31:37 +00:00
Leo Hemsted
e1760adcd3 suppress cronitor request errors 2019-01-18 15:36:53 +00:00
Leo Hemsted
754c65a6a2 create cronitor decorator that alerts if tasks fail
make a decorator that pings cronitor before and after each task run.
Designed for use with nightly tasks, so we have visibility if they
fail. We have a bunch of cronitor monitors set up - 5 character keys
that go into a URL that we then make a GET to with a self-explanatory
url path (run/fail/complete).

the cronitor URLs are defined in the credentials repo as a dictionary
of celery task names to URL slugs. If the name passed in to the
decorator  isn't in that dict, it won't run.

to use it, all you need to do is call `@cronitor(my_task_name)`
instead of `@notify_celery.task`, and make sure that the task name and
the matching slug are included in the credentials repo (or locally,
json dumped and stored in the CRONITOR_KEYS environment variable)
2019-01-18 15:36:53 +00:00
Leo Hemsted
d783e2b236 move tests from test_scheduled_tasks to test_nightly_tasks 2019-01-18 15:36:53 +00:00
Leo Hemsted
d3d56a3224 separate nightly tasks and other scheduled tasks.
other tasks is anything that is run on a different frequency than
nightly
2019-01-18 15:36:53 +00:00
Rebecca Law
39c9b86c35 Merge pull request #2310 from alphagov/remove-used-query
Remove unused query
2019-01-18 10:47:45 +00:00
Pea (Malgorzata Tyczynska)
64191a93c2 Merge pull request #2308 from alphagov/precompiled_postage_response
Return notification postage in response for .post_precompiled_letter_notification
2019-01-18 10:19:46 +00:00
Rebecca Law
6ac1f39fd0 Remove dao_fetch_monthly_historical_stats_by_template, a query using NotificationHistory that is no longer used. 2019-01-17 17:20:21 +00:00
Alexey Bezhan
90dc69b6bc Merge pull request #2303 from alphagov/ft-status-template-statistics
Change template statistics endpoint to use fact_notification_status_dao
2019-01-17 15:04:20 +00:00
Pea Tyczynska
9ab97d3481 Return notification postage in response for .post_precompiled_letter_notification 2019-01-16 16:57:57 +00:00
Pea (Malgorzata Tyczynska)
276a9a3828 Merge pull request #2293 from alphagov/choose_postage_for_precompiled
Choose postage on POST request for precompiled letters
2019-01-16 14:13:26 +00:00
Rebecca Law
3dca36ecfc Actually test the right thing :) 2019-01-15 16:16:19 +00:00
Rebecca Law
a4d89359c5 Adding a filter to exclude test keys for the template monthly usage query.
Added a test.
2019-01-15 16:13:38 +00:00
Pea Tyczynska
ac3832a918 Remove old redis template cache 2019-01-15 14:46:40 +00:00
Pea Tyczynska
d36c4d8a78 Remove now unused methods that populated template usage redis cache 2019-01-15 14:38:45 +00:00