diff --git a/Makefile b/Makefile index 6884c678b..58bfd9b3c 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,7 @@ generate-version-file: ## Generates the app version file .PHONY: build build: dependencies generate-version-file ## Build project + ./venv/bin/pip-accel wheel --wheel-dir=wheelhouse -r requirements.txt .PHONY: build-codedeploy-artifact build-codedeploy-artifact: ## Build the deploy artifact for CodeDeploy diff --git a/app/models.py b/app/models.py index 05b86d4a2..526288990 100644 --- a/app/models.py +++ b/app/models.py @@ -123,6 +123,7 @@ class Service(db.Model, Versioned): backref=db.backref('user_to_service', lazy='dynamic')) restricted = db.Column(db.Boolean, index=False, unique=False, nullable=False) research_mode = db.Column(db.Boolean, index=False, unique=False, nullable=False, default=False) + can_send_letters = db.Column(db.Boolean, nullable=False, default=False) email_from = db.Column(db.Text, index=False, unique=True, nullable=False) created_by = db.relationship('User') created_by_id = db.Column(UUID(as_uuid=True), db.ForeignKey('users.id'), index=True, nullable=False) diff --git a/docker/Dockerfile-build b/docker/Dockerfile-build index 4fa6afb2d..25b071293 100644 --- a/docker/Dockerfile-build +++ b/docker/Dockerfile-build @@ -20,6 +20,7 @@ RUN \ echo "Install global pip packages" \ && pip install \ virtualenv \ - awscli + awscli \ + wheel WORKDIR /var/project diff --git a/migrations/versions/0058_add_letters_flag.py b/migrations/versions/0058_add_letters_flag.py new file mode 100644 index 000000000..3e7e5fcac --- /dev/null +++ b/migrations/versions/0058_add_letters_flag.py @@ -0,0 +1,24 @@ +"""empty message + +Revision ID: 0058_add_letters_flag +Revises: 0057_change_email_template +Create Date: 2016-10-25 17:37:27.660723 + +""" + +# revision identifiers, used by Alembic. +revision = '0058_add_letters_flag' +down_revision = '0057_change_email_template' + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('services', sa.Column('can_send_letters', sa.Boolean(), nullable=False, server_default=sa.false())) + op.add_column('services_history', sa.Column('can_send_letters', sa.Boolean(), nullable=False, server_default=sa.false())) + + +def downgrade(): + op.drop_column('services_history', 'can_send_letters') + op.drop_column('services', 'can_send_letters') diff --git a/requirements.txt b/requirements.txt index 3ffdfb572..dba7c2cfc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,6 +20,6 @@ statsd==3.2.1 git+https://github.com/alphagov/notifications-python-client.git@1.3.0#egg=notifications-python-client==1.3.0 -git+https://github.com/alphagov/notifications-utils.git@9.0.5#egg=notifications-utils==9.0.5 +git+https://github.com/alphagov/notifications-utils.git@9.1.1#egg=notifications-utils==9.1.1 git+https://github.com/alphagov/boto.git@2.42.0-patch2#egg=boto==2.42.0-patch2 diff --git a/scripts/aws_install_dependencies.sh b/scripts/aws_install_dependencies.sh index b82881d45..03daadb21 100755 --- a/scripts/aws_install_dependencies.sh +++ b/scripts/aws_install_dependencies.sh @@ -5,4 +5,4 @@ set -eo pipefail echo "Install dependencies" cd /home/notify-app/notifications-api; -pip3 install -r /home/notify-app/notifications-api/requirements.txt +pip3 install --find-links=wheelhouse -r /home/notify-app/notifications-api/requirements.txt diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 69e382c4e..3959e401d 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -193,6 +193,7 @@ def test_create_service(notify_api, sample_user): json_resp = json.loads(resp.get_data(as_text=True)) assert json_resp['data']['name'] == 'created service' assert not json_resp['data']['research_mode'] + assert not json_resp['data']['can_send_letters'] def test_should_not_create_service_with_missing_user_id_field(notify_api, fake_uuid): @@ -376,7 +377,7 @@ def test_update_service(notify_api, notify_db, sample_service): assert result['data']['organisation'] == str(org.id) -def test_update_service_research_mode(notify_api, sample_service): +def test_update_service_flags(notify_api, sample_service): with notify_api.test_request_context(): with notify_api.test_client() as client: auth_header = create_authorization_header() @@ -387,10 +388,12 @@ def test_update_service_research_mode(notify_api, sample_service): json_resp = json.loads(resp.get_data(as_text=True)) assert resp.status_code == 200 assert json_resp['data']['name'] == sample_service.name - assert not json_resp['data']['research_mode'] + assert json_resp['data']['research_mode'] is False + assert json_resp['data']['can_send_letters'] is False data = { - 'research_mode': True + 'research_mode': True, + 'can_send_letters': True } auth_header = create_authorization_header() @@ -402,7 +405,8 @@ def test_update_service_research_mode(notify_api, sample_service): ) result = json.loads(resp.get_data(as_text=True)) assert resp.status_code == 200 - assert result['data']['research_mode'] + assert result['data']['research_mode'] is True + assert result['data']['can_send_letters'] is True def test_update_service_research_mode_throws_validation_error(notify_api, sample_service):