Commit Graph

7823 Commits

Author SHA1 Message Date
Ben Thorner
ebb82b2e80 Add page for security keys with stubbed data
This adds a new platform admin settings row, leading a page which
shows any existing keys and allows a new one to be registered. Until
the APIs for this are implemented, the user API client just returns
some stubbed data for manual testing.

This also includes a basic JavaScript module to do the main work of
registering a new authenticator, to be implemented in the next commits.

Some more minor notes:

- Setting the headings in the mapping_table is necessary to get the
horizontal rule along the top (to match the design).

- Setting caption to False in the mapping_table is necessary to stop
an extra margin appearing at the top.
2021-05-12 13:41:53 +01:00
Rebecca Law
cf160c3ae1 Update labels
Use more suscinct labels for the service settings page
2021-05-06 07:29:21 +01:00
Rebecca Law
5495de0b3b Remove some of the option we have for broadcast services.
This is the first step in making the UI easier for setting the
options for a broadcast service. Here we remove the options for
"Training mode" test channels. When we create a broadcast message for a trail mode service it is marked as stubbed and does not create a broadcast event that is sent to a provider.

The label for the form and setting page have been updated to reflect the
change.
2021-05-05 14:04:51 +01:00
Ben Thorner
bfc55b45ca Merge pull request #3863 from alphagov/show-suspended
Show service suspension in breadcrumb
2021-04-28 14:59:56 +01:00
Ben Thorner
b43eb3a591 Show service suspension in breadcrumb
Previously there was no indication that a service was suspended.
While this could also be shown for archived/deleted services, the
meaning is similar enough that it makes sense there too - the name
of the archived service should distinguish it as being archived.
2021-04-27 11:15:13 +01:00
karlchillmaid
487452b390 Fix apostrophe 2021-04-26 13:38:11 +01:00
karlchillmaid
e78c10fc40 Remove details of allowance and pricing 2021-04-22 13:27:22 +01:00
karlchillmaid
029a6ec3b5 Update text message cost and rates
Update text message cost and rates on the features page
2021-04-22 13:25:40 +01:00
Pea Tyczynska
c55cc4574e Merge pull request #3854 from alphagov/admin-cancel-broadcast
Allow platform admins to cancel broadcasts.
2021-04-21 12:52:14 +01:00
karlchillmaid
652f3f8065 Update {{ text_field(charge | safe) }} 2021-04-20 17:31:08 +01:00
karlchillmaid
94d71ca330 Update app/templates/views/message-status.html
Co-authored-by: Katie Smith <klssmith@users.noreply.github.com>
2021-04-20 17:30:03 +01:00
Pea Tyczynska
0c0d9dd72f Admins won't see buttons for broadcast actions they can't do
These actions are creating, accepting and rejecting broadcasts.
2021-04-20 17:27:56 +01:00
Pea Tyczynska
002dd7485d Allow platform admins to cancel broadcasts.
Do not allow platform admins to:
- create broadcasts
- approve broadcasts
- reject broadcasts

that is, unless they have a send_messages permission
for a given service.

This is so platform admins have the minimum permissions necessary
to cancel a broadcast that might have been sent out accidentally.
2021-04-20 17:27:55 +01:00
karlchillmaid
6782f6770b Fix error 2021-04-20 16:41:51 +01:00
karlchillmaid
0fe60c3bd8 Update content 2021-04-20 15:51:12 +01:00
karlchillmaid
77f17db9dc Update email status description
Update email status description for ‘Inbox not accepting messages right now’
2021-04-20 15:46:16 +01:00
Rebecca Law
007fa5fa19 Merge pull request #3855 from alphagov/set-annual_billing-in-the-api
Let the API handle setting the default free allowance.
2021-04-20 07:17:57 +01:00
Rebecca Law
ac0b8ed95c If the job is for letters do not add the sender_id.
How this happens: a user starts to send a letter job, then in another tab starts a SMS
or email job, the sender_id is set in the session. Then the user goes
back to the letter job tab and creates the job. The sender_id is set in
the metadata of the csv file, and causes an exception when trying to persist
the letter notification.

This PR adds a check to ensure the sender_id is not set for letter jobs.

This will catch a small use case where the user has multiple tabs open
and has started sending an SMS or email job, then tries to send a letter
job.
2021-04-15 13:51:48 +01:00
Chris Hill-Scott
00f9df7606 Merge pull request #3860 from alphagov/search-templates-by-id
Allow users of the API to search templates by ID
2021-04-14 10:44:17 +01:00
Chris Hill-Scott
559c400e84 Add override from future GOV.UK Frontend version
We need to duplicate it until we upgrade.
2021-04-13 15:43:03 +01:00
Chris Hill-Scott
c95b2ef8b3 Allow users of the API to search templates by ID
For someone who has retrieved a template ID from their system the only
way to find it in Notify is:
- hack the URL
- click through every template, visually inspecting the ID shown on the
  page until you find the right one

Neither of these is ideal.

This commit adds searching by ID, for those services who have an API
integration. This means we don’t need to confuse teams who aren’t using
the API by talking about IDs.

This is similar to how we let these teams search for notifications by
reference[1]

1. https://github.com/alphagov/notifications-admin/pull/3223/files
2021-04-13 15:24:29 +01:00
sakisv
bfa8dfe95e Fix import order 2021-04-13 16:31:06 +03:00
Chris Hill-Scott
e7aad61220 Use pure Python Rtree library
The Python rtree library we are using to build RTrees has a dependency
on the C package libspatialindex. This package is not installed on PaaS,
so it’s hard for us to use it.

This commit changes the code to use a library called rtreelib instead.

rtreelib doesn’t have a built in way to serialise the index it builds,
so I’ve had to implement that using pickle.
2021-04-13 12:43:28 +01:00
Chris Hill-Scott
83c521915c Estimate number of phones in an arbitrary polygon
We want to know how many phones are in a user-supplied polygon, so we
can show the impact of a broadcast, in the same way that we do when
users pick areas from our library.

We already know how many phones are in each electoral ward. But there
are challenges with an arbitrary polygon:
- where it does overlap a ward, the overlap could be partial
- it could overlap more than one ward
- finding out which wards it overlaps by brute force (looping through
  all the wards and seeing which ones intersect with our polygon) would
  be way to slow to do in real time

Instead we can use a data structure called an R-tree[1] to build an
index which provides a much, much faster way of looking up which
polygons overlap another. We can build this tree in advance and save it
somewhere, which means there’s a lot of computation we don’t need to do
in real time.

The R-tree returns a set of objects (ward IDs) which we can go and look
up in our library of electoral wards. These wards will be the ones that
might have some overlap with our custom polygon.

Once we have this small set of wards which might overlap our ward, we
can look at the size of the area of overlap (relative to the size of the
whole ward) and multiply that by the known count of phones in that ward
to get an approximation of the count of phones in the overlap area.
Summing these approximations give an estimate for the whole area of the
custom polygon.

1. https://en.wikipedia.org/wiki/R-tree
2021-04-12 15:45:48 +01:00
Katie Smith
04d051df6b Merge pull request #3856 from alphagov/401-fix
Fix sign in link on 401 page
2021-04-09 08:53:30 +01:00
Chris Hill-Scott
06f2c7eaaa Remove verbs from old alerts
Now we’ve split the old alerts onto two pages the verbs (‘Broadcast’ and
‘Rejected’) will always be the same for each alert – so they’re not
adding any differentiation.

The specifics of what the datetime means is available on the page for
each alert.

Removing the verbs makes the page a bit less cluttered and makes it
easier to scan down the right hand column.
2021-04-08 14:19:36 +01:00
Chris Hill-Scott
4da38e42e3 Make alert page work for rejected broadcasts
The code for this page was making assumptions about properties which
aren’t present on rejected broadcasts.

This commit accounts for those properties and presents the relevant
elements on the page.
2021-04-08 14:19:36 +01:00
Chris Hill-Scott
9b256de4a9 Refactor to reduce duplication
> Rule of three ("Three strikes and you refactor") is a code refactoring
> rule of thumb to decide when similar pieces of code should be
> refactored to avoid duplication. It states that two instances of
> similar code don't require refactoring, but when similar code is used
> three times, it should be extracted into a new procedure

– https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)
2021-04-08 14:19:36 +01:00
Chris Hill-Scott
dc4db4951a Add a separate page for rejected alerts
We don’t want to mix these up with alerts that actually went out.
2021-04-08 14:19:36 +01:00
Chris Hill-Scott
9977028a83 Make Jinja template generic
This will let us reuse the same code for displaying pages of previous
and rejected alerts.
2021-04-08 13:38:54 +01:00
Chris Hill-Scott
0bdd5cab2d Show rejected broadcasts on ‘Previous alerts’ page
Two reasons to not hide rejected broadcasts:
- if a broadcast was rejected by mistake then it’s useful to have an
  audit of who did that
- it means you can still see old broadcasts without having to leave
  in pending-approval, which is dangerous because they might
  accidentally be approved
2021-04-08 10:51:01 +01:00
Katie Smith
b1848b3216 Fix sign in link on 401 page
We've seen someone getting a `500` when trying to visit the `/metrics`
endpoint. This is because the metrics endpoint is not in the `main`
blueprint, so we can't use url_for with a relative endpoint.

Although only bots visit '/metrics' without authorisation, this stops
the odd `500`.
2021-04-08 08:42:02 +01:00
Rebecca Law
b1d78ada83 Let the API handle setting the default free allowance.
The API has a method to handle setting the default SMS free allowance. This will save a call to the API and remove some code duplication between the two apps.

Needs to be merged after https://github.com/alphagov/notifications-api/pull/3197
2021-04-07 09:32:18 +01:00
David McDonald
4acca3de4d Don't show user as unknown for service history
A commit was added:
600e3affc1

In it, it falls back to the string 'Unknown' for actions done by those
not belonging to the service.

This commit changes the behaviour such that if the user is not in the
list of active users for a service, it will go get the user from the DB
(or redis). This should be fine to do as redis will protect us from most
calls as most of these cases are for platform admins.

This will mean we can now see which user platform admin put a service
live rather than seeing 'Unknown'.
2021-04-06 11:36:54 +01:00
karlchillmaid
b2e1c9492f Update content 2021-04-01 13:22:58 +01:00
karlchillmaid
018397fb7d Update pricing for text messages 2021-04-01 13:20:10 +01:00
karlchillmaid
f8feb28fe5 Update pricing information for text messages 2021-04-01 13:18:04 +01:00
Chris Hill-Scott
eeba15356d Merge pull request #3848 from alphagov/leohemsted-patch-1
Fix gov.scot typo
2021-04-01 11:23:58 +01:00
Chris Hill-Scott
18a96d3243 Merge pull request #3830 from alphagov/remove-2020-allowances
Remove 2020/21 free allowance data
2021-04-01 10:40:29 +01:00
Richard Baker
02600d76bd Create additional non-UK broadcast test polygons
This allows MNOs to test delivery to multiple non-adjacent cells without
risk of sending a broadcast on the public network. This will also support
testing of multiple polygon geometries in a single message.

Test polygons are all non-UK (northern Finland).

Signed-off-by: Richard Baker <richard.baker@digital.cabinet-office.gov.uk>
2021-03-31 10:00:39 +01:00
Pea Tyczynska
f7142a1518 Catch validation error from API
When dates chosen for billing report are not in the same
financial year, API throws an error. This error was not being
caught so far. This PR starts to catch it and display a banner
with error message on the page, instead of page crashing.
2021-03-30 14:13:57 +01:00
Pea Tyczynska
38cfee6390 Rename usage report to billing report
Because only services with bills to pay are included, and
we started including billing details.

Also rename endpoints and file names to match this.
2021-03-30 14:13:54 +01:00
Pea Tyczynska
95f46ced8a Add billing details fields to Usage for all services report 2021-03-30 14:11:42 +01:00
Leo Hemsted
8e45075d5e Fix gov.scot typo
thanks rory for the spot
2021-03-29 15:35:22 +01:00
Chris Hill-Scott
fc75d60f65 Refactor BroadcastAreas to reuse common methods
This commit makes an abstract base class for broadcast areas, so that
methods and properties which are common between `BroadcastArea`s (those
which come from our library) and `CustomBroadcastArea`s (those supplied
via the API) can be shared.
2021-03-22 11:07:43 +00:00
Chris Hill-Scott
aa2a10c843 Merge pull request #3833 from alphagov/vary-bleed-by-population-density
Vary bleed amount based on population density
2021-03-22 10:03:19 +00:00
Chris Hill-Scott
57aa994ce9 Add docstring 2021-03-19 15:47:18 +00:00
Chris Hill-Scott
a74db6eaa7 Handle areas which don’t have population data
If an area has a `count_of_phones` value of `0` it means we don’t have
data about the population.

This means we can’t do the maths to work out the estimated bleed. So we
should return the default amount of bleed of 1,500m instead, which is
something in between what we’d expect for a built up area and a rural
area.
2021-03-19 15:47:18 +00:00
Chris Hill-Scott
4367908269 Add limits to max/min bleed
This prevents us from giving unrealistically large or small bleed
estimates in case we have areas which are more dense or less dense than
the most/least dense areas we currently have.

Also means we don’t have to treat City of London as a special case.
2021-03-19 15:47:18 +00:00
Chris Hill-Scott
6c8bfdc5b0 Refactor failed login count
We don’t vary this between different environments so it doesn’t need to
be in the config.

I was trying to look up what this value was and found it a bit confusing
that it was spread across multiple places.
2021-03-19 15:20:11 +00:00