Commit Graph

3780 Commits

Author SHA1 Message Date
Chris Hill-Scott
1d65c19c4e Refactor content preview method into generator
This will let us break up this method a bit more, rather than make the
dictionary comprehension even more involved and nested.

Means we need to `list()` it, because generator expressions cast to
boolean are `True`, even if they’re empty – Python doesn’t evaluate
them. ie:

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

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

```python
bool(list(item for item in list()))
>>> False
```
2017-06-30 14:04:10 +01:00
Chris Hill-Scott
4798258e62 Add redact_missing argument to get_template
Adds an interface to use:
https://github.com/alphagov/notifications-utils/pull/171
2017-06-30 14:04:10 +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
Leo Hemsted
8115dab8e4 Merge pull request #1345 from alphagov/help-i-need-somebody
help (aka tour) now works correctly throughout the notification flow
2017-06-30 13:27:48 +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
f31767e492 Merge pull request #1340 from alphagov/send-one-off
Send one off messages without jobs
2017-06-29 16:24:21 +01:00
Leo Hemsted
87aeec1b8d add other send notification error branches and tests 2017-06-29 16:10:59 +01:00
Leo Hemsted
42e33ce9e6 make partials source-agnostic
they're currently expecting a RecipientsCSV object - but we won't
always have that available if we're handling a single notification.

So make the partials take generic variables, and then use a jinja with
block to pass in the correct values from either the check csv page or
the check notification page.

Additionally set the notification check page to show errors nicely -
hide the send button if there were problems, and replace the header
2017-06-29 15:33:31 +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
f1ecee8469 add template partials for some notification checks
also move out some from the check.html page. This is going to help
with sharing templates between single notifications and csv files.
2017-06-29 12:40:03 +01:00
Leo Hemsted
4eb35a9aa6 make error handler work if only one error message 2017-06-29 12:40:03 +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
47aaebacc3 iron out kinks in recipient/placeholder handling
where we were previously setting the placeholder when going through
the send self a test - however, should be setting recipient. Also,
only do this on step-0 of the one-off route, not the send-test route,
since step-0 of send-test is the first normal placeholder. Phew!
2017-06-29 12:40:03 +01:00
Leo Hemsted
e46b635551 separate recipient from rest of placeholders when sending notification
note: in the case of letters, we still want to create a CSV file. This
only modifies the code flow when it's an email or template 😩

renamed `send_test_values` to `placeholders` because a) that's what
they are and b) this isn't just for sending a test message any more
2017-06-29 12:40:03 +01:00
Leo Hemsted
40f805c230 add new endpoints for one-off flow
rather than creating a job, after entering the placeholders, you now
send a single notification. This means we don't clog up s3 by creating
lots of one line CSV files.
2017-06-29 12:40:03 +01:00
Leo Hemsted
16df91766f rename template var in send_test_step
it's confusing reassigining one template (json from api) to another
type (utils object) on one line.

Also removed an unnecessary bounds check (since if placeholders is
empty the IndexError will throw on the next line anyway and it'll
be handled the same), and moved get_back_link out to its own function
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
1e979394bb Merge pull request #1341 from alphagov/redaction-setting
Add feature to mark a template as redacted
2017-06-29 11:41:45 +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
afbe175d15 Attach current user to redact client method
Not sure how to test this, but we need it.
2017-06-28 15:27:08 +01:00
Chris Hill-Scott
79217a02bb Split views into GET and POST 2017-06-28 15:27:08 +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
Chris Hill-Scott
4b89ee5d1d Merge pull request #1342 from alphagov/60-61
60-61 HMCTS Money Claim
2017-06-27 17:12:41 +01:00
Chris Hill-Scott
c39707a458 Merge pull request #1339 from alphagov/quis-patch-1
Add more nuance to time filter
2017-06-27 17:12:27 +01:00
Pete Herlihy
00e474a4b4 60-61 HMCTS Money Claim 2017-06-27 14:51:36 +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
Ken Tsang
f624215bbf Refactor inbound_sms to use switch_service_permissions 2017-06-27 11:17:06 +01:00
Chris Hill-Scott
75e9d0949c Add more nuance to time filter
Saying X seconds is more precise than we need to be.
2017-06-26 17:16:55 +01:00
Rebecca Law
c4684c692b Merge pull request #1338 from alphagov/een
Add logo for Enterprise Europe Network
2017-06-26 11:39:57 +01:00
Chris Hill-Scott
4b212fbc76 Add logo for Enterprise Europe Network 2017-06-26 11:21:19 +01:00
Chris Hill-Scott
7e354ff341 Merge pull request #1336 from alphagov/revert-show-notifications
Revert show notifications
2017-06-23 16:11:47 +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
6f3bcff32f Merge pull request #1334 from alphagov/fix-missing-recipient-on-notification-page
Fix missing recipients on notification page
2017-06-23 15:03:10 +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
f8a3132d8b Merge pull request #1330 from alphagov/template-nav
Make list of templates filterable by type
2017-06-23 14:08:38 +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
867143e871 Center-align pill text when there’s no big number
When the text is left aligned it looks messy because the spacing is so
uneven and there are no big numbers to give it some rhythm.
2017-06-23 13:49:27 +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
114bac7b80 Merge pull request #1333 from alphagov/fix-empty-table-message
Fix empty table message
2017-06-23 13:45:34 +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
Pete Herlihy
69445380d9 Merge pull request #1331 from alphagov/57-59
57 - 60
2017-06-23 13:14:20 +01:00