Commit Graph

591 Commits

Author SHA1 Message Date
Chris Hill-Scott
8d9038c3e9 Give GP practices NHS branding by default
Previously we were doing it based on their email address. This will also
apply it if they self-select as a GP surgery, even if they don’t have an
NHS email address.
2019-08-28 15:33:00 +01:00
Chris Hill-Scott
edb5790b7c Use nhs_gp not gp as org type
Means we have the option of looking for anything starting with `nhs` as
a way of filtering organisations.
2019-08-28 15:24:30 +01:00
Chris Hill-Scott
a5b36457f2 Add ‘GP’ as an org type
Although their allowances are the same as what we call `nhs_local` it
makes more sense to store them separately because:
- we already present them as two separate choices to the user
- we may want to handle them differently in the future, eg in terms of
  what branding choices are available to them
2019-08-27 17:01:03 +01:00
Pea (Malgorzata Tyczynska)
009406898f Merge pull request #2596 from alphagov/lighter-serialize-for-users
Leaner serialize for user model for displaying list of users
2019-08-20 11:40:07 +01:00
Pea Tyczynska
b2f811662d Leaner serialize for user model for displaying list of users 2019-08-19 13:31:29 +01:00
Rebecca Law
b37de7785c Remove the organisation_to_service table.
This table is no longer used or referenced in the code.
We can remove this mapping table now that the organisation to service relationship is handled by the foreign key in Services.
2019-08-15 15:17:53 +01:00
Rebecca Law
fdee6cbfb2 As per PR comments:
- Remove Organisation.services
- added backref='services' to Services.organisation relationship and removed redundant foreign_keys argument.
2019-08-14 13:23:20 +01:00
Rebecca Law
55dc7184cc Add organisation_id to Service.
This is the second commit in the series to add organisation_id to Service.
- Data migration to update services.organisation_id from data in organisation_to_service
 (The rollback will lose any updates to organisation unless the script is updated to set organistion_to_service from service.organisation_id )
- Update Service.organisation relationship to a ForeignKey relationship to Organisation.
- Update Organisation.services to a backref relationship to Service.
2019-08-13 17:25:30 +01:00
Rebecca Law
12f305bf86 - Migration to add Service.organisation_id
- Add oranisation_id to Service data model.
- Update methods to create service and associate service to organisation to set the organisation_id on the Service.
- Create the missing test, if the service user email matches a domain for an organisation then associate the service to the organisation and inherit crown and organisation_type from the organisation.
2019-08-12 16:03:02 +01:00
Katie Smith
6ea849298e Merge pull request #2580 from alphagov/set-bad-email-addresses-to-perm-fail
Set bad email addresses to permanent-failure
2019-08-12 16:03:01 +01:00
Katie Smith
f8035811a7 Add new 'upload_letters' permission 2019-08-05 12:02:43 +01:00
Pea Tyczynska
38bb2c1cf6 Simpify org types migration script and introduce foreign key
Don't transform org types on prod
2019-07-24 17:55:56 +01:00
Pea Tyczynska
5b256fa64e Migrate all orgs and services onto new organisation types
Remove all mentions of generic 'nhs' organisation type.
2019-07-22 14:58:41 +01:00
Pea Tyczynska
edda816ffa Temporarily add generic 'nhs' 2019-07-19 15:13:24 +01:00
Pea Tyczynska
610bf5d149 For now include nhs type orgs in allowed organisation types 2019-07-18 17:05:24 +01:00
Pea Tyczynska
d89ef0594f nhs_central is crown org and also we do not update org type while
updating service anymore.
2019-07-18 17:05:24 +01:00
Pea Tyczynska
e4cb56b5d3 Emergency service instead of emergency services 2019-07-18 17:05:23 +01:00
Pea Tyczynska
9dfc550f46 Add org types table 2019-07-18 17:05:22 +01:00
Leo Hemsted
07bb0f0332 send emails when MOU is signed
we build up one personalisation dict, and then pass it in to all the
different templates - so be careful editing things. also of note, we
check if the agreement_signed_on_behalf_of is set, and send a different
template with slightly different wording to the person who clicked the
confirm button.
2019-07-12 15:08:55 +01:00
Chris Hill-Scott
3e11d2492a Merge pull request #2552 from alphagov/create-update-org-extra-fields
Add extra fields to create/update organisation
2019-07-12 15:03:56 +01:00
Chris Hill-Scott
a4ae534f87 Add extra fields to create/update organisation 2019-07-03 16:46:01 +01:00
Chris Hill-Scott
0955403a3b Slim down the /organisations response
At the moment this response returns a list of service IDs for hundreds
of organisations.

The admin app doesn’t use this information, but having to wait for it to
be serialized and sent across the network slows it down all the same.
2019-06-18 10:48:41 +01:00
Chris Hill-Scott
8977f5193e Add columns for on whose behalf agreement signed
This is changing because we’re going to introduce accepting contracts
and MoUs online.

Previously
---
We had one column for who signed the agreement, which is foreign keyed
to the user table. This is still relevant, because there will always be
a user who is clicking the button.

Now
---
We add two new fields for the name and email address of the person on
whose behalf the agreement is being accepted. This person:
- is different from the one signing the agreement
- won’t necessarily have a Notify account
2019-06-18 10:41:22 +01:00
Chris Hill-Scott
d974ab3b86 Return count of live services on organisations too
This makes it consistent, so the admin app can always rely on that
property being available.
2019-06-12 15:24:11 +01:00
Rebecca Law
c8196b0631 Merge pull request #2529 from alphagov/add-expiry-date-to-constraint
Allow api_keys names to be reused
2019-06-07 13:19:28 +01:00
Katie Smith
bef24408d0 Add DAO function to archive a user
For a user to be able to be archived, each service that they are a
member of must have at least one other user who is active and who has
the 'manage-settings' permission.

To archive a user we remove them from all their services and
organisations, remove all permissions that they have and change some of
their details:
- email_address will start with '_archived_<date>'
- the current_session_id is changed (to sign them out of their current
session)
- mobile_number is removed (so we also need to switch their auth type to
email_auth)
- password is changed to a random password
- state is changed to 'inactive'

If any of the steps fail, we rollback all changes.
2019-06-05 14:54:52 +01:00
Rebecca Law
a1f6a5f78a Update the unique constraint for the name of an api_key so that it only looks at api_keys that are not expired (or expiry_date is null).
This will allow clients to create a new api key with the same name.
2019-06-04 15:30:27 +01:00
Katie Smith
84c35cbf67 Add request_to_go_live_notes column to Organisation table
This column will be used to stores extra notes that should go in the
Zendesk ticket when a service belonging to that organisation requests to
go live.
2019-05-13 14:45:01 +01:00
Pea Tyczynska
eec5f5490d Don't require precompiled_letter service permission
Everyone can send precompiled letters now yay
2019-05-13 13:04:29 +01:00
Rebecca Law
55a65a22a9 Added test for go_live_user and go_live_at in the response for get_service_by_id 2019-04-17 13:20:44 +01:00
Rebecca Law
60b4970d7f Add new columns to services and services_history.
go_live_user_id: is the user that requested the service to go live
go_live_at: is the DateTime the service went live.

There will be a data migration from the beta partners spreadsheet to back fill the data.
2019-04-17 13:20:44 +01:00
Chris Hill-Scott
ee966668bd Remove domain columns from branding table
This relationship is via the `Organisation` now; we don’t use this
column to fudge a relationship based on the user’s email address and the
matching something in these columns.
2019-04-12 15:53:17 +01:00
Rebecca Law
64428368d1 Update EmailBranding.name to be not null and unique.
Needed to update old migration scripts so that the email_branding name is not null when creating the test dbs.
This should no affect the migrations elsewhere.
2019-04-09 14:33:38 +01:00
Chris Hill-Scott
b3008ee210 Allow excluding services from live services count
Sometimes we have to make a few services for what really is one
service, for example GOV.UK Pay and GOV.UK Pay Direct Debit. We also
have our own test services which aren’t included in the count of live
services. We currently count these as one service by not including them
in the beta partners spreadsheet.

This adds a column to mark such services as ‘not counted’, which can
later be used to exclude them from reporting.
2019-03-25 13:28:31 +00:00
Chris Hill-Scott
6dff916e95 Merge pull request #2407 from alphagov/return-domains-for-org
Return an organisation’s domains and fix a bug where the domains were getting wiped when updating other attributes
2019-03-22 16:07:15 +00:00
Katie Smith
8f5b5d636e Make invited_users folder_permissions column non-nullable
Now that notifications-admin is always sending through
folder_permissions, the folder_permissions column of the invited_user
table can be made non-nullable. The migration also backfills the column
(to []) to account for existing null values.
2019-03-22 10:49:45 +00:00
Katie Smith
3e70407981 Migration to add folder_permissions to invited_users table
Added a new JSONB column, folder_permissions, to the invited_users table
to store a list of folders that an invited user can see. This is
nullable for now, but will be changed to be non-nullable and
back-populated later.
2019-03-22 09:30:39 +00:00
Chris Hill-Scott
28ea75728c Return domains in get organisation response
We need this so we can disply them in the admin app.
2019-03-20 11:56:17 +00:00
Rebecca Law
d43a274562 Merge branch 'master' into remove-fk-to-users 2019-03-11 11:25:17 +00:00
Chris Hill-Scott
d7e03e00d3 Storing more info about an organisation
Currently we have
- a thing in the database called an ‘organisation’ which we don’t use
- the idea of an organisation which we derive from the user’s email
  address and is used to set the default branding for their service and
  determine whether they’ve signed the MOU

We should make these two things into one thing, by storing everything
we know about an organisation against that organisation in the database.
This will be much less laborious than storing it in a YAML file that
needs a deploy every time it’s updated.

An organisation can now have:
- domains which we can use to automatically associate services with it
  (eg anyone whose email address ends in `dwp.gsi.gov.uk` gets services
  they create associated to the DWP organisation)
- default letter branding for any new services
- default email branding for any new services
2019-03-08 13:30:32 +00:00
Rebecca Law
06facb7576 Removing the foreign from to users from Notification_history.
The relationship is not used and it prevents us from deleting users. It would be good to delete users that are never activated.
2019-03-07 17:20:42 +00:00
Chris Hill-Scott
b27bcc1d80 Make consent_to_research nullable
It should be nullable so we can tell whether someone has answered the
question already or not.

No real users have entered data into this column yet, so it’s fine to
wipe it.
2019-03-01 15:21:49 +00:00
Katie Smith
70cdcfff55 Include list of users_with_permission in all folders response
This adds a list of user_ids of the users who have permission to view a folder
to the `get_template_folders_for_service` endpoint.
2019-02-27 12:56:26 +00:00
Katie Smith
33166f3fb2 Add migration for user_folder_permissions table
Changed the user_to_service mapping table into a model called
ServiceUser. When looking at users who have permission for a folder
we are only interested in users for a particular service, not all users,
so we can use the ServiceUser model to access folder permissions.

Added a user_folder_permissions table which contains the service_id,
user_id and template_folder_id. There are links between
user_folder_permissions and TemplateFolder, and between
user_folder_permissions and ServiceUser.
2019-02-27 11:50:36 +00:00
Alexey Bezhan
1d77310fbd Add folder permissions permission
[#163755302](https://www.pivotaltracker.com/story/show/163755302)

Adds a new temporary service permission for enabling folder permission
editing.
2019-02-19 10:23:40 +00:00
Rebecca Law
34e5e9558d Last commit to remove edit_folders. 2019-02-15 14:44:33 +00:00
Chris Hill-Scott
f679731af8 Also store consent to research against a service
It makes most sense to collect this at the same time as the estimated
volumes. Which means we need to store it somewhere; we can’t put it
straight into the ticket.
2019-02-15 10:08:22 +00:00
Chris Hill-Scott
ecdf076506 Store anticipated volumes as integers
This will make it easier to do analysis on the data. Almost all users
are submitting data in a numerical format now anyway, because we ask the
question in a sensible way.
2019-02-15 10:08:22 +00:00
Chris Hill-Scott
17e32fa5f6 Add fields to record a service’s estimated volumes
When a service go live we ask people for their estimated sending
volumes. At the moment we only put this in the ticket, and store it in
a spreadsheet.

This means that a service can
- say they want to go live
- say they are sending 100,000 emails per year
- not have created any email templates
- still see ‘create templates’ as ‘completed’ in the go live checklist

If we store this data against the service we can collect it earlier, and
then use it to determine automatically what kind of templates the user
needs to create before their go live checklist can be considered
complete.
2019-02-15 10:08:22 +00:00
Leo Hemsted
53ecaa3230 remove dvla_organisation
it's been superceeded by letter branding
2019-02-13 15:02:18 +00:00