Commit Graph

360 Commits

Author SHA1 Message Date
Leo Hemsted
793d79c242 ensure invited user permissions show up correctly 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
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
Chris Hill-Scott
f3a0c505bd Enforce order and style of imports
Done using isort[1], with the following command:
```
isort -rc ./app ./tests
```

Adds linting to the `run_tests.sh` script to stop badly-sorted imports
getting re-introduced.

Chosen style is ‘Vertical Hanging Indent’ with trailing commas, because
I think it gives the cleanest diffs, eg:
```
from third_party import (
    lib1,
    lib2,
    lib3,
    lib4,
)
```

1. https://pypi.python.org/pypi/isort
2018-02-27 16:35:13 +00:00
Rebecca Law
d638b446f5 Merge branch 'master' into becca-invite-users 2018-02-27 10:13:40 +00:00
Chris Hill-Scott
103a36a5da Hide ‘request to go live’ from API only users
Users who have the ‘manage API keys’ permission can see the settings
page. But they don’t have permission to request to go live.

At the moment they can still see the link, though clicking it gives them
a 403 error. This commit changes it so that they can’t see the link, and
tells them who they should speak to about going live (their manager).
2018-02-26 08:53:45 +00:00
Rebecca Law
8f5b6491f3 Fix failing tests 2018-02-23 17:09:41 +00:00
chrisw
22bbc0d6d8 invite-team-members 2018-02-23 11:43:13 +00:00
chrisw
dd2231056d organisation dashboard page 2018-02-19 16:56:16 +00:00
chrisw
1450138b9c link-services-to-organisations 2018-02-13 12:49:57 +00:00
chrisw
9ad4435d94 Change organisations to email branding 2018-02-07 17:41:23 +00:00
Chris Hill-Scott
d9a63c07a9 Refactor user permissions to use args, not list
This makes the interface a bit cleaner and less verbose.
2018-01-16 11:22:57 +00:00
Chris Hill-Scott
67b54d850f Add link back to API integration from callbacks
Matches what we do on the API keys and whitelist pages.
2018-01-15 10:10:12 +00:00
chrisw
7271d4fbde Allow letter templates to select the default contact block from the list 2018-01-10 11:20:40 +00:00
Rebecca Law
b7db7debc5 Add letters to usage page.
Before this goes live need to only show letters on usage if the service has the permission.
2017-12-19 14:35:10 +00:00
chrisw
43c14fb756 Allow service to set callback url for notifications 2017-12-08 10:52:50 +00:00
Leo Hemsted
eb3d4acb45 update free sms fragment limit to go via billing client instead of service 2017-12-04 16:03:11 +00:00
Richard Chapman
155e432aa6 Disabled the template_history endpoint
- Updated tests and added a new mock_get_monthly_template_usage
- Deleted get_monthly_template_statistics_for_service
- Added new test to test the redirection of the old endpoint
2017-11-24 15:20:40 +00:00
Athanasios Voutsadakis
1c78b938b4 Fix tests 2017-11-16 16:33:50 +00:00
Athanasios Voutsadakis
fce8129f3e Merge branch 'master' into add_proxy_header_check 2017-11-16 11:09:32 +00:00
Leo Hemsted
b8c8372f77 Merge pull request #1617 from alphagov/remove-flask-script
remove flask-script
2017-11-15 17:47:30 +00:00
Athanasios Voutsadakis
9bfda11bcf Merge branch 'master' into add_proxy_header_check 2017-11-15 17:18:00 +00:00
Athanasios Voutsadakis
7d4fdba237 Fix PEP8 2017-11-15 16:56:39 +00:00
Venus Bailey
f039e64a6d Merge pull request #1594 from alphagov/vb-free-sms-history
Use annual_billing tables at backend for getting and updating free_sm…
2017-11-15 14:57:46 +00:00
Athanasios Voutsadakis
061b057f24 Merge branch 'master' into add_proxy_header_check 2017-11-14 18:02:53 +00:00
Leo Hemsted
65ba7e88c8 refactor RegisterFromInvite to make auth_type required, and update test fixtures 2017-11-14 15:18:14 +00:00
Athanasios Voutsadakis
5574200607 Copy set_config_values from api 2017-11-14 14:51:17 +00:00
venusbb
581759931f Merge branch 'master' of https://github.com/alphagov/notifications-admin into vb-free-sms-history 2017-11-14 09:40:05 +00:00
chrisw
1effec78e5 alter login flow to allow for email auth login 2017-11-09 16:07:28 +00:00
Leo Hemsted
cbf1b3ec38 replace user PUT with POSTs
the update_user fn was used in two places, for things that are handled
fine by update_user_attribute. Reduce complexity in the API by killing
the PUT, which is more dangerous (might silently overwrite things that
shouldn't be, like "last_logged_in_at" etc).

Had to change the code not received mobile number form, and the
activate user function.
2017-11-09 14:58:33 +00:00
Leo Hemsted
bfa6980913 Revert "replace user PUT with POSTs" 2017-11-09 14:57:01 +00:00
venusbb
1ab4681ff5 Use the revise api endpoints without current-year parameter 2017-11-09 13:18:09 +00:00
Leo Hemsted
302a024d3b replace user PUT with POSTs
the update_user fn was used in two places, for things that are handled
fine by update_user_attribute. Reduce complexity in the API by killing
the PUT, which is more dangerous (might silently overwrite things that
shouldn't be, like "last_logged_in_at" etc).

Had to change the code not received mobile number form, and the
activate user function.
2017-11-09 12:30:12 +00:00
venusbb
66b49821a7 Merge branch 'master' of https://github.com/alphagov/notifications-admin into vb-free-sms-history 2017-11-09 09:24:49 +00:00
Chris Hill-Scott
6325f26081 Revert "Stop escaping special characters in inbound messages" 2017-11-07 17:22:57 +00:00
Leo Hemsted
4aeb57567a remove flask-script
flask-script has been deprecated by the internal flask.cli module, but
making this carries a few changes with it

* you should add FLASK_APP=application.py and FLASK_DEBUG=1 to your
  environment.sh.
* instead of using `python app.py runserver`, now you must run
  `flask run -p 6012`. The -p command is important - the port must be
  set before the config is loaded, so that it can live reload nicely.
  (https://github.com/pallets/flask/issues/2113#issuecomment-268014481)
* find available commands by just running `flask`.
* run them using flask. eg `flask list_routes`
* define new tasks by giving them the decorator
  `@app.cli.command('task-name')`. Task name isn't needed if it's just
  the same as the function name. Alternatively, if app isn't available
  in the current scope, you can invoke the decorator directly, as seen
  in app/commands.py
2017-11-06 17:33:04 +00:00
Chris Hill-Scott
f6950ae987 Stop escaping special characters in inbound
At least one of our providers gives us messages with special characters
escaped, ie a newline comes through as `\n`, not a literal newline. We
shouldn’t be showing these backslashes to any of our users.

Python has built in codecs for dealing with encoding/decoding of
strings – see
https://docs.python.org/3/library/codecs.html#text-encodings
for details. Using these builtins is safer than trying to do anything
regex or parsing-based.
2017-11-06 13:24:16 +00:00
Chris Waszczuk
98c8ddca38 Merge pull request #1598 from gov-cjwaszczuk/master
Email auth for inviting members and editing permissions
2017-11-06 10:00:15 +00:00
Rebecca Law
ff22c83b1d Added a hint to show default and receives text messages 2017-11-02 15:48:19 +00:00
chrisw
c6ea90a7d8 Email auth for inviting members and editing permissions 2017-11-02 12:38:01 +00:00
venusbb
8e6c284d7b add logic to change future free_sms_fragment_limit items when service setting changed 2017-10-31 11:56:51 +00:00
venusbb
8ea38ba7b6 Use annual_billing tables at backend for getting and updating free_sms_fragment_limit 2017-10-31 11:22:57 +00:00
chrisw
4e721c95ce Added Multiple SMS sender functionality 2017-10-30 13:40:34 +00:00
Chris Hill-Scott
056c88be2a Merge pull request #1534 from alphagov/collect-service-type
Collect organisation type when user creates a service and use it to calculate text message allowance
2017-10-24 12:24:07 +01:00
Chris Hill-Scott
c516760056 Set free SMS limit depending on organisation type
Different parts of government get billed slightly differently, and
there’s differences in how much money we’re allowed to give them.

Think these numbers are right, but should be double checked.
2017-10-23 17:45:26 +01:00
Chris Hill-Scott
9453f301d2 Collect organisation type
So that we can default services to their appropriate text allowance, we
need to find out what sector they're in. So let's start collecting that
from teams as they create new services.

I think Central/Local/NHS are the right options, but these can be easily
changed if not.
2017-10-23 17:45:01 +01:00
Rebecca Law
7f8e935b44 Improve the performance of /platform-admin
Using a new endpoint in API to get the aggregate platform admin stats.

Relies on https://github.com/alphagov/notifications-api/pull/1332
2017-10-23 15:08:08 +01:00
chrisw
e149d0eb91 Allow one-off email sending to select the reply-to address 2017-10-17 11:15:26 +01:00