Commit Graph

883 Commits

Author SHA1 Message Date
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
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
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
Leo Hemsted
466d0b10ac Merge pull request #1051 from alphagov/inactive-service
users can't edit inactive services
2016-12-12 14:59:30 +00:00
Leo Hemsted
2419f0d8a9 write tests for @minglis 's code 🙁 2016-12-09 16:09:47 +00:00
Leo Hemsted
255ce158b7 block inactive services from making stateful changes
in the NotifyAdminAPIClient, which all api traffic goes through, return
403 for any stateful requests (post, put and delete), if the following
criteria have been met:
* a current_service is set
    (this prevents checks being carried out on non-service related
     updates, eg editing user details)
* the service is not active
* the current user is not a platform admin

so platform admins can still update anything.

Note: Without any specific error handling, the user will see a generic
403 page. This is fine, probably - it's a relatively niche case that
you'll be editing a service you can't get to anyway
2016-12-09 15:44:58 +00:00
Chris Hill-Scott
db6bb77d74 Don’t allow suppliers to sign up for own accounts
Suppliers need to be invited by people who work for the government.
People who work for the government can invite anyone to join their team,
no matter what their email address is.

So there’s no need for these domains to be in the list now.
2016-12-07 13:57:26 +00:00
Chris Hill-Scott
b4a7ffff8d Add Natural England to gov. email domains list
> I cannot register as the Email address field will not accept my email
> address format (.org.uk).  Natural England is a non-departmental
> government body sponsored by Defra (Department for Environment, Food
> and Rural Affairs).  Can you register me on the system or change the
> system so it will accept my email address?

– Deskpro ticket

> Natural England is an executive non-departmental public body,
> sponsored by the Department for Environment, Food & Rural Affairs.

– https://www.gov.uk/government/organisations/natural-england

***

Checks out…
2016-12-07 12:58:49 +00:00
Jenny Duckett
93405dd56b Move day and test key messages to <p> instead of left column
We don't want large numbers in Production to start overlapping other columns
in the tables when they have less space available, and putting these messages
at the top of the page under the h1 means that we don't need an extra column
on the page yet.
2016-12-06 12:46:11 +00:00
Jenny Duckett
3a637c8fa9 Move "Today" heading to left column on platform admin page
When we make the numbers on this page more filterable the date range will be
one of the options to change, so it makes sense to move it to the side now
instead of leaving it above the big numbers.
2016-12-06 12:42:27 +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
Rebecca Law
1efa5530d4 Merge pull request #1027 from alphagov/deactivate-services-all-services-list
dont show inactive services on the choose service list
2016-11-23 16:10: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
Leo Hemsted
805639a2e1 add test for choose services and related redirects to it
it'll just show the add service button if you only have archived services
2016-11-16 13:18:49 +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
28adea52ab fix tests for new platform admin layout 2016-11-14 17:25:07 +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
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
dbbb2f7848 Fix comment 2016-11-14 14:50:36 +00:00
Imdad Ahad
c1649e85a6 Ensure stats shown on platform admin are correct and refactor original test for new layout 2016-11-14 14:46:52 +00:00
Leo Hemsted
63de598d31 Merge pull request #1008 from alphagov/deactivate-service
Deactivate service
2016-11-14 11:41:13 +00:00
Leo Hemsted
fb85877c75 add tests for platform admin list ordering 2016-11-14 11:33:39 +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
f3ca33dad3 Revert original update user method and add new attribute update (with strict checking) 2016-11-09 15:06:02 +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
1c42640137 Update update user mock to conform to new format 2016-11-03 11:20:43 +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
Chris Hill-Scott
82064ca4d0 Make MOU a multiple choice question not a banner
If we want someone to read something (ie that they need to have the MOU
signed), then the best way is to make them interact with it.

And if someone doesn’t have the MOU in place, then we need to know to
send them a copy. The best way of them telling us this is in this form,
rather than sending them to the generic contact form and have them
compose a message saying ‘please send me the MOU thanks’, which we
haven’t seen anyone actually do.
2016-11-01 12:23:49 +00:00
Chris Hill-Scott
d832a9107c Use radio buttons not textboxes for multi-choice
No need to make people type when they can click, and gives us consistent
data.
2016-11-01 11:39:22 +00:00
Leo Hemsted
93cdaf1811 allow users to see letters even if they dont have edit permissions
same way as we handle seeing emails/sms
2016-10-31 18:01:31 +00:00
Leo Hemsted
96c592be10 add user permissions to the letters endpoints
you can get in with either "manage_templates" or "send_letters"

also improve running of a bunch of tests, by parametrising rather than
looping and by cleaning up some mock imports
2016-10-31 14:43:40 +00:00
Leo Hemsted
e0fcb79b9b Merge branch 'master' of github.com:alphagov/notifications-admin into letters-flag 2016-10-31 14:04:05 +00:00
Chris Hill-Scott
3761a7a436 If possible, show sent not uploaded time for jobs
If you’re looking back at a job that was scheduled and has now been sent
it’s more useful and consistent to know what time it went out. The time
it was uploaded at is a bit arbitrary once it’s sent.

The only time the uploaded time is relevant is when the job is still
waiting to be sent.

Slightly fiddlier than it sounds because we never want to show
‘uploaded by’ for a job that hasn’t been scheduled because it almost
immediately changes to ‘sent by’. This flickering of the UI is
undesirable.
2016-10-31 09:14:05 +00:00
Chris Hill-Scott
4b0d8ec636 Use days of week, not month for scheduled jobs
Friday at 4pm is easier to understand than 14 October at 4pm, especially
when the UI you’ve used to choose this time has talked about days of the
week.
2016-10-31 09:14:05 +00:00
Chris Hill-Scott
8a01e6af36 Make it say later today
Categories before:

> Now, today, tomorrow, Friday…

Categories after:

> Now, later today, tomorrow Friday…

This reduces the ambiguity of ‘now’ vs ‘today’, and keeping the word
‘later’ suggests what this features is about.

This implementation here is a bit hacky, but it works…
2016-10-31 09:14:05 +00:00