mirror of
https://github.com/GSA/notifications-api.git
synced 2026-06-20 05:00:42 -04:00
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
This commit is contained in:
@@ -578,6 +578,10 @@ 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):
|
||||
|
||||
@@ -120,7 +120,6 @@ def get_template_by_id_and_service_id(service_id, template_id):
|
||||
def preview_template_by_id_and_service_id(service_id, template_id):
|
||||
fetched_template = dao_get_template_by_id_and_service_id(template_id=template_id, service_id=service_id)
|
||||
data = template_schema.dump(fetched_template).data
|
||||
print(data)
|
||||
template_object = get_template_instance(data, values=request.args.to_dict())
|
||||
|
||||
if template_object.missing_data:
|
||||
|
||||
38
migrations/versions/0153_add_is_letter_contact_blank.py
Normal file
38
migrations/versions/0153_add_is_letter_contact_blank.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""
|
||||
|
||||
Revision ID: ea1c2f80a50e
|
||||
Revises: 0152_kill_service_free_fragments
|
||||
Create Date: 2018-01-04 10:27:01.014640
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0153_add_is_letter_contact_blank'
|
||||
down_revision = '0152_kill_service_free_fragments'
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('templates', sa.Column('is_letter_contact_blank', sa.Boolean(), nullable=True))
|
||||
op.add_column('templates_history', sa.Column('is_letter_contact_blank', sa.Boolean(), nullable=True))
|
||||
op.execute("update templates set is_letter_contact_blank = false")
|
||||
op.execute("update templates_history set is_letter_contact_blank = false")
|
||||
op.alter_column("templates", "is_letter_contact_blank", nullable=False)
|
||||
op.alter_column("templates_history", "is_letter_contact_blank", nullable=False)
|
||||
|
||||
op.create_check_constraint(
|
||||
"ck_templates_contact_block_is_blank",
|
||||
"templates",
|
||||
"Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)"
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_templates_history_contact_block_is_blank",
|
||||
"templates_history",
|
||||
"Not(is_letter_contact_blank = True and service_letter_contact_id is not Null)"
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('templates_history', 'is_letter_contact_blank')
|
||||
op.drop_column('templates', 'is_letter_contact_blank')
|
||||
@@ -623,6 +623,7 @@ 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'] == letter_contact.contact_block
|
||||
assert not json_resp['data']['is_letter_contact_blank']
|
||||
|
||||
|
||||
def test_update_template_reply_to(client, sample_letter_template):
|
||||
|
||||
Reference in New Issue
Block a user