Commit Graph

1196 Commits

Author SHA1 Message Date
Katie Smith
5986dfd415 Allow sending emails to be disabled
Platform admins can now disable sending of emails for a service. If
sending emails is disabled, this will also hide the option to change the
Email reply to address.
2017-07-05 09:15:32 +01:00
Chris Hill-Scott
11adf17330 Merge pull request #1354 from alphagov/no-template-link-tour
Don’t link to template in tour
2017-07-04 09:51:18 +01:00
Chris Hill Scott
702fa1bbb4 Bump utils to count characters in SMS properly
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/172
2017-07-04 09:47:53 +01:00
Chris Hill Scott
584f849a3d Don’t link to template in tour
We want people to go to the dashboard, not get distracted by clicking
the tempting blue link.
2017-07-04 09:32:09 +01:00
Chris Hill-Scott
ef45a1d83f Merge pull request #1343 from alphagov/show-template-as-first-step-of-tour
Change step 1 of tour to only show the template
2017-07-04 08:55:16 +01:00
Rebecca Law
fb256b4147 Add unit test 2017-07-03 17:21:44 +01:00
Chris Hill Scott
140d3eeb09 Remove tour-related stuff from the job page
The tour does the send one-off thing now, rather than creating a
job.
2017-07-03 15:43:28 +01:00
Chris Hill Scott
8eed32620d Fix link to dashboard from end of tour
The notification page was different to the job page in that it
passed through the whole template, not just the ID.
2017-07-03 15:29:11 +01:00
Rebecca Law
1b1839ad30 The yearly usage section on the dashboard page takes too log as a result services with large yearly stats are timing out.
As a short term fix we have taken the yearly stats off the dashboard.

There is a plan to create permanent statistic tables to warehouse the data.
2017-07-03 11:35:55 +01:00
Chris Hill-Scott
bc880017e5 Respect template’s redaction preference
If a template has the `redact_personalisation` flag set, then this
commit removes the personalisation from the notification before
rehydrating the template.

We’re doing this because we have a need to not show things like one time
passwords or two factor codes when we show the content of messages.

By passing through empty personalisation, and the `redact_missing` flag,
the `Template` instance will make use of the work done in:
- [x] https://github.com/alphagov/notifications-utils/pull/171
2017-06-30 14:04:11 +01:00
Chris Hill-Scott
9f20ea4b7e Revert "Merge pull request #1336 from alphagov/revert-show-notifications"
This reverts commit 7e354ff341, reversing
changes made to 6f3bcff32f.
2017-06-30 14:01:18 +01:00
Rebecca Law
885086dd8a Fix codestyle 2017-06-30 13:09:59 +01:00
Leo Hemsted
0b6b659bc0 if on the tour check notification page (step 2), show back link
Back link redirects to beginning of tour.

Additionally, this fixes a problem where you'd get a 500 when using
the browser back button
2017-06-30 12:48:44 +01:00
Leo Hemsted
ef4d3d111f help (aka tour) now works correctly throughout the notification flow 2017-06-30 11:49:03 +01:00
Leo Hemsted
87aeec1b8d add other send notification error branches and tests 2017-06-29 16:10:59 +01:00
Leo Hemsted
70914bfe8a display errors on the end page.
The following errors may happen:
* Number outside of service if service in trial mode
* Message too long for sms
* Service over daily limit

We need to handle these. They only return on send, rather than in a
separate validation step (for now).
2017-06-29 15:31:44 +01:00
Leo Hemsted
a31bf0c5ce add tests for new check and send notification endpoints 2017-06-29 12:40:03 +01:00
Leo Hemsted
de92950d8e make sure recipient details always rendered 2017-06-29 12:40:03 +01:00
Leo Hemsted
3966d024d8 add new send_notification api call 2017-06-29 12:40:03 +01:00
Chris Hill-Scott
480a57bba4 Change step 1 of tour to only show the template
We’ve made a few changes to the tour recently, without changing the
help text on the left hand side of the screen. So the stuff you see on
the right side of the screen doesn’t quite sync up any more.

This commit adds an extra, introductory page that just shows the
template and a next button, which better matches the ‘every message
starts with a template’ help text.
2017-06-29 12:16:47 +01:00
Chris Hill-Scott
6e48dc7689 Add a message saying a template has been redacted
This is useful if it’s been redacted by someone who isn’t you.
2017-06-28 15:27:09 +01:00
Chris Hill-Scott
9569521142 Add feature to mark a template as redacted
Works similarly to the delete template flow, because it’s a destructive,
one-way action.

Not on the edit template page, because it’s not something you want to be
considering every time you’re editing a template. And we saw that people
couldn’t find the delete button when it was on this page.

Adds a bit more CSS for the `dangerous` banner type, because the content
here is quite complicated. Breaking it into a list helps, but the
spacing didn’t look right, so needed some tweaking.

Can ship independently of the code that shows the redaction, but needs
the API first.
2017-06-28 15:27:07 +01:00
Chris Hill-Scott
1dbd6a122d Make client_request understand POST-redirect-GET
When we do a `POST` we almost always do a redirect straight afterwards.
`client_request` understands this, and expects a `302` by default.

However, if the `_follow_redirects` flag is set the status code returned
is that of the subsequent request – normally a `GET`, itself returning
`200`. Therefore the default expected response code would need to be
overridden.

Overriding this repeatedly would get pretty boring. Better to do it once
inside the fixture.
2017-06-28 15:27:06 +01:00
kentsanggds
8202c44202 Merge pull request #1335 from alphagov/ken-use-new-service-permissions
Use new service permissions
2017-06-27 11:27:12 +01:00
Chris Hill-Scott
b450a349a3 Revert "Merge pull request #1328 from alphagov/notification-page-reworked"
This reverts commit 1797162248, reversing
changes made to 95b4d9eb31.
2017-06-23 15:56:25 +01:00
Chris Hill-Scott
5c0f6796e4 Revert "Merge pull request #1333 from alphagov/fix-empty-table-message"
This reverts commit 114bac7b80, reversing
changes made to 69445380d9.
2017-06-23 15:55:54 +01:00
Chris Hill-Scott
c52bfc5b81 Revert "Merge pull request #1334 from alphagov/fix-missing-recipient-on-notification-page"
This reverts commit 6f3bcff32f, reversing
changes made to f8a3132d8b.
2017-06-23 15:55:06 +01:00
Ken Tsang
beffaeaeea Refactor test 2017-06-23 15:29:09 +01:00
Chris Hill-Scott
4b02612d93 Fix missing recipients on notification page
For some reason:
- notifications sent from CSV files have the recipient as part of the
  personalisation
- notifications sent via the API don’t have the recipient as part of the
  personalisation

I’d only tested it locally with CSV-sent files so didn’t spot this. The
`conftest.py` fixtures we set up like the API already, but we didn’t
have an explicit test.

This commit adds a method to append the recipient to the
personalisation, so we can populate the template with it.
2017-06-23 14:43:39 +01:00
Ken Tsang
bcc45ede9c Refactored code for new service permissions 2017-06-23 14:27:41 +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
Ken Tsang
c5e1de9b33 Enable update of url / bearer_token inbound api 2017-06-21 17:34:22 +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
5e4aff2a7b Refactor test to match subsequent line
Easier to read these asserts if they’re formatted the same.
2017-06-21 15:17:11 +01:00
Chris Hill-Scott
b578c3589b Put status under message
Since we’ve removed the table of notifications from the single
notification page there’s no way of knowing the status of a
notification.

This re-adds it in a way that’s similar to how it looks on inbound
messages.
2017-06-21 15:15:13 +01:00
Chris Hill-Scott
16d92b9a62 Remove notifications table from notification page
This table will only over show one notification.

There’s a better way to display who the recipient was, and what the
status of the notification is.
2017-06-21 15:09:44 +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
Ken Tsang
ba8ee3e60a Add test for elided inbound api urls 2017-06-21 13:43:52 +01:00
Ken Tsang
3b47ff28f0 Refactored tests for inbound api 2017-06-21 12:15:53 +01:00
Leo Hemsted
d47c2cdf9f remove dupe fixture 2017-06-20 10:51:25 +01:00
Leo Hemsted
580c225ca2 Change client_request so its kwargs look more like url_for 2017-06-19 12:31:14 +01:00
Leo Hemsted
20bb34849d add tests for notification status page 2017-06-16 15:29:34 +01:00
Leo Hemsted
09dc85e5bc Clean up code to remove unnecessary paths.
Status code was overcomplex, given how we control the inputs. Now, it
expects a single value, rather than a comma separated list, and if you
give something it doesn't expect it just returns all. Note, it won't
select the correct box - but if you've been manually editing the URL
that's your own problem ¯\_(ツ)_/¯

Also, as this page will only ever be shown from the tour (tutorial),
it doesn't need some non-help things - such as the download csv button
and associated endpoint.
2017-06-16 15:28:17 +01:00