Commit Graph

1184 Commits

Author SHA1 Message Date
Ken Tsang
bcc45ede9c Refactored code for new service permissions 2017-06-23 14:27:41 +01:00
Chris Hill-Scott
3e335c3250 Hide template nav if service has one of each
There are a bunch of services that just have one text message template
and one email template.

In this case the template navigation is essentially the same as the
list of templates – a user can just differentiate by looking at the two
templates. Adding the nav would just be noise in this case.
2017-06-23 13:53:54 +01:00
Chris Hill-Scott
f386b991cb Only show template navigation when it’s useful
There are lots of services that only send emails, or only send text
messages. For these services, being able to filter the list of templates
but type is pointless – it won’t cut the list down at all.

This commit adds some logic to only show the navigation if the service
has some variety of template types.
2017-06-23 13:49:26 +01:00
Chris Hill-Scott
358edf7f20 Make list of templates filterable by type
When users are trying to find a template there’s a fair chance that they
know whether or not it’s an email/text message/(letter) that they’re
looking for.

Making them scroll past a whole bunch of templates of a different type
means it will take them longer to find the template they are looking
for.

We already have search on the templates page, but this is only good for
where they can remember the name of the template. This will be
sometimes but not always.

This commit adds some navigation to filter down the list of templates to
only show one type at a time. By default it will show all templates. It
adapts the pattern we use for filtering notifications by
sending/failed/delivered, but without the counts of how many things are
in each bucket (I don’t think there’s any value in knowing you have X
text message templates; on this page you only really care
about the one template you’re looking for).

_Note: required re-arranging the functions in `templates.py`. The route
for `/template/:uuid` needs to come before the route for
`template/:string` otherwise Flask tries to interpret a template’s ID
as its type.
2017-06-23 13:49:24 +01:00
Chris Hill-Scott
cde7d781d5 Fix empty table message
Bug was happening because:

```python
bool(list())
>>> False
```

```python
bool((item for item in list()))
>>> True
```

i.e. generator expressions cast to boolean are `True`, even if they’re
empty – Python doesn’t evaluate them.

This was causing the functional tests to fail because it was taking too
long for any table rows to appear on the page.
2017-06-23 13:37:05 +01:00
Chris Hill-Scott
1797162248 Merge pull request #1328 from alphagov/notification-page-reworked
Add a page for each notification and start linking to it
2017-06-23 10:16:54 +01:00
kentsanggds
01760f3405 Merge pull request #1327 from alphagov/create-inbound-api
Create inbound api
2017-06-22 12:36:28 +01:00
Chris Hill-Scott
ff4a580ab4 Indicate template on scheduled jobs
We’ve removed the template on the jobs page, so you can no longer see
which template a job is about to be sent with.

This is removing information which might enable you to undo a costly
mistake.

I don’t think we need to bring back the whole template – giving its
name, and a link to it meets the need just as well.
2017-06-21 17:57:20 +01:00
Chris Hill-Scott
ba93be5ea5 Remove template from job page
Showing the template on the job page was semi-useful when you couldn’t
see the contents of each individual message. It was still a bit weird
because it just showed the template, never the actual messages that
went out, with the placeholders.

Now that users can click through to see individual messages, and can see
a short preview of the content on each row I think we can safely lose
the template preview on this page.
2017-06-21 17:57:20 +01:00
Chris Hill-Scott
c554e9e32d Put template content or subject in tables
In tables where we show rows and rows of information we used to give
some meta information about the notification, or at least as much as we
could give in the very limited space available.

This information is now on the notifications page, so the information we
show in these tables should just be whatever helps users identify the
right message. I reckon that this is:
- the content of the message for text messages
- the subject for emails and letters

This also makes these pages consistent with:
- the inbound SMS page
- the way the people’s inboxes work for their text
  messsages/Whatsapps/emails

For consistency’s sake this makes the job page work the same way. It may
be slightly less useful here because on the job page every message is
sent from the same template, so will have broadly the same content.
2017-06-21 17:57:20 +01:00
Chris Hill-Scott
1eb3a5aca0 Link to the relevant job from notification page
If a notification has been sent from a job then that’s important context
to know about it. So we should surface that information on the page.

It also gives users an easy way of going back, if that’s the page
they’ve come from.
2017-06-21 17:56:08 +01:00
Ken Tsang
c5e1de9b33 Enable update of url / bearer_token inbound api 2017-06-21 17:34:22 +01:00
Chris Hill-Scott
929e2b841f Put notification meta above message, remove AJAX
The meta info about a notification (who sent it, when they sent it)
won’t ever change, so there’s no need for it to reload it using AJAX.

Putting it above the message and under the `<h1>` makes it match how
this information is displayed on the job page.

On the job page this information is bold, but visually the job page is
using too much bold now (nothing is emphasised/differentiated if
everything is bold). So this commit also makes this line of info regular
on both the notification and job pages.
2017-06-21 16:21:34 +01:00
Chris Hill-Scott
67b2937123 Show full message content on notification page
We’ve had a few teams talk about wanting to go back and check what their
users are sending out, including the content of any placeholders.

We already provide this functionality through the API, this commit makes
it the default in the admin app too.

We couldn’t do this before because we didn’t have the individual
notification page.

It’s better to do this by re-hydrating the template than pulling the
content from the API, because things like letters have multiple areas
of content – this is more complex than what we can get from API at the
moment.
2017-06-21 16:20:45 +01:00
Chris Hill-Scott
a964417555 Show recipient on notification page
Since we removed the notifications table from this page we need a
different way of showing who the message was sent to.

Our `Template` classes already have a way of doing this, and we have a
flag to switch this on (which is what this PR changes).
2017-06-21 15:09:45 +01:00
Chris Hill-Scott
742173dd33 Remove counts from notification page
The counts on the notification page will only ever show 1 thing. Which
feels like overkill, especially if you’re only sending one-off messages.

It’s also confusing when you come from the job/activity pages which
have one set of numbers to then be confronted with a different set of
numbers.

The important stuff on this page is:
- what the message was
- some meta information about it

Sorry Leo 😢
2017-06-21 15:09:44 +01:00
Chris Hill-Scott
2ee5880e0c Change URL of notification page
This page is going to be used to show all notifications now, not just
ones sent as one-offs.
2017-06-21 15:09:40 +01:00
Ken Tsang
3b47ff28f0 Refactored tests for inbound api 2017-06-21 12:15:53 +01:00
Ken Tsang
d3d0c0c0b6 Add create_service_inbound_api 2017-06-20 13:29:20 +01:00
Ken Tsang
827c6ccc99 Refactor inbound api html and processing 2017-06-20 13:24:01 +01:00
Ken Tsang
5b54dd53a2 Change bearer input to password 2017-06-20 13:03:28 +01:00
Rebecca Law
f40448f80e Remove print 2017-06-19 11:35:25 +01:00
Leo Hemsted
c5f92eabfb add add one-off notification status
completely mimicks the job status page, and as such, all the code and
templates have been taken from the job page. This page performs
exactly the same as the job page for now

* total, sending, delivered, failed blue boxes (though they'll just
  read 0/1 for now.
* download report button (same as with job download, except without job
  or row number in file)
* removed references to scheduled
* kept references to help (aka tour/tutorial) as that'll eventually
  change over from a job to a one-off too
2017-06-16 15:28:17 +01:00
Rebecca Law
703b48b157 [WIP]
Page and form to persist the inbound api data for a service.
2017-06-15 16:20:07 +01:00
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
86b4a27ca3 Fix the problems 2017-06-14 16:53:16 +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
Pete Herlihy
11215a0c16 Adding route for new features page 2017-06-14 16:05:20 +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
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
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
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
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
da77737c16 Refactor if statement 2017-06-05 12:13:40 +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
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
Martyn Inglis
e236cc4cbe Fixed typo and moved the sms free limit into the config. 2017-06-01 17:04:41 +01:00