Commit Graph

156 Commits

Author SHA1 Message Date
Andrew White
00c3943222 Disable the remaining messages check for uploads
The HTTP request for the statistics is taking more 30 seconds which leads to 504 errors from CloudFront.
2021-05-22 07:25:07 +01:00
Katie Smith
3485475270 Allow provider_restriction to be None or "all"
Until all the data is updated to always be "all", we have to handle the
case of provider_restriction being set to None or "all" (which mean the
same thing).

The code can be tidied up once the broadcast provider_restriction is never None.
2021-05-10 16:18:14 +01:00
David McDonald
f8f3d44511 Add form to set service broadcast account type
Note, no option at the moment to set the service broadcast account type
as None, or back to without the broadcast permission. This has been done
for speed of development given the chance of us needing this is very
low. We can add it later if we need to.
2021-02-23 16:03:14 +00:00
Pea Tyczynska
079f371bc5 Update attribute names following changes in API 2021-02-03 10:30:01 +00:00
Pea Tyczynska
8f21caa87a Change service billing details
View page that lets you change service billing details and
update details on form submission.
2021-02-03 10:30:01 +00:00
Pea Tyczynska
33dbfbaa65 Sort allowed attributes alphabetically 2021-02-01 17:36:04 +00:00
Pea Tyczynska
f107fe260a Allow to update service notes 2021-02-01 17:13:53 +00:00
Rebecca Law
01a3df6edc Update _delete_template_cache_for_service to delete all template version cache and not just the one ending in "None"
Update all methods that were previous calling @cache.delete('service-{service-id}-template-None') to instead call _delete_template_cache_for_service
Remove call to get service templates, it's not needed since all template version cache is being deleted.
2021-01-25 16:28:20 +00:00
Pea Tyczynska
341933478b Succesfully update service notes 2021-01-15 15:38:39 +00:00
Chris Hill-Scott
d930c885e7 Allow rate limit to be updated
This bit of code is just a safety check to make sure we don’t
inadvertently updating something we shouldn’t (see
0cfe10639a for context).

`rate_limit` is something we allow the admin app to update now (as of
939029a9be).
2020-10-23 13:00:28 +01:00
David McDonald
2921c7302c Fix incorrect redis key deleting
We were trying to delete the old 'template-{template-id}' keys but
should have been deleting the new keys which have the service id as part
of the key name. This was causing the cache to not be correctly purged
when we did things like update sender names or set defaults. This should
fix it.
2020-10-21 11:14:23 +01:00
David McDonald
beb57fed85 Delete template cache if adding a new reply to email address
As if this is chosen as default, then the template data will be stale as
they do not have the latest reply to address.

We are already doing this for create/update/delete for sms senders and
contact lists for letters, it was just the create we were missing for
email reply to addresses.
2020-10-07 17:32:10 +01:00
David McDonald
7b82ca5083 Remove deleting of old redis key
At this point we are no longer setting this key, nor are we reading from
it so we are able to delete it.
2020-10-02 15:21:30 +01:00
David McDonald
a538329d0e Use new redis key for service templates and broadcasts
We can drop use of the old key as we no longer need to read data from
the old key. Either data exists in the new key and we read it from there
or data doesn't exist in the new key and we go to the API to get it and
then set it in redis.

Note, the previous commit is important because it means we aren't at
risk of when this commit is being deployed out, of us getting stale data
from the old key.
2020-09-21 17:37:27 +01:00
David McDonald
e3baa9ba35 Step 1 of renaming cache keys for templates
We want to change cache keys for templates and broadcasts to include
their service ID. So cache keys should change from
`template-{template_id}-versions` to
`service-{service_id}-template-{template_id}-versions`.

The first step of this which needs to be deployed as a change first is
to delete both keys when updating service templates (even if they key is
not yet set). This means that when we release code in the next PR to
start setting the new key, we won't run into a case where either the old
or the new key can remain set with stale data.
2020-09-21 14:04:10 +01:00
Leo Hemsted
7e15d0c928 delete template cache when reply_to stuff is updated
sms sender, email reply to, letter contact blocks.

These are all cached within template, under `template.reply_to` - if the
template doesnt have a specific default, then that field stores the
service default. So when service default changes, we need to clear the
template cache so that it is updated to reflect that.

We already use this pattern for deleting the template cache for a bunch
of templates in `template_folder_api_client.move_to_folder`
2020-08-18 14:47:12 +01:00
Chris Hill-Scott
e0cb487093 Use new guest list API URLs
The API now[1] accepts requests on `…/guest-list` as well as
`…/whitelist`. This commit starts using the former, which means:
- the use of ‘whitelist’ is fully gone from the admin app
- the API can stop using it, at least in URLs

1. As of https://github.com/alphagov/notifications-api/pull/2928
2020-07-27 13:24:37 +01:00
Chris Hill-Scott
51e99bd828 Ask API for less detailed JSON for all templates
This should speed things up by:
- less time waiting for big blobs of JSON to come from Redis or the API
- less time spent deserialising big blobs of JSON
2020-06-19 10:32:44 +01:00
Chris Hill-Scott
16cc640822 Rename API client methods to remove term ‘whitelist’
See c31264d4c for rationale. To avoid confusion the codebase should use
the same terminology as the UI.
2020-06-12 10:27:18 +01:00
David McDonald
ee14ae33dc Use redis_client rather than wrapper method
Fixes a bug where we were calling a wrapper method when instead we
should have been calling the redis_client. This had resulted in no
actual calls to redis happening.
2020-05-27 11:56:07 +01:00
David McDonald
0fdda016e2 Refactor archive to do one sync delete of all keys rather than many
Otherwise we could be waiting on 50 sync calls to redis to happen. This
way we do it in one sync call and follow the pattern of
b98f4561fa/app/notify_client/organisations_api_client.py (L56)
2020-05-22 17:12:00 +01:00
David McDonald
a65ada0d7e Delete cached users and templates when archiving a service
When the admin app gets user objects from the API, these include a dict
of permissions by service for what the user can do to that services.
Permissions for inactive services are not included in the response as
per:
87cb6f2597/app/dao/permissions_dao.py (L66)

However, this causes a bug where a service is archived but cached user
data still tells us that the user has permissions to view the service.
This should not be the case and causes errors where users can still see
the archived service page, it's settings, and even request to go live
for it, because they are using old cached data for the user.

We solve this by deleting the users who are part of the service from the
cache.

We also delete the templates for this service from the cache as the
templates are also archived when we ask the API to archive the service
as per:
d95c0131e0/app/service/rest.py (L597)

Note, one decision I had to make was whether to delete the user cache
for just active team members or also invited users. Assuming an invited
user can't see the service until they've accepted their invite anyway, it
shouldn't make any difference whether we delete their cache or not.
2020-05-22 16:27:05 +01:00
Chris Hill-Scott
7fb8e1de92 Use statistics for returned letters on dashboard
This should be faster and more accurate than querying all the reports.
2020-04-01 10:18:55 +01:00
Chris Hill-Scott
af8395956e Cache returned letter summary in Redis
We’re going to start using the returned letters summary to show some
info on the dashboard.

This means we will be accessing it more often than it changes. And we
know exactly when it changes because it’s us manually submitting the
references we get from DVLA.

This makes it a good candidate for being cached, and Redis is where we
cache stuff that we’d otherwise go to the API for.
2020-02-12 11:42:06 +00:00
Rebecca Law
729281532d Added returned-letter-summary page.
This page displays a list of available reports, a report is a set of returned lettters that have been reported on the same day.
Each line of the page is a link that can download the report.

I'm not sure the format of the csv is right. The data might be confusing especially if the service has a mix of precompiled templates and jobs.
Units tests are still to come.
2019-12-24 08:44:56 +00:00
Rebecca Law
e2d979f199 New pages to show a summary of all the reports the services has for its returned letters 2019-12-24 08:44:56 +00:00
Chris Hill-Scott
59b4d60c91 Munge stuff into a consistent event data type
We store our audit history in two ways:

  1. A list of versions of a service
  2. A list of events to do with API keys

In the future there could be auditing data which we want to display that
is stored in other formats (for example the event table).

This commit adds some objects which wrap around the different types of
auditing data, and expose a consistent interface to them. This
architecture will let us:
- write clean code in the presentation layer to display these events on
  a page
- add more types of events in the future by subclassing the `Event` data
  type, without having to rewrite anything in the presentation layer
2019-10-23 13:02:11 +01:00
Katie Smith
7368245c9a Show letter preview once file is uploaded
This shows the sanitised letter preview if the file had no validation
errors or the preview with the overlay if it failed validation.
2019-09-12 09:54:36 +01:00
Pea Tyczynska
035cb19568 Find services by name or partial name 2019-08-14 11:38:58 +01:00
Chris Hill-Scott
17bf06d04c Let users delete letter contact blocks
Because they can delete email reply to addresses and text message
senders.
2019-07-22 11:57:11 +01:00
Chris Hill-Scott
c11a43cbc4 Update live services count when service is counted
If we change our mind and decide whether a service should/should not be
counted in the list of live services then we should also drop the cache
which stores the count of how many live services there are.
2019-07-08 14:46:34 +01:00
Pea Tyczynska
ea314ad75f Deal with duplicate reply-to email addresses 2019-05-23 15:34:24 +01:00
Pea Tyczynska
d70afddf51 Send request to api to check if reply-to address is working 2019-05-23 15:34:23 +01:00
Pea (Malgorzata Tyczynska)
338de3dd67 Merge pull request #2934 from alphagov/live-services-csv
Add Live services and Performance platform csv reports
2019-05-01 16:20:53 +01:00
Pea Tyczynska
128bbd0d5f Add yearly notifications sent stats to live services report
Update live_services_csv so it works with new endpoint
2019-05-01 16:00:01 +01:00
Rebecca Law
da8eead475 Update service with the user that requested to go live.
When a service is marked as live update the service with the go live datetime.
2019-04-16 15:01:54 +01:00
Chris Hill-Scott
700e073d0f Stop sending service domain to the API
The API doesn’t look at it, and the rest of the admin code isn’t calling
the method with this argument any more.
2019-04-12 17:15:51 +01:00
Chris Hill-Scott
9863aa3c48 Automate counting of live services and orgs
Returns the data calculated by the API. Stored in Redis against a
hardcoded key so that no-one hammering the home page is directly hitting
the database.
2019-04-12 13:59:33 +01:00
Chris Hill-Scott
e7abebebf3 Pass API correct attribute to search inbound SMS
It’s `phone_number` here:
1250e47cc7/app/inbound_sms/rest.py (L33)
2019-04-02 09:17:13 +01:00
Leo Hemsted
53cdbad2cc make inbound search a POST
that way it doesn't expose PII to our logs
2019-03-29 15:16:29 +00:00
Chris Hill-Scott
8fb576e60a Allow excluding services from live services count
Adds a front end for:
https://github.com/alphagov/notifications-api/pull/2417

> Sometimes we have to make a few services for what really is one
> service, for example GOV.UK Pay and GOV.UK Pay Direct Debit. We also
> have our own test services which aren’t included in the count of live
> services. We currently count these as one service by not including
> them in the beta partners spreadsheet.
2019-03-25 15:46:35 +00:00
Chris Hill-Scott
8791134c60 Move the ‘estimated usage’ questions
We get a bunch of requests to go live where people have told us they're
going to send email but there is no email reply-to address present.

These come from 2 scenarios:

1. when there are email templates, and no reply to address – but they
   ignore the checklist
2. when there are no email templates (yet) but they provide anticipated
   volumes for email

At the moment we only auto-check for a reply to address when they have
email templates. And because the question about anticipated volumes
follows the checklist, you'll get a checklist that passes (reply
addresses not required as no templates present) - but your future intent
that differs (reply address IS required because you have anticipated
volumes).

So let’s bring the request for anticipated volumes into the checklist,
that way we can dynamically add the requirement for a reply to address
if they say they will send email but don't have templates yet.

We should begin storing it in the database against the service to stop
people having to re-enter it each time they try to complete the go live
screens.

This also means moving the ‘consent to research question’ along with
the questions about volume, because
- we want people to answer both before going live
- we don’t want to clutter up the summary page by asking questions there
  too
2019-02-27 13:17:28 +00:00
Katie Smith
31a1c1ca51 Pass service domain to api when adding a new service
We need to pass the domain to api when adding a service so that api can
link the domain of the service with a letter brand.
2019-02-12 14:59:29 +00:00
Leo Hemsted
8266635a7a remove dvla_organisation and other unused things
dvla_organisation, branding_dict, a weird `branding` property on
update_service. all gone 💥
2019-02-07 11:38:20 +00:00
Leo Hemsted
a1caf77b0e use new letter branding instead of dvla organisation id
new code is copied stylistically from the email branding patterns.
Instead of `service.dvla_organisation`, there's now
`service.letter_branding` and `service.letter_branding_id`. However,
unlike email branding we're not currently showing a preview of the
logo. That can come later when we work out how we want to do it.
2019-02-07 11:30:18 +00:00
Pea Tyczynska
b07f16b9a0 Don't use service default postage, but template postage instead 2019-02-06 11:40:50 +00:00
Pea Tyczynska
20ae200de9 Remove choosing postage from edit template content flow 2019-02-04 14:45:33 +00:00
Pea Tyczynska
db5378bac2 Edit template postage from a separate view 2019-02-04 14:45:33 +00:00
Chris Hill-Scott
1d3a4e5043 Inherit don’t duplicate API client constructor
This removes some code which is duplicative and obscure (ie it’s not
very clear why we do `"a" * 73` even though there is a Very Good Reason
for doing so).
2019-01-29 12:11:27 +00:00
Pea Tyczynska
85b8b343e2 Service deafault radio checked by default, existing tests pass. 2018-12-21 17:13:18 +00:00