Commit Graph

64 Commits

Author SHA1 Message Date
Katie Smith
31a1c1ca51 Pass service domain to api when adding a new service
We need to pass the domain to api when adding a service so that api can
link the domain of the service with a letter brand.
2019-02-12 14:59:29 +00:00
Katie Smith
bbc7b173f0 Ensure non-gov invited users get added to services
We were adding invited users to services in the `main.add_service` view
function as the last step in the process of inviting users. Since this
view function is decorated with `@user_is_gov_user`, invited users with
non-governmental email addresses would never reach this point and would
be able to register an account but would not get linked to a service.

To fix this, we now add the invited user to the service at the point at
which the user gets activated and also ensure that non-gov users don't
get redirected to a page which they don't have permission to view.
2019-01-22 09:52:55 +00:00
Chris Hill-Scott
a8b916b57f Refactor gov user check into a decorator
We quite often use it in the same way as `@user_has_permissions`.
2018-12-12 13:42:26 +00:00
Chris Hill-Scott
126db71de6 Refactor government user check onto model 2018-12-12 12:29:08 +00:00
Chris Hill-Scott
e04b2b5631 Split models to prevent circular imports
This commit is the first step to disentangling the models from the API
clients. With the models in the same folder as the API clients it makes
it hard to import the API clients within the model without getting a
circular import.

After this commit the user API clients still has this problem, but at
least the service API client doesn’t.
2018-10-30 15:01:36 +00:00
Chris Hill-Scott
01fdcb8998 Use NHS.UK branding is for all NHS services
Anyone choosing ‘NHS’ for their organisation type gets should get the
NHS branding. We don’t want to hard-code an ID for NHS branding anywhere
because it won’t be consistent between environments.

So instead we can say that anyone who chooses ‘NHS’ as their
organisation type should get whatever branding has `nhs.uk` as its
domain.

This allows us to easily manage the branding the same way we do other
brands, but gives us the efficiency of having it auto applied.
2018-09-05 10:32:44 +01:00
Chris Hill-Scott
243fdb0260 Assign email branding based on user’s email domain
When a user creates a service we can take a pretty good guess at what
organisation they’re from.

For many organisations, especially local councils, GOV.UK branding is
not appropriate for their service. But right now every service:
- gets created with GOV.UK branding
- has to ask us to change it, even if they’ve already done so for other
  services they run

This commit starts using the `domain` field on the email branding table
to lookup what email branding to assign to a service automatically,
where we’re sure there’s a sensible default.
2018-09-05 10:32:44 +01:00
Chris Hill-Scott
b28e8691a6 Revert "Remove keyword args from call to create service"
This reverts commit bde696cf56.

The caching decorator supports keyword arguments now.
2018-04-19 14:01:45 +01:00
Chris Hill-Scott
bde696cf56 Remove keyword args from call to create service
The cache decorator doesn’t work with functions that use keyword
arguments (at the moment).
2018-04-19 13:54:14 +01: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
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
Leo Hemsted
eb3d4acb45 update free sms fragment limit to go via billing client instead of service 2017-12-04 16:03:11 +00:00
venusbb
a9f06c23f7 Commit out using the new end points until data is migrated 2017-11-14 16:23:08 +00:00
venusbb
1ab4681ff5 Use the revise api endpoints without current-year parameter 2017-11-09 13:18:09 +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
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
9b9c6d75dc - Change update service name to check that the name/email_from is unique across all services.
- This is done using a new endpoint in the api.
- Removed the AddServiceForm in favor or using the ServiceNameForm
- Removed ServiceApiClient.find_all_service_email_from
2017-08-09 16:52:10 +01:00
Rebecca Law
98595d8d80 Added an else: raise 2017-08-08 15:04:45 +01:00
Rebecca Law
7e8c76bbc5 Let the API error when the service name is a duplicate.
- Remove the name_func from the AddServiceForm
- Catch the HTTPError and set the error on the form
2017-08-08 11:15:22 +01:00
Rebecca Law
186202cc9d [WIP]
Let the API return a 400 error message if the service name is a duplicate.
2017-08-07 11:30:25 +01:00
Chris Hill-Scott
480a57bba4 Change step 1 of tour to only show the template
We’ve made a few changes to the tour recently, without changing the
help text on the left hand side of the screen. So the stuff you see on
the right side of the screen doesn’t quite sync up any more.

This commit adds an extra, introductory page that just shows the
template and a next button, which better matches the ‘every message
starts with a template’ help text.
2017-06-29 12:16:47 +01:00
Chris Hill-Scott
72fa3713e8 Make example text message template priority
The tour teaches you how Notify works by letting you do a thing and then
showing you the effect of the thing you’ve just done – a text message on
your phone.

This is not as effective if you don’t get the text message quickly. It
breaks the association you make between what you’ve done on the computer
and what’s happening on your phone.

Slow text message delivery can happen if you’re doing a big job. We can
get around this by making your text message use the priority queue.

This was observed in the pilot research session yesterday.
2017-03-09 10:30:19 +00:00
Leo Hemsted
08881e5bd1 add get_active_services method
* all current invocations of get_services now call get_active_services
  EXCEPT for platform admin page (where we want to see inactive services
* cleaned up parameter names and unpacking (since *params is unhelpful)
* fixed incorrect kwarg name in conftest
2016-11-16 11:08:20 +00:00
Leo Hemsted
b885ce9cf4 clean up some usage of active in tests and remove it from service_api_client.create_service (created services are always active) 2016-11-16 11:08:20 +00:00
Imdad Ahad
2676ee9bcf Add additional tests and refactor 2016-10-28 10:47:32 +01:00
Imdad Ahad
84762edef4 Abort 403 if nonwhitelist user tries to add service 2016-10-25 18:11:37 +01:00
Chris Hill-Scott
a5a35f1a6b Don’t create an example email template
We reckon that:

- a ‘blank slate’ templates page is a better start
- the example template hurt more than it helped when it comes to
  understanding placeholders
2016-07-01 13:26:57 +01:00
Chris Hill-Scott
c41944080c Make the tour interactive
_The code for this is quite hacky and light on tests. But I’d really like to get
it in the app for the research tomorrow to see how well the feature works._

This commit changes the tour from being a set of static screens to some help
which guides you through the process of sending your first test message.

The theory behind this is that what users are really struggling with is the
concept of a variable, rather than the relationship between the placeholders and
the column headers. And like learning to program, the best way to learn is by
taking an example and modifying it to your own needs.

This means that when someone adds their first service we set them up an
example email template and an example text message template. Then there is a
guided, three step process where _all_ the user can do is send a test message to
themselves.

Once the message is sent, the user still has the example templates which they
can edit, rather than having to remember what they’re supposed to be doing.
2016-05-25 13:14:09 +01:00
Andrew White
7812b1cef5 Redirect to dashboard if this isn't the first service
There's no need to show the tour again if the user has previously
created a service so just redirect to the dashboard instead.
2016-04-28 16:44:12 +01:00
Chris Hill-Scott
b75ab7c3df Make new service current service on first use
When you add a new service, it’s probably the one you want to do stuff
with.

When you get invited, the service you’ve been invited to is probably the
one you want to use.

This commit adds the ID of the new service or service you’ve been
invited to to the session.
2016-04-19 11:04:00 +01:00
Chris Hill-Scott
37f341e757 Make tour work for non-logged-in users
There’s no content in the tour that’s specific to a service. And since
we can now take a pretty good guess at what service you last used, or
which service we should send you to if you only have one service,
there’s no need to make the URLs for the tour service-specific.

This also means that you don’t need to be logged in to see the tour
pages, and we have no good reason to only restrict these pages to users
with accounts.

https://www.pivotaltracker.com/story/show/116960703
2016-04-19 10:38:16 +01:00
Nicholas Staples
a6d1c5b693 Download CSV option now available.
App is updated to use the rebased db.
2016-04-12 15:38:02 +01:00
Nicholas Staples
c31c55666b Added current_service to flask context and template context.
Fix all tests and conflicts.

Removed comment line.
2016-04-04 17:01:20 +01:00
Chris Hill-Scott
5d873bdc45 Show a tour when users first create a service
This commit adds a 3 screen tour, similar to those used on GOV.UK Verify
and Passports.

We guerilla tested this on Friday, and it really helped users to build a
mental model of how Notify works, so that when they’re playing around
with it they have a greater sense of what they’re aiming to do. This
makes concepts like templates and placeholders click more quickly.

https://www.pivotaltracker.com/story/show/116710119
2016-04-04 09:25:34 +01:00
Rebecca Law
9a2cb60f5e Update the service name validation in the ServiceNameForm and AddServiceForm to check the email_safe version
of the name against a list of all service email_from fields.
Update find_all_service_names to find_all_service_email_from, which returns the email_from of all services.
2016-03-31 15:17:05 +01:00
Rebecca Law
1871243cc8 Check the uniqueness of the service name ignoring case.
When the service name changes the email_from changes to.
Renamed find_all_service_names to find_all_service_names_lower.
2016-03-31 10:26:03 +01:00
Nicholas Staples
644336b151 Merge with master. 2016-03-29 22:50:40 +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
Adam Shimali
2792bece54 Changed registration flow to first send email verification link that
when visited sends sms code for second step of account verification.

At that second step user enters just sms code sent to users mobile
number.

Also moved dao calls that simply proxied calls to client to calling
client directly.

There is still a place where a user will be a sent a code for
verification to their email namely if they update email address.
2016-03-17 15:19:51 +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
Rebecca Law
6e3bf97af4 Remove services_dao.insert_new_service.
Update api_client.create_service to return the service id.
Fix unit tests.
2016-03-13 09:37:17 +00:00
Adam Shimali
9bc5d08d52 Flash message to confirm invitation accepted and user has been
added to service.
2016-03-08 08:18:41 +00:00
Adam Shimali
a974e6e157 [WIP] Add call to api to update invitation to accepted.
When flow for invited user is complete, that is
when user has been added to service, update invitation
to accepted
2016-03-03 18:13:56 +00:00
Adam Shimali
1ff9d671eb [WIP] pass invite instead of permissions to make update of invite easier if all goes well 2016-03-03 16:37:22 +00:00
Adam Shimali
6ba13a6513 [WIP] New user can now accept invite and will be made to
register. On succesful register and verfication they
will be added to service and forwarded to dashboard.

Nothing is done yet with the permissions requested in the
invite to the user.
2016-03-02 17:52:32 +00:00
Chris Hill-Scott
ce221fc40b Drop ‘preview service name’ page
This page:
- confused users in research
- didn’t communicate what it was intended to (eg the generated email address,
  how your service name would appear in messages)

This commit removes the page so that after typing in the service name the user
is sent straight to the dashboard for their new service.
2016-02-26 13:12:25 +00:00
Chris Hill-Scott
73deae9bff Preview service name when adding a new service
This commit adds a new page, which appears after a user enters the name for
their new service. It shows how the service name will appear in emails and
text messages.

This means that the new service is not created until after they have confirmed
that the name is appropriate in context.

This has also involved:
- visual changes to the ‘email template’ pattern, which wasn’t very refined
  before
- removing a bunch of words from the enter service name page, because most users
  don’t read them, and we reckon that showing a preview is a better way of
  getting them to understand what is meant by service name

Still to do:
- validating the the generated email address for a service is unique (on the
  API) side
- having the API return the generated email address, rather than determining it
  in the admin app
2016-02-19 16:38:46 +00:00
Chris Hill-Scott
26adcc64c1 Updates to ‘send SMS’ page
Based on discussion with Pete.

Make the blue banner an ‘important’ banner (copied from Register to Vote, used
because it’s not as boxy and fits on the page better).

Remove the back button because you haven’t changed any data yet. If you need to
go back you can just press back or start again.

Make the filename stand out more.

Remove the ‘download example’ link. Will need to revist the best way of doing
this.

Make text messages consistently 2/3rd width.
2016-02-04 14:06:19 +00:00
Chris Hill-Scott
3617f2e936 Move service and user nav to proposition header
This commit moves user-related navigation into the proposition header (the black
bar) at the top of the site. It adds some custom SASS to override GOV.UK
template and align these navigation items to the right (because it looks
better).

It then removes the service chooser dropdown (and its associated SASS and JS) in
favour of a link alongside the user-related navigation items. ‘Switch service’
is the best language for this that we’ve come up with so far.

This means that the only way of adding a new service is from the `/services`
page. So this commit removes the redirect if you land on this page with only one
service (else it would prevent you from ever being able to add more).
2016-02-01 13:52:45 +00:00