Commit Graph

5132 Commits

Author SHA1 Message Date
Chris Hill-Scott
4384c1df15 Merge pull request #1929 from alphagov/show-download-letters
Show CSV download link for letter jobs
2018-03-06 14:28:00 +00:00
Leo Hemsted
92b4cee033 Merge pull request #1917 from alphagov/permissions-refactor
Permissions refactor
2018-03-06 13:21:17 +00:00
Leo Hemsted
3be4b57bbd fix imports 2018-03-06 13:10:37 +00:00
Leo Hemsted
793d79c242 ensure invited user permissions show up correctly 2018-03-06 13:08:07 +00:00
Leo Hemsted
7f268c0ab3 don't allow us to create permissions decorator without permissions
ie: not for an organisation, and not for a service
2018-03-06 13:08:07 +00:00
Leo Hemsted
d14f33ea70 has_permissions() now checks user's orgs for <org_id> view args
view args are parameters within the route. for example,
`/organisation/<org_id>/users`. If there is an org_id, then check that
the user is part of that organisation (users.organisations is a list of
all orgs that user is a member of).

* platform admins ignore this check if restrict_admin_usage=False
* if an endpoint has both org_id and service_id, org_id takes
  precedence, but we should probably revisit this if we ever need
  to create such an endpoint.
* you now call `@user_has_permissions()` with no arguments for
  organisation endpoints - we can look at this if we decide we want
  more clarity.
* you should never call user_has_permissions without any arguments
  for endpoints that aren't organisation-based. We'll raise
  NotImplementedError if you do.
2018-03-06 13:08:07 +00:00
Leo Hemsted
3d589887ce remove useless properties from user model
we don't need them to mask private variables if we're not doing anything unusual.
2018-03-06 13:08:07 +00:00
Leo Hemsted
8acf5115d5 add restrict_admin_usage flag to more of the send flow 2018-03-06 13:08:07 +00:00
Leo Hemsted
3afc193624 remove any_ from has_permissions
we branch on any_ to either say "require ALL these permissions" or
"require ANY of these permissions". But we only ever call the decorator
with one permission, or with any_=True, so it's unnecessary
2018-03-06 13:08:07 +00:00
Leo Hemsted
4a08cf81e7 remove admin_override from all has_permissions usage
as previously pointed out, it's not used anywhere.
2018-03-06 13:08:07 +00:00
Leo Hemsted
3ae815528c add restrict_admin_usage arg to admin_override
rather than allow admins to do everything specifically, we should
only block them from things we conciously don't want them to do.
This is "Don't let platform admins send letters from services they're
not in". Everything else the platform admins can do.

This is step one, adding a restrict_admin_usage flag, and setting that
for those restricted endpoints around creating api keys, uploading CSVs
and sending one-off messages.

Also, this commit separates the two use cases for permissions:
* user.has_permission for access control
* user.has_permission_for_service for user info - this is used for
  showing checkboxes on the manage-users page for example

With this, we can remove the admin_override flag from the permission
decorator.
2018-03-06 13:08:06 +00:00
Leo Hemsted
09824078dd remove all instances of db style permissions
lots of renaming of send_texts/emails/letters to send_messages, and
manage_settings/users to manage_service
2018-03-06 13:08:06 +00:00
Leo Hemsted
17061e0d06 map roles and db permissions
in the db, we have several rows for single permissions - we separate
`send_messages` into `send_texts`, `send_emails` and `send_letters`,
and also `manage_service` into `manage_users` and `manage_settings`.

But on the front end we don't do anything with this distinction. It's
unhelpful for us to have to think about permissions as groups of things
when we can never split them up at all. So we should combine them. This
commit makes sure:
* when user models are read  (from JSON direct from the API), we
  should transform them from db permissions into roles.
* when permissions are persisted (editing permissions, and creating
  invites), we should send db permissions to the API.

All other interaction with permissions (should just be the endpoint
decorator and checks in html templates generally) should use admin
roles.
2018-03-06 13:08:06 +00:00
Leo Hemsted
bd54dbb40c remove unnecessary invocations of has_permissions(..., any_=True)
when added to a service, all users are given the view_activity
permission. So, if that's included in the list, we don't need `any_`,
and we don't need any of the other permissions.
2018-03-06 13:08:06 +00:00
Leo Hemsted
7ddad7c99e dont use has_permissions to check for platform admins
platform_admin is a separate concept to permissions, so by removing the
checks for it from the current_user.has_permissions function, we can
simplify things greatly. We already record on the user whether they're
a platform admin anyway.
2018-03-06 13:08:06 +00:00
Chris Hill-Scott
4b69e1003e Merge pull request #1923 from alphagov/remove-dvla
Remove anything to do with DVLA format letters
2018-03-06 13:00:35 +00:00
Chris Hill-Scott
5a68fb640f Show CSV download link for letter jobs 2018-03-06 10:24:01 +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
Rebecca Law
5c26d7a061 Merge pull request #1922 from alphagov/update-free-allowance-for-org-type
Update the free allowance when the organisation type is changed
2018-03-02 15:37:13 +00:00
Rebecca Law
dcb3b84468 Fix syntax error 2018-03-02 15:16:33 +00:00
Rebecca Law
f7e1ca29fe Added an assert for the mocker 2018-03-02 15:09:07 +00:00
Chris Hill-Scott
1391f12239 Remove anything to do with DVLA format letters 2018-03-02 14:30:45 +00:00
Chris Hill-Scott
1cfcb42606 Merge pull request #1921 from alphagov/duplicate-cols-error
Catch duplicate recipient columns in spreadsheets
2018-03-02 14:25:34 +00:00
Chris Hill-Scott
a4424e999f Catch duplicate recipient columns in spreadsheets
If someone has duplicate recipient columns in their file we don’t know
which one to use. This commit adds an error message which should help
them fix the duplication.

This commit doesn’t go to the extra effort to actually show the
correct values for duplication in the preview. Don’t think it’s worth
the effort/complexity for how infrequently we’ve seen this error.

Depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/376
2018-03-02 13:18:04 +00:00
Alexey Bezhan
982ea8a7fa Merge pull request #1851 from alphagov/direct-api-requests-to-paas
Add route secret key header to the API requests
2018-03-02 13:17:57 +00:00
Chris Hill-Scott
ea94d466b6 Merge pull request #1911 from alphagov/fix-date-exception
Catch exceptions caused by ambiguous Excel files
2018-03-02 12:46:26 +00:00
Chris Hill-Scott
69aa4d0025 Merge pull request #1877 from alphagov/job-csv-upgrade
Add original file data to job downloads
2018-03-02 12:46:20 +00:00
Rebecca Law
fa0196bc88 Update the free allowance when the organisation type is changed.
The free allowance affect the number of free text messages a services get per yer.
This allowance is being set properly when an organisation is created by not updated.
This PR updates the free allowance when the organisation type is updated.
The free allowance can also be changed if service has an exceptional free allowance.
2018-03-02 10:48:59 +00:00
Ken Tsang
ba6a0e6466 Fix sorting of imports 2018-03-01 23:50:55 +00:00
Ken Tsang
ff457b8407 Refactor to handle API errors for preview 2018-03-01 23:50:55 +00:00
Ken Tsang
b34b0e2870 WIP refactor letter preview function 2018-03-01 15:24:26 +00:00
Ken Tsang
42622d86e1 Remove redundant code from notifications.html 2018-03-01 15:24:26 +00:00
Ken Tsang
c6285ed68b Improve preview_error.png image 2018-03-01 15:24:26 +00:00
Richard Chapman
1f69d882c2 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-01 15:24:26 +00:00
Ken Tsang
64e706ec76 Refactor imports 2018-03-01 15:24:26 +00:00
Richard Chapman
c52657146a Removed unneeded parameters after update to api.
Updated the tests to take the removal into account.

Tidied up unused imports
2018-03-01 15:23:16 +00:00
Ken Tsang
6279169b18 WIP refactor preview pdf 2018-03-01 15:21:50 +00:00
Richard Chapman
2b10060e49 Fixed code style changes which were making the tests fail. 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
Katie Smith
68fc6b5cb4 Merge pull request #1914 from alphagov/reject-sms-senders-starting-with-00
Update SMS sender validation to reject senders starting with 00
2018-03-01 13:56:23 +00:00
Katie Smith
d1c724d02c Merge pull request #1916 from alphagov/pyup-update-pytest-mock-1.7.0-to-1.7.1
Update pytest-mock to 1.7.1
2018-03-01 13:56:06 +00:00
Chris Hill-Scott
91a7858c45 Merge pull request #1910 from alphagov/env-sh-fix
hardcode some development values
2018-03-01 11:21:00 +00:00
pyup-bot
435f169c2a Update pytest-mock from 1.7.0 to 1.7.1 2018-03-01 11:17:59 +00:00
Chris Hill-Scott
75976f3b59 Merge pull request #1915 from alphagov/no-priority-example
Stop creating tour text messages as priority
2018-03-01 09:56:08 +00:00
Chris Hill-Scott
6d29587d3a Merge pull request #1913 from thomchambers/patch-3
Update Features page with new content
2018-03-01 09:56:02 +00:00
Chris Hill-Scott
70e37a1af5 Merge pull request #1912 from thomchambers/patch-2
Update Security page content
2018-03-01 09:55:55 +00:00
Chris Hill-Scott
76da1ab28d Stop creating tour text messages as priority
Since we send all one off messages as priority now[1], we don’t need to
explicitly mark this template as being priority.

This stops the (potential) problem of people skipping the tour, still
having this template and then modifying it to send other messages,
potentially in high volumes from CSV files or the API. I don’t think
this is a real problem now, but worth cleaning this up.

Currently:
- 827 priority templates in the database
- 195 of which are not deleted
- 18 of which are not called ‘Example text message template’
- 3 of which look like genuine use cases, not from services that we run

[1]: https://github.com/alphagov/notifications-api/pull/1722
2018-02-28 17:00:36 +00:00
thomchambers
aadc73645e Update Features page with new content
Edited some things in here based on user support tickets and new features we've added recently.
2018-02-28 16:11:04 +00:00
Chris Hill-Scott
e899e2e826 Make it clearer what you sign in using with
Avoid confusion between and email you’re sent and an email address that is your username.
2018-02-28 16:05:16 +00:00
thomchambers
e1b77e3b13 Update Security page content
Adding some new content based on feedback from user research.
2018-02-28 15:33:47 +00:00