Commit Graph

48 Commits

Author SHA1 Message Date
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
stvnrlly
944715ac46 big commit with letters removal 2022-12-05 15:33:44 -05:00
David McDonald
04fa99b3dc Update get_notifications_for_service to make POST requests
This updates the `get_notifications_for_service` of the
`NotificationApiClient` to make POST request to the api when the `to`
field is provided. This is done so that we avoid logging personal
details such as email addreses.

If the `to` field is not present, the method will make a GET reqeust and
there will be no change to how it works.
2022-01-04 11:14:16 +00:00
Rebecca Law
f8e7635a1d Show the first line of the address from the to field.
Now persisting the address to the "to" field of the Notification, after the notification has been validated.
If the letter is pending validation, then "Checking..." will appear as the identifier for the letter.
If the letter has passed validation, then the first line of the address (now persisted in the "to" field) will be displayed, with the client reference underneath.
If the letter has failed validation the "Provided as PDF" will show be displayed, which is now the initial value of the "to" field.
2020-01-10 16:00:40 +00:00
Pea Tyczynska
678e0bed81 Show users more detailed validation failed mesage on notification page
Show valdiation failed messages on letter notifications in red text,
not in the banner like we do on Uploads and Validation checker pages.
This is because it is a different step in the journey: the user
has already sent the notification and styling needs to be in line
with other places where user is checking the notification she already
has sent.
2019-11-07 11:10:27 +00:00
David McDonald
2b8b4c25aa Send postage value to API when sending pre compiled letter 2019-11-01 10:47:42 +00:00
David McDonald
3436a190a7 Send precompiled letters with a postage value to the API
We hardcode this as second class for the moment but eventually
will let the user pick.

Currently the API appears to do no validation, e.g. a json
schema, that rejects API calls with the extra key for postage.

Next steps will be to put a PR into the API that will expect a
postage value in the request and save it with the rest of the
notification. Then when that is done we can add the user interface
to the admin app to let the user pick the postage.
2019-10-18 16:35:16 +01:00
Pea Tyczynska
9058b13ff2 Get notification count from api instead of list of notifications
when checking if job can be cancelled. This makes query lighter,
less likely to fall over if job is large and removes
pagination bug.
2019-09-24 19:07:20 +01:00
Katie Smith
79053dec93 Allow uploaded letters to be sent if valid
Added a send button which only appears on the page if the query string
indicates that the PDF is valid. Before actually sending, we check that
the service has the right permissions and that the metadata for the
letter confirms the letter is valid (because the query string can be
changed).
2019-09-12 09:54:36 +01:00
Katie Smith
9dc13f1d8e Add new report to show monthly notification stats for each service
This report will be used by the engagement team. There is a form to give
a start and end date for the report, and the form is then downloaded
as a CSV file when the form is submitted.
2019-07-23 11:32:28 +01:00
Pea Tyczynska
e0b61e3d70 Call precompiled letter preview with overlay 2019-04-04 12:05:17 +01:00
Leo Hemsted
53cdbad2cc make inbound search a POST
that way it doesn't expose PII to our logs
2019-03-29 15:16:29 +00:00
Chris Hill-Scott
1d3a4e5043 Inherit don’t duplicate API client constructor
This removes some code which is duplicative and obscure (ie it’s not
very clear why we do `"a" * 73` even though there is a Very Good Reason
for doing so).
2019-01-29 12:11:27 +00:00
Alexey Bezhan
6cd18f87de Don't request pagination links for API Message log page
Counting pages for API notifications takes a long time for services
with a lot of sent messages (since it issues a `count(*)` query for
the given filter). Since API message log doesn't have a "Next page"
link we can skip the count by setting a flag on the API request.
2019-01-08 15:35:44 +00:00
Pea Tyczynska
b8318c491b Format letter statuses so they make more sense to our users 2019-01-07 15:17:09 +00:00
Katie Smith
1ee972bd04 Add endpoint for cancelling letters to NotificationApiClient 2018-12-05 11:03:59 +00:00
Chris Hill-Scott
9e798506c5 Initialise clients outside the app
This avoids the annoying problem where you can’t import a client unless
the app has already been initialised.
2018-10-30 14:59:24 +00:00
Katie Smith
eb9e9fac3b Ensure one-off jobs do not appear on message log page
Upcoming changes to API will mean that by default its
`get_notifications_for_service` DAO function will return one-off
notifications. In most cases this is what we want, but the message log
page should not show one-off notifications. By passing in the `include_one_off=False`
option to API we can ensure that this page will stay the same when API
changes.
2018-07-18 08:11:42 +01:00
Ken Tsang
4628b99445 Refactor to move preview logic to API
* Moved the notifications code to go to admin to get the the template

preview document rather than go to template preview.

This will remove the logic from admin and place it in api so it is
easier to expand on later when there are precompiled PDFs

* Added some error handling if API returns an API error.

Caught the error and displayed an error PNG so it is obvious something
failed. Currently it displayed a thumbnail of a png over the top of the
loading page, and therefore it wasn't obvious of the state.
2018-03-08 12:25:07 +00:00
Rebecca Law
bc731ec54d Revert "Letter preview use api not template preview" 2018-03-06 13:47:43 +00:00
kentsanggds
acf7b331ad Merge pull request #1918 from alphagov/letter_preview_use_api_not_template_preview
Letter preview use api not template preview
2018-03-05 16:21:12 +00:00
Ken Tsang
6279169b18 WIP refactor preview pdf 2018-03-01 15:21:50 +00:00
Richard Chapman
c4f0b4d35d Moved the notifications code to go to admin to get the the template
preview document rather than go to template preview.

This will remove the logic from admin and place it in api so it is
easier to expand on later when there are precompiled PDFs
2018-03-01 15:21:50 +00:00
Alexey Bezhan
acfe8092fc Add route secret key header to the API requests
Currently requests to the API made from the admin app are going from
PaaS admin app to the nginx router ELB, which then routes them back
to the api app on PaaS.

This makes sense for external requests, but for requests made from
the admin app we could skip nginx and go directly to the api PaaS
host, which should reduce load on the nginx instances and
potentially reduce latency of the api requests.

API apps on PaaS are checking the X-Custom-Forwarder header (which
is set by nginx on proxy_pass requests) to only allow requests going
through the proxy.

This adds the custom header to the API client requests, so that they
can pass that header check without going through nginx.
2018-02-28 11:28:46 +00:00
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
chrisw
e149d0eb91 Allow one-off email sending to select the reply-to address 2017-10-17 11:15:26 +01:00
chrisw
43395bc9d9 Added letters info to service / admin dashboard & activity page 2017-10-03 10:28:34 +01:00
Leo Hemsted
03397f416e move status mapping logic to the api client
also added tests 👼
2017-09-20 16:02:15 +01:00
Chris Hill-Scott
415e1a401a Don’t set combined API on Notify python client
Because we’re setting the API key and service ID after calling the
`__init__` method of the client it wasn’t doing the thing where it
splits the combined key into the two individual UUIDs. So we still need
to set them directly, individually on the client.
2017-07-26 12:08:10 +01:00
Chris Hill-Scott
5ddbe80ea9 Fix calls to API client which now takes fewer args
The Notify API client changed in version 4 to take two arguments, not
three (service ID was removed in favour of the combined API key).

This gets a bit gnarly because the API key has to be at least a certain
length so it can be substringed internally.
2017-07-26 11:10:37 +01:00
Leo Hemsted
a31bf0c5ce add tests for new check and send notification endpoints 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
Leo Hemsted
580c225ca2 Change client_request so its kwargs look more like url_for 2017-06-19 12:31:14 +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
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
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
Imdad Ahad
99805fb592 Add extra flag to indicate we want a csv notification response 2017-04-20 15:18:47 +01:00
Martyn Inglis
08dc8fb13d Use the local APIClient rather than the one from the python-api-client
- ensures that all API calls set the request ID when talking to the API.
2016-11-30 17:01:44 +00:00
Rebecca Law
cebf8e1d65 Removed get_all_notifications method from notification_api_client as it is not longer being used. 2016-11-18 14:39:23 +00:00
Chris Hill-Scott
a04aad8825 Add additional params to get notifications client
We want to show a log of notifications that have been sent from the API.

The admin app uses its own private `/service/…/notifications` endpoint
for listing activity. This commit allows us to pass through two
optional, additional parameters to tell the API to:

- include or not include notifications created from a job
- include or not include notifications created with a test API key
2016-09-29 09:27:55 +01:00
Chris Hill-Scott
ce0b3511e6 Make indentation more sensible
Starting arguments on their own line and putting the closing parenthesis
on it’s own line because any subsequent changes to the arguments diff
cleanly (ie without touching any other lines).
2016-09-29 09:27:46 +01:00
Chris Hill-Scott
92aacc1a54 Remove extraneous arguments to super
> dont need self.__class__, self in super - that's a python 2.x crutch.
> super() is equivalent
2016-09-12 14:59:53 +01:00
Chris Hill-Scott
5fda35c89d Make it clear that client do not use __init__
The clients never get passed useful values to their `__init__` methods.
Rather the real values are passed through later using the `init_app`
method.

So it should be an error if the client is relying on the values that
get passed to it’s init method. Easiest way to ensure this is by making
the `__init__` method not expect any arguments and passing fake values
to the `Super` call.
2016-09-12 12:18:19 +01:00
Chris Hill-Scott
fa5e5475e9 Update Python client
Just so that nobody else has to do it.

Implements:
- [x] https://github.com/alphagov/notifications-python-client/pull/29

Which is a breaking change requiring the renaming of method arguments.
2016-09-08 15:55:07 +01:00
Adam Shimali
a627cf9002 Change activity to view to request 7 days data.
Cleaned up filters a bit so that if you want both templates
email and sms is passed.

Added mock assertion to test.
2016-04-28 15:52:20 +01:00
Nicholas Staples
f3210ea992 Functionality added to download all on activity page. All tests passing. 2016-04-19 11:45:36 +01:00
Nicholas Staples
a41dda8884 Working functionality for filtering notifications and all tests passing. 2016-04-04 16:34:06 +01:00
Chris Hill-Scott
2f76ef27ce Add API client for notifications
This commit adds an API client for the notifications endpoints added in:
https://github.com/alphagov/notifications-api/pull/113
2016-03-03 11:15:50 +00:00