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.
This commit is contained in:
Leo Hemsted
2018-02-28 15:37:49 +00:00
parent bd54dbb40c
commit 17061e0d06
7 changed files with 117 additions and 22 deletions

View File

@@ -47,6 +47,7 @@ def user_json(
mobile_number='+447700900986',
password_changed_at=None,
permissions={generate_uuid(): [
'view_activity',
'send_texts',
'send_emails',
'send_letters',