Commit Graph

174 Commits

Author SHA1 Message Date
Andrew Shumway
a1484c62bb Requested changes in PR review 2023-06-01 15:40:50 -06:00
Andrew Shumway
bd798e78b6 Added global remaining daily messages across services to ui 2023-06-01 10:44:13 -06:00
stvnrlly
944715ac46 big commit with letters removal 2022-12-05 15:33:44 -05:00
stvnrlly
f16b5dd1c4 remove broadcast-related code 2022-10-04 03:04:13 +00:00
jimmoffet
69abec0bb3 change dashboard test to reflect demo changes to uploads view 2022-09-09 17:02:48 -07:00
jimmoffet
68e6efdad0 remove redis debug config var 2022-09-08 09:07:54 -07:00
jimmoffet
dad051a662 2767 passing 2022-08-05 00:25:03 -07:00
James Moffet
1a204ae872 remove extra logs 2022-07-26 11:39:00 -07:00
James Moffet
4c25a81004 disable cache until we can fix on cloud deployment 2022-07-26 11:17:43 -07:00
James Moffet
50e660a73f devcontainer config 2022-07-19 18:23:48 -07:00
Ben Thorner
a5d18cf1a0 Simplify clearing the template cache
This is more consistent and more visible than a direct call to a
function. It makes use of the new decorator added in response to [^1].

[^1]: https://github.com/alphagov/notifications-admin/pull/4162#pullrequestreview-896208092
2022-03-07 14:42:55 +00:00
Ben Thorner
8aabaf1f49 Standardise when we clear template cache
This is consistent with all other methods: we clear the cache after
the actual change, not before it.

Since the new version of -utils, we're now catching redis exceptions
on delete, so this change has little effect on behaviour.
2022-03-07 13:54:01 +00:00
Ben Thorner
3f2b760efb Remove redundant deletion decorators
These are superseded by the "_delete_template_cache_for_service"
call in each of these methods.
2022-03-07 13:54:00 +00:00
Ben Thorner
81d9c73543 Bump -utils to 55.0.0
This renames "delete_cache_keys_by_pattern" to match the new method
name, which will also catch exceptions if Redis is down [1].

Note that this also includes a change to RecipientCSV [2], which has
no effect because the new default is the same as the old behaviour.

[1]: https://github.com/alphagov/notifications-utils/pull/949
[2]: https://github.com/alphagov/notifications-utils/pull/947/files#diff-a8a994bf655634f89dc7439880708b4ff0d780ac1bd8033827d8aaa2692a8e0fR373
2022-03-07 13:53:57 +00:00
Chris Hill-Scott
b998b6bb20 Remove methods for checking service/org name uniqueness
We don’t use these now – instead we try to update the name and see if
it works or not.
2022-01-13 10:16:07 +00:00
Katie Smith
5b52b6f9bf Clear user cache when broadcast service settings form is submitted
When the broadcast service settings form is submitted it now removes all
permissions for users in notifications-api. This means it should be
clearing the user cache.
2021-07-13 17:06:35 +01:00
Rebecca Law
77c2aa9fd6 Stop passing in today_only for the get_service_statistics method.
We now only ever call it with False.
To remove it from the api call will require a change in the API so will do that at another time.
2021-06-29 07:33:40 +01:00
Rebecca Law
44f02f2e30 To check the daily limit get the daily notification_count from redis.
The daily limit cache is set by the api when a notification is created. There is one cache key per service per day and it expires after 24 hours.
2021-06-23 15:56:05 +01:00
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