Commit Graph

515 Commits

Author SHA1 Message Date
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
Rebecca Law
41309721bd - Remove organisation setter for the user model.
- Revert the change to the log level for admin.
2018-02-26 22:18:46 +00:00
Rebecca Law
298eb77b54 Refactor the check token endpoint to use the newly merged api endpoints. 2018-02-26 11:50:40 +00:00
Chris Hill-Scott
96aac519cc Extend user client to count users with permission
One of the things we need to know for a service to go live is whether
they have at least two users with the ‘manage service’ permission.

So this commit adds a method to the client to count how many users have
a given permission. We can do logic on this count later. But having the
counting done in the client feels like a cleaner separation of concerns.

Meant some refactoring of the way `service_id` is extracted from the
request, in order to make it easier to mock.
2018-02-26 08:53:45 +00:00
Chris Hill-Scott
51f0320aec Add API client method to count templates
When users request to go live we check stuff like:
- if they’ve added templates
- if they have email templates (then we can check their reply to
  address)

This commit adds a method to do this programatically rather than
manually.

We _could_ do this in SQL, but for page that’s used intermittently it
doesn’t feel worth the work/optimisation (and the client method is at
least in place now if we do ever need to lean on this code more
heavily).
2018-02-26 08:53:45 +00:00
chrisw
22bbc0d6d8 invite-team-members 2018-02-23 11:43:13 +00:00
chrisw
96b66829a1 organisation-dashboard 2018-02-19 16:56:16 +00:00
Chris Waszczuk
34f1b40dbc Merge pull request #1858 from gov-cjwaszczuk/link-service-to-organisation
Link services to organisations (Admin)
2018-02-14 12:30:15 +00:00
Katie Smith
84d810b981 Pass service_id through to API '/service/unique' endpoint
Notifications-api now needs the service_id to check the uniqueness of
the service name when trying to change it. This is to allow a user to
successfully change the pluralization or the case of their service name.
2018-02-13 15:57:19 +00:00
chrisw
1450138b9c link-services-to-organisations 2018-02-13 12:49:57 +00:00
Ken Tsang
b11bfd49e3 Add Organisations API Client 2018-02-12 12:27:06 +00:00
Chris Hill-Scott
1908e7b091 Tell API what URL to use for email auth links
So that we can keep people on the prototype URL when doing user
research.

Depends on:
- [ ] https://github.com/alphagov/notifications-api/pull/1645
2018-02-09 15:01:20 +00:00
chrisw
9ad4435d94 Change organisations to email branding 2018-02-07 17:41:23 +00:00
Chris Hill-Scott
2221a8ca48 Change display of cancelled users, fix edit link
It’s confusing showing green ticks for cancelled invites. This commit
changes the appearance so that only pending or active users (ie those
that could actually do some damage) get green ticks.

Also fixes missing edit links caused by instances of `User` having
`.state` but instances of `InvitedUser` having `.status`.

Right now these are two separate lists. Which makes it harder to add
improvements that will make large numbers of users easier to manage.
2018-01-29 15:23:54 +00:00
Chris Hill-Scott
e573f492db Check for unknown permissions
This guards against anyone mispelling or using the wrong words for a
permission, which could introduce unexpected or hard to catch errors.
2018-01-16 11:24:37 +00:00
Chris Hill-Scott
f2418c171c Move roles to models file
Any time we can keep code out of the view files is good. This user stuff
seems like a sensible place to put it, since we’re going to use it
there.
2018-01-16 11:23:48 +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
chrisw
7271d4fbde Allow letter templates to select the default contact block from the list 2018-01-10 11:20:40 +00:00
Chris Hill-Scott
86d76baa0d Have admin specify host to use for invite links
When we’re doing user research we often:
- start the task by inviting the participant to a service on Notify
- have them use a prototype version of the admin app, hosted on a
  different domain

Currently we can’t do both of these things together, because the invite
emails always send people to notifications.service.gov.uk (because it’s
the API that sends the emails, and the prototype admin app points at the
production API).

This commit changes the admin app to tell the API which host to use when
creating the invite links.

Depends on:
- [ ] https://github.com/alphagov/notifications-api/pull/1515
2018-01-03 10:37:29 +00:00
Leo Hemsted
99db15d975 fix notifications-python-client version import 2017-12-28 10:05:54 +00:00
chrisw
43c14fb756 Allow service to set callback url for notifications 2017-12-08 10:52:50 +00:00
Leo Hemsted
2a28278cb8 make sure service api client doesnt expect free sms fragment 2017-12-04 16:57:00 +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
Richard Chapman
d03df16db5 Added new template usage page which will replace template-activity
The current template-activity page is slow as it is using the end point
which uses notification_history  and hence is timing out. This adds a
new pages (so that they can be compared side by side) which will be
hidden until is is approved with the larger data set and tested.
2017-11-16 16:55:07 +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
Leo Hemsted
65ba7e88c8 refactor RegisterFromInvite to make auth_type required, and update test fixtures 2017-11-14 15:18:14 +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
Rebecca Law
ef5f5ca43a Merge pull request #1628 from alphagov/remove-unused-code-for-sms-sender
Remove unused routes
2017-11-09 15:59:09 +00:00
Leo Hemsted
fcefd2a80c pass in data to posts 2017-11-09 15:02:59 +00:00
Leo Hemsted
2f37b00989 use active-endpoint 2017-11-09 14:58:44 +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
Leo Hemsted
b9eca67b0d Revert "use new activate endpoint" 2017-11-09 14:55:08 +00:00
Leo Hemsted
7b0fcf8c08 use active-endpoint 2017-11-09 14:37:33 +00:00
Rebecca Law
8c9d90c0f8 Remove unused routes 2017-11-09 13:48:27 +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
9e600b6051 POST to the correct endpoint when updating
`prefix_sms_with_service_name` is a computed attribute on the service
model. It’s where we get the value from, and the API does some work to
get it from the database, or derive it from the default SMS sender.
It can’t be updated, because it’s not itself a database column.

`prefix_sms` is the name of the actual database column. This is the
thing that we need to update.

This will go away eventually.
2017-11-06 15:08:34 +00:00
Chris Hill-Scott
6d3855bba4 Allow updates to SMS prefixing setting
We’re extracting this from being determined based on what the sender
name is to its own setting.

This commit will let users set it independently.

Until the explicitly set it, it will still be determined based on
whether their default sender name matches the default for the platform.
2017-11-06 11:24:46 +00:00
chrisw
c6ea90a7d8 Email auth for inviting members and editing permissions 2017-11-02 12:38:01 +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
Leo Hemsted
273b864dce add auth_type default to InvitedUser object
we unpack the api invited user rest endpoint results straight into the
InvitedUser object, so we should make sure that any fields added to
the api response are mentioned here
2017-10-30 17:38:50 +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
d9104ba59f Add page to change SMS allowance
There may be exceptions to the rule, so we should have a way of
overriding this manually.
2017-10-23 17:45:44 +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