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:
Rebecca Law
2018-01-04 11:33:10 +00:00
parent 33e8e55dc6
commit 6a3831eace
4 changed files with 43 additions and 1 deletions

View File

@@ -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):

View File

@@ -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: