Commit Graph

453 Commits

Author SHA1 Message Date
Chris Hill-Scott
c029927fde Merge pull request #1733 from alphagov/remove-dvla
Remove anything to do with DVLA format letters
2018-03-08 10:58:34 +00:00
Katie Smith
b0de3ba4d9 Create DailySortedLetter table
The response files we receive from the DVLA when we send letters
contain a row for each letter and a field with a value of 'Unsorted' or
'Sorted'. This table will be used to store the total number of
'Unsorted' and 'Sorted' letter notifications per day.
2018-03-06 09:09:02 +00:00
Chris Hill-Scott
7ef6af2d14 Remove anything to do with DVLA format letters 2018-03-02 14:13:12 +00:00
kentsanggds
25d84af63e Merge pull request #1709 from alphagov/ken-fix-letter-serialization
Fix serialization on precompiled letter
2018-02-27 10:13:15 +00:00
Rebecca Law
7faf375375 Merge pull request #1695 from alphagov/org-user-endpoints
Organisation user endpoints
2018-02-26 16:27:01 +00:00
Ken Tsang
c14663d84a Fix serialization on precompiled letter
Postcodes are required for created letters, but not for precompiled, this fix allows postcodes to be None in the model.
As postcodes are still required for created letter they should be caught by validation schemas in the POST handler
2018-02-26 13:53:06 +00:00
Rebecca Law
466aabdbea Added a new endpoint that can be used for organisation or service invitations.
The other two invitation endpoints will be removed once the admin app is updated.
2018-02-23 14:15:39 +00:00
Alexey Bezhan
c4fddab6a6 Add a hidden column to templates
Allows hiding templates from the templates list in the admin app
and related API responses.

This is used for 'internal' templates that we create for notifications
that wouldn't have a template otherwise (eg pre-compiled PDF letters)
2018-02-23 13:38:15 +00:00
Rebecca Law
446e76f1f3 Remove users relationship in organisations 2018-02-23 13:36:42 +00:00
Rebecca Law
13ef2d7bae - new endpoint to check the token for an org invitation.
- new endpoint to add user to organisation
- new endpoint to return users for an organisation
2018-02-23 10:45:18 +00:00
Leo Hemsted
5b71d2f36e add org invite template to db 2018-02-23 10:45:18 +00:00
Leo Hemsted
a2a1c5e9af add organisation invite rest and dao 2018-02-23 10:45:18 +00:00
Ken Tsang
90e9d99161 Add precompiled_letter service permission
- migration script to add precompiled_letter in service_permission_types table and in service permission types list in models.py
2018-02-21 16:26:49 +00:00
Leo Hemsted
450deae32a add user_to_organisation and invited_organisation_users tables
similar to user_to_service and invited_users, but without auth types
or permissions
2018-02-15 14:19:24 +00:00
Ken Tsang
d80c7d4f65 Return services serialized for dashboard for orgs
- rather than returning the entire service, return only whats needed when listing the service on the org dashboard
2018-02-13 14:06:43 +00:00
Ken Tsang
a035dcf7b0 Add organisation_to_service association table
- moved Organisation so that Service model has access to it
2018-02-13 14:06:43 +00:00
Katie Smith
269923ba28 Add Organisations endpoints
As part of this we also needed to add:
- schemas for validation
- serialize method for Organisation model
2018-02-08 15:22:21 +00:00
Katie Smith
d40d520d2c Add Organisation model and migration
Now that we have renamed the 'old' organisation model to email_branding,
we can create a new organisation model.
2018-02-08 14:39:25 +00:00
Leo Hemsted
ba20010f27 remove organisation from api 2018-02-07 11:39:33 +00:00
Leo Hemsted
2f79da8702 create, edit and use email branding instead of organisation
notable things that have been kept until migration is complete:

* passing in `organisation` to update_service will update email branding
* both `/email-branding` and `/organisation` hit the same code
* service endpoints still return organisation as well as email branding
2018-02-06 11:23:34 +00:00
Leo Hemsted
5d00abd6bc update service_email_branding mapping table alongside organisation_id 2018-02-02 12:50:53 +00:00
Ken Tsang
3355a29d01 Ensure letter personalisation is serialized correctly
The personalisation for letters can take different formats depending on
how the letter was generated, for example it can contain either
address_line_1 or addressline1. This change ensures that it is always
serialized in the same way.
2018-01-24 16:44:14 +00:00
Katie Smith
b07db16cd1 Get rate limit from service.rate_limit column (not config)
PR #1550 added the rate_limit column to the Service table.

This PR removes the rate limits from the config and uses rate_limit from
the Service model instead. Rate limits are still separated into 'team',
'normal' and 'test', but these values are the same for a service.

Pivotal story https://www.pivotaltracker.com/story/show/153992529
2018-01-11 10:28:11 +00:00
Rebecca Law
a052020f84 - simplify if statement
- use the template.get_reply_to_text() in send_notification, it's already using the right thing.
2018-01-08 16:54:19 +00:00
Rebecca Law
d6683d9630 If template has a default address use that address ELSE the address is blank. 2018-01-08 15:54:58 +00:00
Rebecca Law
5be5e17e46 Because life is difficult today...
Need to alter the column to nullable and remove reference to the column in any code. Next PR will drop column
2018-01-05 15:55:02 +00:00
Rebecca Law
6e6f388f88 Merge branch 'master' into update_template_schema 2018-01-04 11:45:36 +00:00
Rebecca Law
6a3831eace Added a boolean column to templates called is_letter_contact_blank.
If is_letter_contact_blank then the user has set the letter contact block to be blank on purpose
ELSE IF is_letter_contact_blank is false THEN use the template default
IF template default is blank THEN the service_letter_contact is blank use the service default
2018-01-04 11:33:10 +00:00
Alexey Bezhan
d5b6bd85fe Normalize outbound SMS sender number in one off notifications 2018-01-03 10:32:34 +00:00
Alexey Bezhan
545ff7dda6 Normalize outbound SMS number for job notifications
Replaces 0 with 44 in UK SMS sender number to make it possible to
respond to the SMS from an international number.
2018-01-03 10:32:34 +00:00
Alexey Bezhan
3b0790f950 Add Template.get_reply_to_text helper method
Returns either template's reply_to text if set or the related field
from the default service record.

Return value can be used as default for `Notification.reply_to_text`
when per-notification value is not provided.
2017-12-19 10:23:24 +00:00
Ken Tsang
3464336aff Refactored tasks.py to split out letters_pdf tasks
- Added has_permission helper in models.py to check permission in service
- Moved letters pdf tasks to separate file
- Moved letters pdf tests to own file
2017-12-12 12:07:55 +00:00
Rebecca Law
ad060435ca Merge branch 'master' into refactor-letter-rates 2017-12-06 17:25:39 +00:00
Rebecca Law
14be85160c Insert initial letter rates.
Create letter rates dao.
Query to fetch letter rates.
2017-12-06 16:40:38 +00:00
Leo Hemsted
664187f878 update model to reflect service.prefix_sms not being nullable 2017-12-06 14:45:43 +00:00
Leo Hemsted
b0d4044ff5 remove free_sms_fragment_limit from service
* remove from model
* still required when calling POST /service - we just call through
  from dao_create_service to add a new annual billing entry.
* removed from POST /service/<id> update_service - if you want to
  update/add a new one, use POST /service/<id>/free-sms-fragment-limit
* made sure tests create services with default 250k limit.
2017-12-06 14:45:43 +00:00
Rebecca Law
91e6cb9215 Merge branch 'master' into refactor-letter-rates 2017-12-05 12:03:13 +00:00
Rebecca Law
956907c170 Revert the last commit. It was intended for another branch. 2017-12-05 10:54:55 +00:00
Rebecca Law
00d2e543dc Refactor letter_rates table to include everything needed to calculate billing for letter notificaitons.
It is ok to drop the existing tables as they are not used anywhere as of yet.
2017-12-05 10:32:19 +00:00
Rebecca Law
06a6d37595 Merge branch 'master' into add-crown-column-to-services 2017-12-05 10:28:26 +00:00
Rebecca Law
b4a1d635f7 Rebuild the letter_rates table to include everything it needs.
The current letter_rates table is not used so it is ok to drop and re-create it
2017-12-05 10:27:29 +00:00
Katie Smith
f73319f5ef Add and populate crown column to services and services_history
- Added the boolean 'crown' column to services and services_history tables
- We populate this column in the same migration script by checking the
'organisation_type' of a service
2017-12-04 13:31:08 +00:00
Ken Tsang
907a9d62a1 Add letters_as_pdf service permission 2017-12-01 17:25:20 +00:00
Rebecca Law
a01838e833 Drop the Notification to sender mapping tables.
We no longer need them because we record the text value of the sender on the notification.
2017-11-30 15:53:08 +00:00
Venus Bailey
795056bc1b Merge pull request #1440 from alphagov/vb-govuk-db-migration
Migration to create new database table service_callback_api
2017-11-29 11:46:51 +00:00
venusbb
5761d22822 Migration to create new database table service_callback_api 2017-11-28 15:25:15 +00:00
Leo Hemsted
28d5f9b87f flake8 - remove unused imports and ensure they're always at the top of the file 2017-11-28 14:28:01 +00:00
Rebecca Law
86098041fa Add reply_to_text to Notification model.
This was missed out of the previous PR and needs to be there before the next PR is merged.
2017-11-27 13:39:35 +00:00
Alexey Bezhan
e8ce408f6a Fix an intermittent test failure when creating a template with reply_to
reply_to requires template_type to be already set, but the order
of attribute assignment is not defined when a model object is created
from a dictionary.

This adds a constructor to Template model that makes sure that
template_type is set first when multiple arguments are passed to the
constructor at once.

The problem might still exist when the template is created through the
API, so this is a temporary fix to unblock the release.
2017-11-22 16:13:45 +00:00
Alexey Bezhan
cbce610098 Add template.service_letter_contact_id and reply_to wrapper property
Adds a relationship between Template models and service letter contact
blocks.

Depending on template type, we can have a reference to either a letter
contact block, email reply-to address or SMS sender record. This means
that in order to enforce foreign key constraints we need to define three
separate foreign key columns on the template model.

To hide this implementation detail and make it easier to access the
sender/reply-to information we define a wrapper property that returns
the value from the correct column.

The relationship and the property are only defined for letter templates
at the moment.

The setter raises an error when trying to assign a reply_to value for
non-letter templates. The exception isn't raised if the value being
assigned is `None` since it can get assigned by marshmallow schemas
and as it matches the value returned for other template types it
doesn't need to be written anywhere.
2017-11-22 14:20:53 +00:00