Commit Graph

1105 Commits

Author SHA1 Message Date
Martyn Inglis
0dbd3fa10d Revert "Merge pull request #1288 from alphagov/add-new-rate-logic"
This reverts commit adbff63d1f, reversing
changes made to 80f0b4b2a2.
2017-06-02 10:41:42 +01:00
minglis
adbff63d1f Merge pull request #1288 from alphagov/add-new-rate-logic
Wire in the new API method that calculates the total cost and total billable units
2017-06-02 09:52:19 +01:00
minglis
8f70dcf549 Fix typo 2017-06-01 16:55:49 +01:00
minglis
74e79e175b Fix typo 2017-06-01 16:53:36 +01:00
Chris Hill-Scott
80f0b4b2a2 Merge pull request #1297 from alphagov/search-outbound
Add search box to filter notifications by recipient
2017-06-01 16:09:20 +01:00
Chris Hill-Scott
f12e0fde39 Ensure the tour sidebar gets shown
I accidentally broke it by removing a parameter. This commit reinstates
that parameter and adds some tests to make sure it doesn’t happen again.
2017-06-01 14:27:55 +01:00
Chris Hill-Scott
6425dcbc94 Rename the feature to ‘send to one recipient’
‘One-off’ is a bit wooly. Feels like our name for the thing. ‘Send to
one recipient’ matches ‘Upload recipients’.

This also means making the `<h1>` on job page ‘Report’ for one-off
messages. It doesn’t make sense to call the feature ‘send to one
recipient’ when we’re not using the language of one-off any more.
2017-06-01 14:27:25 +01:00
Chris Hill-Scott
43f6d21e1d Replace test with one-off
It’s a confusing proposition to have two features which are almost
identical. Even differentiating between them in the template menu would
be tricky.

I think the better thing to do is rename the whole feature to ‘send
one-off message’.

Then if someone wants to use there own phone number or email address,
give them a quick shortcut to doing that, once they’re in the flow.
In the background this reuses the ‘send yourself a test’ code, but
the user is never aware that they’re going through a different route
to send an individual message. So the proposition stays nice and clean.
2017-06-01 14:26:49 +01:00
Chris Hill-Scott
82549c817a Ensure correct page titles on send test flows
We have some fairly complicated nested if statements in our Jinja that
decide what the page titles should be. It’s only going to get more
complicated with the send individual message routes.

So this commit:
- moves the logic from Jinja to Python
- adds tests to check things are working as expected
- sets the page titles to the right thing for each flow
2017-06-01 14:26:14 +01:00
Chris Hill-Scott
27c1463213 Validate recipients in send a one-off message
It would be annoying to get all the way to the end of the flow and get
told that the phone number or email address you entered isn’t valid.

So this commit reuses the existing WTForms objects that we have to do
some extra validation on the first step in the send one-off message
flow. It also accounts for international phone numbers, if the service
is allowed to send them.

It doesn’t reject other people’s phone numbers if your service is
restricted, because I think it’s better to let users play with the
feature – it’s good for learning.
2017-06-01 14:25:41 +01:00
Chris Hill-Scott
7310e8b435 Make send one-off route ask for phone number/email
This commit adds an extra, initial, step to the ‘send one-off message’
flow to ask for a phone number or email address. This is the first pass
at making a feature which caseworkers or similar could use Notify to
send individual messages while they’re working a case.
2017-06-01 14:25:04 +01:00
Chris Hill-Scott
311732ff9d Add test for international phone no. 2017-05-31 11:53:10 +01:00
Chris Hill-Scott
b9bf18b936 Add a form to filter notifications by recipient
Because manually editing the URL isn’t a great user interface, this
commit adds a search field to do this on the user’s behalf.

For this pass at the story it doesn’t do any validation – the user will
just get no results if they search by something which isn’t a phone
number or email address.

If the user navigates to a different ‘bucket’ of notifications (eg
delivered, failed) then the search term is reset, because they’ve
changed the filter which is at a level above the search term.
2017-05-30 15:11:34 +01:00
Chris Hill-Scott
f41830e5d3 Add query string parameter to search by recipient
> Service teams that use the admin interface often need to know the
> outcome of a message... at the moment they have to page through all
> the results in the activity stream. They should be able to find
> notifications by email address or phone number.

– https://www.pivotaltracker.com/n/projects/1443052

This commit adds an additional query string parameter (`to`) to the URL,
which users can use to filter down the list of notifications.

It:
- takes the status into account
- doesn’t update the counts based on the search term (in reality each
  service will only send a handful of notifications to one person in any
  7 day period)

In other words the funnel that filters down the notifications looks
like:

> all notifications for service → only failed → only to this phone
> number
2017-05-30 15:06:56 +01:00
Chris Hill-Scott
eabd9fcbf1 Add a third route through populating a template
This commit adds a route which is identical to send yourself a test, but
with its own endpoint. This will let us add a slightly different
‘send a one-off message’ flow. This commit just adds the route though,
and makes sure that the tests pass for both routes.
2017-05-30 10:33:48 +01:00
Chris Hill-Scott
d516f19a33 Merge pull request #1292 from alphagov/tidy-tests
Combine related tests into one
2017-05-30 10:30:46 +01:00
Rebecca Law
a1d004fa45 Add cjsm.net to whitelist 2017-05-26 10:40:48 +01:00
Chris Hill-Scott
ff00058847 Don’t hit template preview app when running tests
It’s annoying for tests to pass locally because the template preview app
is running locally, but fail on Jenkins because the template preview app
doesn’t exist.

This commit changes it’s hostname to use a dummy port in tests.
2017-05-25 15:03:49 +01:00
Chris Hill-Scott
d04bdaa6fb Combine related tests into one
These tests were both requesting the same page with the same input,
saves a lot of boilerplate if they’re not separated.
2017-05-25 08:31:58 +01:00
Martyn Inglis
52326539d6 Wire in the new API method that calculates the total cost and total billable units.
- Used on dashboard to calculate free tier/cost
- Update tests to mock new method
- Two new tests to check output on dashboard page
2017-05-24 10:35:52 +01:00
Chris Hill-Scott
ad5fc9a583 Put error flag on whole row
We’ve seen people miss errors if they’re in the right-hand columns of
the spreadsheet because people’s eyes scan down the left edge of the
table.
2017-05-23 14:33:22 +01:00
Chris Hill-Scott
1c1c5bd758 Merge pull request #1285 from alphagov/from-always-set
Use GOVUK as fallback SMS sender
2017-05-23 13:55:35 +01:00
Chris Hill-Scott
616fec9d77 Remove 40604 as fallback
We should just be using whatever is in the database. Should not be
merged until the DB migration is done.
2017-05-23 13:36:48 +01:00
Chris Hill-Scott
eab15f252b Merge pull request #1284 from alphagov/validate-sms-sender
Stop letting people enter empty SMS senders
2017-05-23 12:55:14 +01:00
Chris Hill-Scott
1d76b22bc0 Add extra tests to make sure that the form is safe
Previous implementations of this functionality mutated the base form
class, which broke a bunch of stuff.

I want to make sure that getting this form for one placeholder doesn’t
change other forms that have already been instantiated for other
placeholders.

Mutation is scary.
2017-05-22 12:12:22 +01:00
Chris Hill-Scott
cd7c27925c Check that users can’t skip steps in send test
Because we put the step in the URL, users could:
- skip ahead to a later step
- navigate to a step which doesn’t exist (ie an index greater than the
  number of placeholders)

This commit adds some checks to do the sensible thing in the unlikely
event that either of these situations occur.
2017-05-22 12:12:22 +01:00
Chris Hill-Scott
c8a64aeb19 Clean up unused test fixtures
The combination of `service_one` and `logged_in_client` takes care of
most of the permissions stuff.
2017-05-22 12:12:22 +01:00
Chris Hill-Scott
e7896f283a Cache letter page count on send yourself test
Calculating the number of pages in a letter is quite slow. And the send
yourself a test pages need to load _fast_. Since filling in placeholders
is very unlikely to change the number of pages in the resultant letter,
it’s pretty safe to cache that count, and makes the subsequent pages
load a lot faster.
2017-05-22 10:52:06 +01:00
Chris Hill-Scott
8c03feb334 Show one field at a time on send yourself a test
The send yourself a test feature is useful for two things:
- constructing an email/text message/letter without uploading a CSV file
- seeing what the thing your going to send will look like (either by
  getting it in your inbox or downloading the PDF)
- learning the concept of placeholders, ie understanding they’re thing
  that gets populated with _stuff_

The problem we’re seeing is that the current UI breaks when a template
has a lot of placeholders. This is especially apparent with letter
templates, which have a minimum of 7 placeholders by virtue of the
address.

The idea behind having the form fields side-by-side was to help people
understand the relationship between their spreadsheet columns and the
placeholders. But this means that the page was doing a lot of work,
trying to teach:
- replacement of placeholders
- link between placeholders and spreadsheet columns

The latter is better explained by the example spreadsheet shown on the
upload page. So it can safely be removed from the send yourself a test
page – in other words the fields don’t need to be shown side by side.

Showing them one-at-a-time works well because:
- it’s really obvious, even on first use, what the page is asking you to
  do
- as your step through each placeholder, you see the message build up
  with the data you’ve entered – you’re learning how replacement of
  placeholders works by repetition

This also means adding a matching endpoint for viewing each step of
making the test letter as a PDF/PNG because we can’t reuse the view of
the template without any placeholders filled any more.
2017-05-22 10:50:10 +01:00
Chris Hill-Scott
ab150d876d Stop letting people enter empty SMS senders
This shouldn’t be deployed until we’ve migrated the database to default
to GOVUK.
2017-05-19 22:42:17 +01:00
Chris Hill-Scott
42ebc44b83 Make removing placeholders a non-breaking change
The CSV upload route has always quietly ignored excess personalisation.
We changed the API to do the same here:
https://github.com/alphagov/notifications-api/pull/853

This means that removing a placeholder from a template is never a
breaking change, because the data that you were providing to populate it
is now just ignored.

So we don’t need to show the interstitial page in this case.
2017-05-17 13:10:23 +01:00
Chris Hill-Scott
d9f5884e3d Fix argument order bug with page count 2017-05-16 11:43:19 +01:00
Chris Hill-Scott
11394bce8e Merge remote-tracking branch 'origin/all-pages-everywhere' 2017-05-16 11:22:33 +01:00
Chris Hill-Scott
24817de387 Merge remote-tracking branch 'origin/spreadsheet-error-tweaks' 2017-05-16 11:22:19 +01:00
Chris Hill-Scott
acae449ab9 Show all pages of a letter everywhere
Right now showing all the pages in full is the only way we have of
showing a letter that makes sense to our users. Maybe in the future we
show some kind of truncated version, but the end of the first page is
not a good place to truncate the letter.

This commit just extracts the code for showing multiple pages from the
template view, refactors it for reuse, and includes it in the send
views.
2017-05-16 11:09:34 +01:00
Chris Hill-Scott
d37f7b6bc5 Don’t repeat _your file_ at start of paragraph
Looks weird, like we’re telling you two contradictory things. Doesn’t
scan well.
2017-05-11 11:33:25 +01:00
Chris Hill-Scott
f836f206e6 Say ‘missing’ rather than ‘doesn’t have’
Missing gives more of a suggestion that this is something to be fixed,
rather than just a statement of fact.
2017-05-11 11:23:58 +01:00
Chris Hill-Scott
30fe6db2e2 Don’t repeat names of columns in the error message
It makes the error message quite noisy.

We’re going to move the table right underneath the error message, so
you’ll be able to see the column names right there.
2017-05-11 11:14:27 +01:00
Chris Hill-Scott
3bccf39c77 Make the ‘no recipient column’ error more concise
Word salad.
2017-05-11 11:11:59 +01:00
Chris Hill-Scott
0697c62616 Hide the recipient table on send yourself a test
Send yourself a test is:
- a good way of explaining how placeholders work
- a useful tool for checking your work before you send a big batch

It’s not a good way of learning about the relationship between columns
in a spreadsheet and placeholders. The ‘example spreadsheet’ thing is
good at making that connection. The table on this page isn’t, because
it doesn’t _feel_ like you’re making a spreadsheet with the send
yourself a test feature (even though that’s what you’re doing in the
background). This will be even more the case when we stop putting the
input boxes horizontally on one page.

By removing the table from this page it makes the page simpler, which
allows people to focus on the important thing – what’s happening to
their message.
2017-05-11 10:55:44 +01:00
Chris Hill-Scott
bf15c12380 Merge pull request #1259 from alphagov/letters-are-a-thing
Tell users that letters are coming
2017-05-05 14:10:34 +01:00
Leo Hemsted
d6de5508ca make sure static subdir 404s correctly
before each request, we put the current service on the flask session,
except for with the static folder, cos it's not needed.... except, if
we 404, then we return the 404 template, which checks if you're logged
in or not to display different nav bar items. This was crashing when
current_service wasn't set, so we now set it.

also cleaned up some imports and stuff in test files
2017-05-04 11:28:45 +01:00
Ken Tsang
79e1df33cf Update rates to avoid confusion 2017-05-03 13:19:15 +01:00
Ken Tsang
829bcd632f Handle future dates 2017-05-02 14:10:56 +01:00
Chris Hill-Scott
3e16372169 Tell users that letters are coming
Users might be interested in letters. And when they’re fully
available, users will probably be able to control whether letters are
on/off for their service.

Until that point, the only way of getting the feature is to ask us. So
let’s make an in-the-meantime page that directs them to ask us, from the
place where they’d be able to do it themselves.

Wording TBC.
2017-05-02 11:04:24 +01:00
Ken Tsang
53e78c2b60 Update page to handle international stats 2017-04-28 14:49:41 +01:00
Ken Tsang
79b4b37b0e Add tests for sms breakdown adjusted free allowance 2017-04-28 14:49:41 +01:00
Ken Tsang
260dfb1e32 Updated code and added tests 2017-04-28 14:49:41 +01:00
Chris Hill-Scott
55a0ed22d9 Merge pull request #1252 from alphagov/international-invite
Tell users international text messaging is coming
2017-04-28 13:27:06 +01:00
Leo Hemsted
cf125d0a14 add sent as a new status
functions as delivered - shows up in delievered column, contributes
to delivered stats etc.
2017-04-27 16:17:10 +01:00