There was a misunderstanding about how we wanted the feature to work.

There is no need for the extra column.
If a template does not have a default address set - they address will be blank.
Otherwise use the address of the service_letter_contact.

There will be another PR to do a db migration.
Template.service_letter_contact = blank if no service_letter_contacts for service ELSE use set Template.serivce_letter_contact_id = service default service_letter_contact
This commit is contained in:
Rebecca Law
2018-01-05 15:32:43 +00:00
parent 89116d683b
commit 9e9b8ab1a3
3 changed files with 20 additions and 5 deletions

View File

@@ -582,10 +582,6 @@ class TemplateBase(db.Model):
content = db.Column(db.Text, nullable=False)
archived = db.Column(db.Boolean, nullable=False, default=False)
subject = db.Column(db.Text)
is_letter_contact_blank = db.Column(db.Boolean, nullable=False, default=False)
# if is_letter_contact = True then service_letter_contact must be null.
CheckConstraint("Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)")
@declared_attr
def service_id(cls):

View File

@@ -0,0 +1,20 @@
"""
Revision ID: 0154_revert_0153
Revises: 0153_add_is_letter_contact_blank
Create Date: 2018-01-05 14:09:21.200102
"""
from alembic import op
revision = '0154_revert_0153'
down_revision = '0153_add_is_letter_contact_blank'
def upgrade():
op.drop_column('templates', 'is_letter_contact_blank')
op.drop_column('templates_history', 'is_letter_contact_blank')
def downgrade():
pass

View File

@@ -625,7 +625,6 @@ def test_get_template_reply_to(client, sample_letter_template):
assert 'service_letter_contact_id' not in json_resp['data']
assert json_resp['data']['reply_to'] == str(letter_contact.id)
assert json_resp['data']['reply_to_text'] == letter_contact.contact_block
assert not json_resp['data']['is_letter_contact_blank']
def test_update_template_reply_to(client, sample_letter_template):