Commit Graph

562 Commits

Author SHA1 Message Date
Rebecca Law
82cc6d6bef As it turns out the s3ftp used to mount the s3 bucket to our ftp server puts the file on s3 more than once. So the SNS topic is triggered more than once.
We need to deal with this, it's ok when updating a notification status from delivered to delivered. But the DailySortedLetter counts are being doubled.
Adding the file_name to the table as a unique key to get around this issue. It will mean we have multiple rows for each billing_day, but that's ok we can aggregate that.
This will also give us a way to see which file created which count.
2018-03-14 17:04:58 +00:00
Leo Hemsted
5871dee606 use joinedload to only hit the database once per request
also:

* only include active orgs
* write lots of tests
2018-03-14 15:39:31 +00:00
Leo Hemsted
91fa475645 add new endpoint to get organisations and services for a user
contains orgs, and unmapped services.

the orgs contain nested services - services the user is a part of that
belong to that org.

the unmapped services are any services that the user is a part of that
either don't have an org or have one that the user doesn't know about
2018-03-14 15:39:31 +00:00
Leo Hemsted
efec57db01 replace user_schema with serialize method on user model
this is so that we can filter out inactive organisations and services

note: can't remove user schema completely, as we still use it in
POST /user to create new users
2018-03-14 15:39:31 +00:00
Katie Smith
43c63a1644 Add new virus scan statuses
Added the following new notification statuses:
* pending_virus_check
* virus_scan_failed

If we decide to remove these statuses in future, we will need to replace
them with a different status in the notifications and
Notification_history tables where they are referenced, so
pending-virus-check will be replaced with sending, and virus-scan-failed
will be replaced with permanent-failure.
2018-03-13 12:03:14 +00:00
venusbb
59898b7349 Add billing models and small alteration to billing tables 2018-03-12 18:19:26 +00:00
Katie Smith
db6fa457b5 Delete JobStatistics model
Also changed the delete_service_and_all_associated_db_objects function
from the services DAO to remove reference to JobStatistics table.
2018-03-12 10:48:46 +00:00
kentsanggds
b0b0062b35 Merge pull request #1732 from alphagov/ken-hidden-in-json-response
Return `is_precompiled_letter` field as part of json for notification by id
2018-03-08 15:06:10 +00:00
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
Ken Tsang
7011b90bd4 Refactor is_precompiled_letter to model 2018-03-07 23:03:03 +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