Commit Graph

33 Commits

Author SHA1 Message Date
Chris Hill-Scott
50c20ce680 Add formatted notification status to CSV
This commit makes the CSV download use the same language for failure
reasons as the frontend.

It also adds a test around this stuff, which was patchily tested before.
2016-07-11 13:12:46 +01:00
Chris Hill-Scott
d33c254fa5 Merge pull request #743 from alphagov/hide-delivery-download-tour
Hide download CSV link when in the tour
2016-07-08 16:31:16 +01:00
Chris Hill-Scott
84a2862387 Fix 500 being thrown when uploading large files
This is re-fixing a bug which was re-introduced when adding the
`Spreadsheet` class in 1409ca36ca.

It was previously fixed in 19662d8329:

>  Fix bug with large file uploads
>
>  Depending on the size of the uploaded file, Flask will temporarily store
>  it in different ways. This means that it comes back as a `TempFile` if
>  the file is roughly <500k and as `BytesIO` if the file is larger.
>
>  `TempFile` supports the `.getvalue()` method, but `BytesIO` does not.
>  Both support the `.read()` method, so this commit changes to use that
>  instead.
2016-07-07 11:52:57 +01:00
Chris Hill-Scott
80e0832f7d Make a function for parsing help query param
Our templates are a littered with `request.args.get('help', '0')`.
This commit refactors these into a single helper method, which can be
used by the view functions, then passed to the template.

This makes the templates cleaner, and should make it easier to refactor
`help` out of the query parameters entirely in the future.
2016-07-05 17:29:41 +01:00
Leo Hemsted
539950d772 when not logged in, redirect to sign-in
parts of the initial setup/login stages were throwing 500s if user
not already in process (ie: user directly navigated to url):
* /resend-email-verification
* /text-not-received
* /send-new-code
* verify
2016-06-17 13:53:48 +01:00
Chris Hill-Scott
2ff6cf049f Change order of errors for bad CSV files
This commit rearranges the CSV errors (again) to make them geared towards
teaching you how to match placeholders to the column headers.

So the order of errors now is:

1. No phone number/email column
2. Column headers don’t match placeholders
3. Missing or bad data
4. Trial mode
5. Daily limit reached

This depends on:
- [x] https://github.com/alphagov/notifications-utils/pull/39 for 1.
2016-06-03 16:26:58 +01:00
Nicholas Staples
5ef5920c17 Job notification download now includes all notifications.
Get row number to match excel format.

Fix for no job_row_number.
2016-05-31 10:43:14 +01:00
Nicholas Staples
2505d1421b Fixed download bug for services with api notifications. Re-organised the mock job and job_json methods. 2016-05-24 12:35:12 +01:00
Chris Hill-Scott
000d630cae Use Spreadsheet class to generate example CSVs
This means not repeating a bunch of `with StringIO` blocks all
over the place.
2016-05-16 13:05:41 +01:00
Chris Hill-Scott
1409ca36ca Accept common spreadsheet formats, not just CSV
We require users to export their spreadsheets as CSV files before
uploading them. But this seems like the sort of thing a computer should
be able to do.

So this commit adds a wrapper class which:
- takes a the uploaded file
- returns it in a normalised format, or reads it using pyexcel[1]
- gives the data back in CSV format

This allows us to accept `.csv`, `.xlsx`, `.xls` (97 and 95), `.ods`,
`.xlsm` and `.tsv` files. We can upload the resultant CSV just like
normal, and process it for errors as before.

Testing
---

To test this I’ve added a selection of common spreadsheet files as test
data. They all contain the same data, so the tests look to see that the
resultant CSV output is the same for each.

UI changes
---

This commit doesn’t change the UI, apart from to give a different error
message if a user uploads a file type that we still don’t understand.

I intend to do this as a separate pull request, in order to fulfil
https://www.pivotaltracker.com/story/show/119371637
2016-05-15 22:10:58 +01:00
Chris Hill-Scott
a0e3a648f3 Fix innacurate error message on CSV check
We only know if a row contains missing cell(s), not how many cells are
missing data.

This commit changes the error message to be more accurate.
2016-04-18 11:47:53 +01:00
Nicholas Staples
6ea72182d2 Download CSV option now available. 2016-04-12 14:19:51 +01:00
Nicholas Staples
a41dda8884 Working functionality for filtering notifications and all tests passing. 2016-04-04 16:34:06 +01:00
Rebecca Law
677237ba47 Update email_from when the service name is changed.
Update unit tests
Service name is uniqueness is not based on case.
2016-03-30 17:12:00 +01:00
Rebecca Law
e67bb5f716 Fix main_nav for platform admin
Renamed or_ to any_
2016-03-30 11:30:18 +01:00
Rebecca Law
402f55be23 Merge branch 'master' into platform-admin
Conflicts:
	app/__init__.py
	app/main/views/add_service.py
	app/main/views/jobs.py
	app/templates/main_nav.html
	tests/app/main/views/test_dashboard.py
	tests/conftest.py
2016-03-18 16:32:10 +00:00
Rebecca Law
13d9acf7dd Completion of the platform admin user story. 2016-03-18 16:20:37 +00:00
Nicholas Staples
24dbdc8202 Syntax fix 2016-03-18 15:37:58 +00:00
Rebecca Law
d003dc4aa9 [WIP]: fixing unit tests 2016-03-18 10:49:22 +00:00
Rebecca Law
b28fbc16d7 A platform admin user is able to see a list of all services.
Each service on the list is linked to the dashboard page of the service.
The platform admin user can see/edit templates, see/invite users, see/edit service settings.
The platform admin user can not send messages, see/edit api keys and developer docs.
2016-03-17 10:46:47 +00:00
Nicholas Staples
b0ca855ba8 Notification history page added and pagination, tests all working. 2016-03-16 16:57:10 +00:00
Chris Hill-Scott
eb3734f1d1 Give the user better error messages for CSV files
Makes uses of the additions to utils in https://github.com/alphagov/notifications-utils/pull/9

This commit strips out a lot of the complex stuff that the views and templates
in this app were doing. There is now a cleaner separation of concerns:

- utils returns the number and type of errors in the csv
- `get_errors_for_csv` helper in this app maps the number and type of errors
  onto human-friendly error messages
- the view and template just doing the glueing-together of all the pieces

This is (hopefully) easier to understand, definitely makes the component
parts easier to test in isolation, and makes it easier to give more specific
error messages.
2016-03-08 18:36:22 +00:00
Chris Hill-Scott
0a5bf0bc44 Update to utils 2.0.0
…and remove the code from this app that has moved into utils.
2016-03-08 17:18:42 +00:00
Rebecca Law
e3c692ede7 Validate column heading.
Still need to show that it is the heading that is wrong.
2016-03-04 10:09:46 +00:00
Nicholas Staples
1b59e5c7f1 Review comments fixed. All tests passing. 2016-03-03 09:02:56 +00:00
Nicholas Staples
dde2fba705 Merge with master again. 2016-03-02 13:53:05 +00:00
Chris Hill-Scott
b57ac2f7e5 Accept CSVs with 'email address' or 'phone number'
CSV files currently have ‘to’ as the recipient column. This is changing in
https://github.com/alphagov/notifications-api/pull/109

The admin app also has to validate that the CSV files have the right columns,
because the API expects any CSV that it’s given to have been checked (also we
want things to actually work).

This commit is the minimum code change needed. In the future it should reuse
the same code as the API for processing CSV files. This will need more thinking.
2016-03-02 10:41:35 +00:00
Nicholas Staples
ffe30c3070 Permissions added for templates and send_messages pages. All tests passing.
Fix up page heading.
2016-02-29 17:18:12 +00:00
Nicholas Staples
58351a094c Merge with master. 2016-02-29 14:59:15 +00:00
Nicholas Staples
48943527ec API keys hooked up and working. All tests passing. 2016-02-29 14:57:07 +00:00
Chris Hill-Scott
1e46922876 Make send the send flow generic
This commit parameterises all methods in the send view so that they can send
either emails or SMS messages.

It works out what kind of message it is sending from the `template_type`
property of the template object.

This means that the `Template` util class needs to know about these properties,
which means that this commit depends on:
https://github.com/alphagov/notifications-utils/pull/2

This commit does _not_ add tests for sending emails. The existing tests for
sending SMS still pass, but actually sending emails is outside the scope of
this story.
2016-02-24 09:23:38 +00:00
Nicholas Staples
32e37d89fb User permissions added with test. 2016-02-19 16:38:04 +00:00
Chris Hill-Scott
45cacd82d3 Validate CSVs fully
This commit extends the existing function to validate each row’s phone number
to also validate that all the required data is present.

It does this using the checking that the `Template` class can do when given
a template and a `dict` of values.
2016-02-18 15:07:15 +00:00