Commit Graph

1136 Commits

Author SHA1 Message Date
Chris Hill-Scott
7e8471f21f Look at body, not template in outbound texts
As of this PR we don’t return the template content any more:
https://github.com/alphagov/notifications-api/pull/1015
2017-06-14 17:44:50 +01:00
Chris Hill-Scott
cebfa6cff6 Merge pull request #1315 from alphagov/feature
Adding first pass of the new features page
2017-06-14 17:03:56 +01:00
Chris Hill-Scott
c60917d0e4 Merge pull request #1291 from alphagov/two-way
Add page to show two-way conversation
2017-06-14 16:42:46 +01:00
Chris Hill-Scott
7411256fc2 Add hidden form to re-post AJAX requests
Serializing the search box form is bad, because the AJAX thing submit
any changes that the user makes to the contents of the box. This results
in unexpected behaviour.
2017-06-14 16:25:20 +01:00
Pete Herlihy
b466b266df Adding test for routing to features page 2017-06-14 16:07:34 +01:00
Chris Hill-Scott
fd3f6f920f Refactor conversation test to not re-request page
There’s no need to request the page once for each message on it. Quicker
to load the page once and then loop through the messages.

Still need this as an integration test because it’s testing the ordering
and threading of the message.
2017-06-14 15:43:42 +01:00
Chris Hill-Scott
eabd3f551a Add tests for getting a user’s phone number
Also makes the code a bit more specific by not squashing any exception,
only `HTTPError`s.
2017-06-14 15:37:57 +01:00
Chris Hill-Scott
681cea1d34 Make AJAX requests on activity page POST not GET
See parent commit for the reason we’re doing this.

Currently our AJAX requests only work as `GET` requests. So this commit
does a bit of work to make them work as `POST` requests. This is
optional behaviour, and will only happen when the element in the page
that should be updated with AJAX has the `data-form` attribute set. It
will take the form that has the corresponding `id`, serialise it, and
use that data as the body of the post request. If not form is specified
it will not do the serialisation, and submit as a `GET` request as
before.
2017-06-13 12:15:04 +01:00
Chris Hill-Scott
e65dcbe199 Make search by recipient form POST not GET
Phone numbers and email addresses are showing up in URLs where we let
users search for sent notifications by phone number or email address.

`GET` requests put the form data as a query string in the URL. This is
problematic when people are searching by a recipient’s phone number or
email address, because the URL may show up:
- in our server logs
- in our analytics
- in the user’s browser history

This is bad because these are all places where we don’t want
people’s personal information. It’s not too bad when this is happening
a handful of times. But it would be bad if we kept aggregating this
information because it would allow us to track users across services.

So, while it’s not especially RESTful, it’s better for the search form
to submit as a `POST` request. This way the phone number or email
address goes in the body of the request and does not show up in the URL.
2017-06-13 12:15:03 +01:00
Chris Hill-Scott
ff83c7090f Split activity page tests into their own file
It’s not intuitive for these tests to be lumped in with the tests for
the job page.
2017-06-13 10:33:56 +01:00
Chris Hill-Scott
036ff9228e Merge pull request #1308 from alphagov/inbound-sms-setting
Add settings page for inbound SMS
2017-06-12 10:35:19 +01:00
Chris Hill-Scott
bff9365d1b Let users send inbound emoji
Implements:
- [ ] https://github.com/alphagov/notifications-utils/pull/167

Required some refactoring to be able to defined the `is_inbound`
variable.
2017-06-10 12:03:37 +01:00
Chris Hill-Scott
f6d8e55579 Add two-way messaging view
> Once an inbound message has been received, there should be a way to
> see the other messages in the system from the same service to the same
> number. Both in and outbound. Nice inbox/whatsapp stylee view or some
> such. This way the context of the reply is understood.
>
> Initially will only see the outbound template, not the actual message,
> but we’re going to change this for the rest (soon), so that you can
> always see the full message for all outbound.
2017-06-10 12:03:10 +01:00
minglis
183c324f9a Merge pull request #1309 from alphagov/reinstate-new-rate-api
Reinstate new rate api
2017-06-08 14:07:33 +01:00
minglis
834c255195 Fixed typos 2017-06-08 13:55:13 +01:00
Chris Hill-Scott
d9a46a67bb Merge pull request #1306 from alphagov/roll-up-inbox
Roll up messages in inbox
2017-06-07 16:24:22 +01:00
Chris Hill-Scott
363a3e1864 Add settings page for inbound SMS
Users might be interested in inbound SMS. And when it’s fully
available, they’ll probably be able to control whether it’s on/off for
their service.

Until they point, the only way of getting it 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.
2017-06-07 15:07:20 +01:00
Martyn Inglis
784be721f4 Merge branch 'master' into reinstate-new-rate-api
Conflicts:
	app/main/views/dashboard.py
2017-06-07 14:44:27 +01:00
Martyn Inglis
d2ecd2121e Wired in the free limit from the API 2017-06-07 14:26:00 +01:00
Chris Hill-Scott
4259fb02ba Add handler for old feedback form
Cool URIs don’t change 😎

https://www.w3.org/Provider/Style/URI

We still have links to `/feedback` in our emails. These will live in people’s inboxes forever.
2017-06-07 12:25:33 +01:00
Chris Hill-Scott
313f669690 Roll up messages in inbox
The inbox should work a bit like the one on your phone. You shouldn’t
see all the messages, but the latest one from each of your ‘contacts’
only.
2017-06-06 15:15:36 +01:00
Chris Hill-Scott
67137f5570 Fix timestamp of latest inbound text on dashboard
Key was misnamed.
2017-06-06 12:44:59 +01:00
Chris Hill-Scott
85105fd6cd Only show inbound stuff if service has permission
Only services that have inbound SMS turned on should be able to see the
dashboard and ‘Received messages’ page.

There’s probably a cleaner way (decorator) of doing this permissions
stuff, but I think it can wait until we ship this.
2017-06-05 15:52:30 +01:00
Chris Hill-Scott
e373296bd9 Show inbound messages on the dashboard
This commit adds two things:

a section on the dashboard to show how many inbound messages the
service has received in the last 7 days, and how recently an inbound
message has been received
---

Doesn’t show the contents of any messages, just like how the rest of the
dashboard is an aggregation, never individual messages.

a page to show all the inbound messages the service has received in
the last 7 days
---

This shows the first line of the message. Eventually this will link
through to a ‘conversation’ page, where a service can see all the
messages it’s received from a given phone number.
2017-06-05 15:42:36 +01:00
Chris Hill-Scott
56354a0177 Merge pull request #1302 from alphagov/cqc
Add Care Quality Commission to email whitelist
2017-06-05 14:07:10 +01:00
Chris Hill-Scott
3d45454330 Add Care Quality Commission to email whitelist
CQC is an executive non-departmental public body, sponsored by the
Department of Health.

They have asked to be allowed to register for Notify using the
`cqc.org.uk` and `digital.cqc.org.uk` domains. We know that this really
is there domain because it’s linked to from here:

https://www.gov.uk/government/organisations/care-quality-commission
2017-06-05 13:51:53 +01:00
Rebecca Law
9d7510a52f Revert if statement refactor, if set_inbound_sms is False it still resolves to True, because it is not a boolean but a string. 2017-06-05 13:46:02 +01:00
Rebecca Law
f40e81bc3a Added a test to turn off the inbound permission. 2017-06-05 12:01:39 +01:00
Rebecca Law
fe24501075 Add a platform admin button to service-settings page to turn the inbound_sms messaging on and off.
If clicked you will be prompted to enter a sms sender number, when setting the permission on or off.
Team members will always be able to see the number, but will only be able to change it if the inbound_sms permission is off.
2017-06-02 16:33:31 +01:00
Chris Hill-Scott
4a251203df Merge pull request #1286 from alphagov/no-sender-fallback
Remove fallback for empty SMS sender
2017-06-02 12:16:52 +01:00
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