Commit Graph

872 Commits

Author SHA1 Message Date
Rebecca Law
3dfb3806d2 Add a selectField to edit and create templates that is only visible for platform admins that makes the template a priority template.
There is a check that the template can not be created as priority if the user is not a platform admin.
There is a check that the template can not change the `priority` unless they are a platform admin.
2017-01-18 15:11:34 +00:00
imdadahad
b5cb34c368 Merge pull request #1070 from alphagov/return-streamed-csv
Fix timeout on download of large CSV reports
2017-01-16 10:34:25 +00:00
Imdad Ahad
59c7bc2e6f Refactor get notifications streaming including formatting 2017-01-13 11:35:27 +00:00
Imdad Ahad
e28d009fa7 Return csv download stream instead of all-in-memory 2017-01-06 17:41:24 +00:00
Chris Hill-Scott
2854dbe3dd Refactor PNG generating endpoint for code reuse
The way we generate PNGs is the same for all the different endpoints,
so the code to do this should be shared.
2017-01-04 15:45:59 +00:00
Chris Hill-Scott
559433c5d2 Add remaining endpoints for PDFs and PNGs
Right now we can show what a letter template looks like as a PDF or PNG.

This commit completes the work so this is also possible when:

- showing a template with the placeholders replaced
- showing any version of a template

Also removes dependency on `Exception().message`, which was deprecated
in Python 2.6. See
97f82d565f
for full details.
2017-01-04 15:45:59 +00:00
Chris Hill-Scott
a159f351a8 Split endpoints that use templates
We’ll need to reuse the logic for viewing images and PDFs of templates,
so let’s have it in a shared method which the HTML endpoint then calls.
2017-01-04 15:45:58 +00:00
Rebecca Law
ea73936f0b Merge pull request #1067 from alphagov/add-date-range-filter-to-platform-admin
Add date range filter to platform admin
2017-01-04 14:21:16 +00:00
Rebecca Law
21582cadb3 Get the BooleanField working in the form. 2017-01-03 16:14:25 +00:00
Rebecca Law
2e69d3c680 Add date filter for platform admin page. 2017-01-03 10:45:06 +00:00
Rebecca Law
5572d0f25f This commit renders the platform admin page with the given start and end date query params.
Need to add a form to the page to take these params.
2016-12-28 15:23:19 +00:00
Rebecca Law
df41da4860 [WIP] Attempt at adding a form to the platform admin page is not working well for me here. But I want to commit it so I can look at it again. 2016-12-28 14:44:53 +00:00
Rebecca Law
7b54e0c463 After investigating a 500 in the admin app, I found an edge case in the invitation registration flow that can cause an error.
The flow is as follows:
If the invited user clicks on the /invitation/<token> link in the email (now on /register-from-invite),
then goes to another browser and registers for Notify.
Coming back to the other browser, submit the form for /register-from-invite.

This PR fixes that bug and adds a couple tests for register_from_invite
2016-12-22 11:43:11 +00:00
Chris Hill-Scott
1c679ae621 Make breaking change not use rendered template
The breaking change page was taking the rendered template and saving
that if the user confirmed the change. This meant that templates could
be saved with `<span class="placeholder">…</span>` in their subject line
for example.

This commit fixes it so that it uses whatever data the user submitted,
not the rendered version of this.
2016-12-14 14:32:07 +00:00
Chris Hill-Scott
dc63de0f4e Incorporate breaking utils changes
Brings in:
- [ ] https://github.com/alphagov/notifications-utils/pull/94
2016-12-14 14:32:07 +00:00
Chris Hill-Scott
ae356fc741 Use PDF link renderer to preview letters
Depends on and implements:
- [x] https://github.com/alphagov/notifications-utils/pull/84
- [ ] https://github.com/alphagov/notifications-utils/pull/86
2016-12-13 10:34:19 +00:00
Chris Hill-Scott
43296469d6 Add endpoint for generating an image of a letter
The PDF preview is all good, but it’s hard, finickeity and feels dirty
to embed a PDF in a web page. It’s a more natural thing to embed an
image in a web page.

So this commit adds another endpoint to return an image of a letter
template. It generates this image from the PDF preview, so the stack
looks like:

1. `template.png` (generated in admin)
2. `template.pdf` (generated in admin)
3. HTML preview (generated by a `Renderer` in utils)
4. `Template` instance
5. serialised template from API
6. Template stored in database

The library used to convert the PDF to an image is Wand[1], which binds
to ImageMagick underneath. So in order to get this working locally on a
Mac you will probably need to do:
`brew install imagemagick ghostscript cairo pango`.

To get it working on Ubuntu/EC2 is an exercise left to the reader…

1. http://docs.wand-py.org/en/0.4.4/
2016-12-13 10:34:18 +00:00
Chris Hill-Scott
d0f90eac7e Add an endpoint for generating a PDF of a letter
Previewing a letter is different to previewing an email or text message
because:

- a letter has a layout
- the layout is fixed, ie it doesn’t depend on the user’s device
- the ‘send yourself a test’ feature won’t be as useful because it has
  a lead time, so the feedback loop will be much longer

For these reasons a HTML-only preview of the letter won’t be enough (we
don’t think). A PDF is more appropriate because:

- it can replicate the layout of the letter exactly
- it is a print format, so the user could even print themselves a copy
  locally to get a feel for how it will look

This commit makes use of Flask WeasyPrint [1] to take a HTML
representation of the letter, convert it to a PDF and serve it back to
the user.

The actual work to generate the HTML and specify the layout is done in
utils, same as we do for rendering other messages.

1. https://pythonhosted.org/Flask-WeasyPrint/
2016-12-13 10:34:18 +00:00
Jenny Duckett
c88a961e04 Add option to exclude test key stats on platform admin page
This page currently includes all notifications for all services, including
those sent using a test key. Stats on all other pages exclude test key usage,
though, which can lead to confusion for admins comparing numbers between
pages. Adding the option to toggle between including and excluding test key
usage on the platform admin page gives context for this difference, and allows
admins to see live usage of the platform as well as load associated with test
key usage.
2016-12-06 12:42:27 +00:00
Chris Hill-Scott
18d11aa013 Move code for rendering messages/templates → utils
Utils is better structured to handle the logic of what thing to show
for what template type, especially now that what we show for different
template types in different contexts has diverged significantly.

See https://github.com/alphagov/notifications-utils/commit/6b39c1a for
an example of this code moving into utils

Depends on and implements:
https://github.com/alphagov/notifications-utils/pull/84

The main reason for doing this is to get Paul’s fix for the misaligned
CSV columns: https://github.com/alphagov/notifications-utils/pull/87
2016-12-05 12:11:54 +00:00
Leo Hemsted
08881e5bd1 add get_active_services method
* all current invocations of get_services now call get_active_services
  EXCEPT for platform admin page (where we want to see inactive services
* cleaned up parameter names and unpacking (since *params is unhelpful)
* fixed incorrect kwarg name in conftest
2016-11-16 11:08:20 +00:00
Leo Hemsted
b885ce9cf4 clean up some usage of active in tests and remove it from service_api_client.create_service (created services are always active) 2016-11-16 11:08:20 +00:00
Leo Hemsted
045864f052 Merge pull request #1022 from alphagov/deactivate-services-plat-admin
Deactivate services plat admin
2016-11-16 11:07:52 +00:00
Chris Hill-Scott
48496eefde Merge pull request #1024 from alphagov/add-letters-templates-2
Let users upload a CSV file of addresses against a letter template
2016-11-15 17:57:28 +01:00
Leo Hemsted
5edb8cd086 revert platform admin statistics
was erroneously using 'requested' rather than calculating 'sending'
2016-11-15 11:12:19 +00:00
Leo Hemsted
d26f7ac441 Merge branch 'master' of github.com:alphagov/notifications-admin into deactivate-services-plat-admin 2016-11-14 17:15:05 +00:00
imdadahad
6a9973d1b6 Merge pull request #1025 from alphagov/show-email-sms-stats-platform-admin
Show email and sms counts for each service on platform admin
2016-11-14 16:56:00 +00:00
imdadahad
49082ab646 Revert user_profile back original
This change shouldn't be in this PR and got in somehow :(
2016-11-14 16:49:25 +00:00
Imdad Ahad
5ce0cbe1db Refactor stats into a macro and add format number red on failure 2016-11-14 16:42:08 +00:00
Chris Hill-Scott
a108165e47 Give more realistic example address data
Posit that examples of where you can put different parts of the address
is more helpful than ‘example, example, example’. Also shows that you
don’t have to fill all of the address columns.

Spot the Easter egg 🎅
2016-11-14 14:53:07 +00:00
Chris Hill-Scott
69ad5fe156 Handle multi-column recipients
Implements https://github.com/alphagov/notifications-utils/pull/81

Handles addresses as multiple columns:
- in ‘Send yourself a test’
- in example CSV files
- in validating that a CSV file has recipients (eg at least an ‘address
  line 1’ and ‘postcode’ column)
- when showing the contents of a CSV file

As few UI changes as possible, once we have the thing working end-to-end
we can think about how the UI might need to work differently.
2016-11-14 14:53:06 +00:00
Chris Hill-Scott
5772fd34fe Remove placeholder letters page
👋 emoji
2016-11-14 14:51:28 +00:00
Chris Hill-Scott
70eec8fe73 Don’t let people actually start a letter job
Who knows what would happen if a job with a letter template actually
got into the database. `403`ing the page is a quick and dirty hack to
stop this from happening.
2016-11-14 14:51:27 +00:00
Chris Hill-Scott
88631a680c Sprinkle letter throughout the app
Let users create/edit/delete letter templates.

Let them upload a CSV file or send a test against a letter template.

Big assumption at the moment is that addresses only have one line, and
therefore one column in the CSV file.
2016-11-14 14:51:26 +00:00
Imdad Ahad
ec7ec77b69 Return the email and sms stats instead of summing them 2016-11-14 14:45:41 +00:00
Chris Hill-Scott
e164c4d5b1 Merge pull request #1023 from alphagov/sms-sender-fix
Fix errant service name in text messages
2016-11-14 15:04:25 +01:00
Chris Hill-Scott
b68ebbb107 Fix errant service name in text messages
Was missed as part of:
https://github.com/alphagov/notifications-admin/pull/905
2016-11-14 13:08:27 +00:00
Leo Hemsted
63de598d31 Merge pull request #1008 from alphagov/deactivate-service
Deactivate service
2016-11-14 11:41:13 +00:00
imdadahad
115cbe67e5 Merge pull request #1011 from alphagov/update-user-profile
Update user profile
2016-11-11 14:47:13 +00:00
Imdad Ahad
e5ea81b184 Fix pep issues and refactor tests 2016-11-10 10:45:09 +00:00
Imdad Ahad
c28aea2de1 Update user profile attributes with new method 2016-11-09 15:05:06 +00:00
Leo Hemsted
defa93809a show archived label on platform admin page, and sort last 2016-11-08 15:00:44 +00:00
Leo Hemsted
7a48e25dbb flash up prompt when archiving a service
same way as we do when deleting templates

(also rename button from deactivate -> archive)
2016-11-08 14:33:53 +00:00
Chris Hill-Scott
4ae28386a6 Always show live key, reword key labels
This is trying to resolve these confusions:

- that you’re in trial mode, which means you can’t have a live key yet (
  or you can but it wont work, which is what we used to have)
- what does simulate mean

The create key page is the right place to resolve these confusions
because it’s where users are actively reading.

This commit also removes the trial mode banner from API integration
page because this where users _aren’t_ actively reading. A whole bunch
of users weren’t seeing this banner at all.

The implementation of the disabled API key options is kinda clunky
because WTForms doesn’t have a native way of doing this.

¯\_(ツ)_/¯
2016-11-04 14:05:30 +00:00
Chris Hill-Scott
6a07b8bac2 Merge pull request #1006 from alphagov/request-to-go-live-improvements
Make certain questions on request to go live radio buttons
2016-11-04 14:05:54 +01:00
Leo Hemsted
a216259a8e Merge pull request #1005 from alphagov/letters-nav
allow users to see letters even if they dont have edit permissions
2016-11-04 09:46:27 +00:00
Imdad Ahad
f14c3dbfa5 Stop passing the 'whole' user object when making changes to profile 2016-11-03 11:20:24 +00:00
Chris Hill-Scott
274b2893f7 Merge pull request #979 from alphagov/4-days-scheduled
Allow a job to be scheduled any time in next 4 days
2016-11-03 10:24:07 +01:00
Leo Hemsted
a982144821 add deactivate service button on the service settings page
only visible for platform admins looking at active services.
no way to undo. no confirm button.
2016-11-02 16:53:40 +00:00
Leo Hemsted
e89f89bd11 remove unused delete service functionality 2016-11-02 10:29:44 +00:00