|
|
@ -4,6 +4,7 @@ from django import template |
|
|
import json |
|
|
import json |
|
|
|
|
|
|
|
|
from django.core.urlresolvers import reverse |
|
|
from django.core.urlresolvers import reverse |
|
|
|
|
|
from django.utils.html import format_html, format_html_join |
|
|
|
|
|
|
|
|
register = template.Library() |
|
|
register = template.Library() |
|
|
|
|
|
|
|
|
@ -28,67 +29,81 @@ def reformat_value(source, question_key): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_list(lst, question_key): |
|
|
def process_list(lst, question_key): |
|
|
tag = ["<ul>"] |
|
|
|
|
|
if question_key.startswith('other_name_'): |
|
|
if question_key.startswith('other_name_'): |
|
|
for alias_type, value in lst: |
|
|
|
|
|
if value: |
|
|
|
|
|
tag.append('<li>' + alias_type + ' ' + value + '</li>') |
|
|
|
|
|
|
|
|
list_items = format_html_join( |
|
|
|
|
|
'\n', |
|
|
|
|
|
'<li>{} {}</li>', |
|
|
|
|
|
((alias_type, value) for alias_type, value in lst if value)) |
|
|
else: |
|
|
else: |
|
|
for value in lst: |
|
|
|
|
|
if value and not value.isspace(): |
|
|
|
|
|
tag.append('<li>' + str(value) + '</li>') |
|
|
|
|
|
tag.append('</ul>') |
|
|
|
|
|
return ''.join(tag) |
|
|
|
|
|
|
|
|
list_items = format_html_join( |
|
|
|
|
|
'\n', |
|
|
|
|
|
'<li>{0}</li>', |
|
|
|
|
|
((value, '') for value in lst if value and not value.isspace())) |
|
|
|
|
|
tag = format_html( |
|
|
|
|
|
'<ul>{}</ul>', |
|
|
|
|
|
list_items) |
|
|
|
|
|
|
|
|
|
|
|
return tag |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reformat_list(source): |
|
|
def reformat_list(source): |
|
|
text_list = source.split('\n') |
|
|
text_list = source.split('\n') |
|
|
if len(text_list) > 1: |
|
|
if len(text_list) > 1: |
|
|
tag = ["<ul>"] |
|
|
|
|
|
for value in text_list: |
|
|
|
|
|
if value and not value.isspace(): |
|
|
|
|
|
tag.append('<li>' + value + '</li>') |
|
|
|
|
|
tag.append('</ul>') |
|
|
|
|
|
return ''.join(tag) |
|
|
|
|
|
|
|
|
list_items = format_html_join( |
|
|
|
|
|
'\n', |
|
|
|
|
|
'<li>{0}</li>', |
|
|
|
|
|
((value, '') for value in text_list if value)) |
|
|
|
|
|
tag = format_html( |
|
|
|
|
|
'<ul>{}</ul>', |
|
|
|
|
|
list_items) |
|
|
|
|
|
return tag |
|
|
else: |
|
|
else: |
|
|
return text_list.pop() |
|
|
return text_list.pop() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_row(question, response): |
|
|
def format_row(question, response): |
|
|
return '<tr><td width="75%" class="table-bordered" style="padding-right: 5%">{0}</td><td class="table-bordered" width="25%">{1}</td></tr>'.format( |
|
|
|
|
|
question, response |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
return format_html( |
|
|
|
|
|
'<tr><td width="75%" class="table-bordered" style="padding-right: 5%">{0}</td><td class="table-bordered" width="25%">{1}</td></tr>', |
|
|
|
|
|
question, |
|
|
|
|
|
response) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_review_row_heading(title, style=""): |
|
|
def format_review_row_heading(title, style=""): |
|
|
return '<tr><td colspan="2" class="table-bordered {1}"><b>{0}</b></td></tr>'.format(title, style) |
|
|
|
|
|
|
|
|
return format_html( |
|
|
|
|
|
'<tr><td colspan="2" class="table-bordered {1}"><b>{0}</b></td></tr>', |
|
|
|
|
|
title, |
|
|
|
|
|
style) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_head(headings): |
|
|
|
|
|
if len(headings) == 0: |
|
|
|
|
|
return '', [] |
|
|
|
|
|
|
|
|
# def format_head(headings): |
|
|
|
|
|
# if len(headings) == 0: |
|
|
|
|
|
# return '', [] |
|
|
|
|
|
|
|
|
tags = ["<tr>"] |
|
|
|
|
|
head_order = list() |
|
|
|
|
|
for key in headings[0].keys(): |
|
|
|
|
|
tags.append('<th>{}</th>'.format(key.replace('_', ' ').title())) |
|
|
|
|
|
head_order.append(key) |
|
|
|
|
|
tags.append('</tr>') |
|
|
|
|
|
return ''.join(tags), head_order |
|
|
|
|
|
|
|
|
# tags = ["<tr>"] |
|
|
|
|
|
# head_order = list() |
|
|
|
|
|
# for key in headings[0].keys(): |
|
|
|
|
|
# tags.append('<th>{}</th>'.format(key.replace('_', ' ').title())) |
|
|
|
|
|
# head_order.append(key) |
|
|
|
|
|
# tags.append('</tr>') |
|
|
|
|
|
# return ''.join(tags), head_order |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_fact_sheet_list(data, header): |
|
|
|
|
|
tags = list() |
|
|
|
|
|
for item in data: |
|
|
|
|
|
tags.append('<tr>') |
|
|
|
|
|
for key in header: |
|
|
|
|
|
tags.append('<td>{}</td>'.format(item.get(key, ''))) |
|
|
|
|
|
tags.append('</tr>') |
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
# def process_fact_sheet_list(data, header): |
|
|
|
|
|
# tags = list() |
|
|
|
|
|
# for item in data: |
|
|
|
|
|
# tags.append('<tr>') |
|
|
|
|
|
# for key in header: |
|
|
|
|
|
# tags.append('<td>{}</td>'.format(item.get(key, ''))) |
|
|
|
|
|
# tags.append('</tr>') |
|
|
|
|
|
# return ''.join(tags) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_fact_sheet(title, url, style=''): |
|
|
def format_fact_sheet(title, url, style=''): |
|
|
return '<tr><td colspan="2" class="table-bordered {0}"><a href="{1}"><b>{2}</b></a></td></tr>'.format(style, url, title) |
|
|
|
|
|
|
|
|
return format_html( |
|
|
|
|
|
'<tr><td colspan="2" class="table-bordered {0}"><a href="{1}"><b>{2}</b></a></td></tr>', |
|
|
|
|
|
style, |
|
|
|
|
|
url, |
|
|
|
|
|
title) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag(takes_context=True) |
|
|
@register.simple_tag(takes_context=True) |
|
|
@ -152,12 +167,11 @@ def format_children(context, source): |
|
|
|
|
|
|
|
|
child_support_orders = {'have_court_order', 'what_parenting_arrangements', 'order_respecting_arrangement', 'order_for_child_support'} |
|
|
child_support_orders = {'have_court_order', 'what_parenting_arrangements', 'order_respecting_arrangement', 'order_for_child_support'} |
|
|
|
|
|
|
|
|
tags = [] |
|
|
|
|
|
|
|
|
tags = '<tbody>' |
|
|
# process mapped questions first |
|
|
# process mapped questions first |
|
|
working_source = source.copy() |
|
|
working_source = source.copy() |
|
|
tags.append('<tbody>') |
|
|
|
|
|
for title, questions in question_to_heading.items(): |
|
|
for title, questions in question_to_heading.items(): |
|
|
tags.append(format_review_row_heading(title)) |
|
|
|
|
|
|
|
|
tags = format_html('{}{}', tags, format_review_row_heading(title)) |
|
|
|
|
|
|
|
|
for question in questions: |
|
|
for question in questions: |
|
|
if question in fact_sheet_mapping: |
|
|
if question in fact_sheet_mapping: |
|
|
@ -177,7 +191,7 @@ def format_children(context, source): |
|
|
show_fact_sheet = True |
|
|
show_fact_sheet = True |
|
|
|
|
|
|
|
|
if show_fact_sheet and len(fact_sheet_mapping[question]): |
|
|
if show_fact_sheet and len(fact_sheet_mapping[question]): |
|
|
tags.append(format_fact_sheet(question, fact_sheet_mapping[question])) |
|
|
|
|
|
|
|
|
tags = format_html('{}{}', tags, format_fact_sheet(question, fact_sheet_mapping[question])) |
|
|
else: |
|
|
else: |
|
|
|
|
|
|
|
|
item = list(filter(lambda x: x['question_id'] == question, working_source)) |
|
|
item = list(filter(lambda x: x['question_id'] == question, working_source)) |
|
|
@ -187,7 +201,7 @@ def format_children(context, source): |
|
|
item = item.pop() |
|
|
item = item.pop() |
|
|
if context['derived']['wants_child_support'] is True: |
|
|
if context['derived']['wants_child_support'] is True: |
|
|
# make sure free form text is reformted to be bullet list. |
|
|
# make sure free form text is reformted to be bullet list. |
|
|
tags.append(format_row(item['question__name'], reformat_list(item['value']))) |
|
|
|
|
|
|
|
|
tags = format_html('{}{}{}', tags, format_row(item['question__name'], reformat_list(item['value']))) |
|
|
continue |
|
|
continue |
|
|
|
|
|
|
|
|
if len(item): |
|
|
if len(item): |
|
|
@ -197,12 +211,14 @@ def format_children(context, source): |
|
|
if q_id == 'claimant_children': |
|
|
if q_id == 'claimant_children': |
|
|
child_counter = 1 |
|
|
child_counter = 1 |
|
|
for child in json.loads(item['value']): |
|
|
for child in json.loads(item['value']): |
|
|
tags.append(format_review_row_heading('Child {}'.format(child_counter), 'review-child-heading')) |
|
|
|
|
|
tags.append(format_row('Child\'s name', child['child_name'])) |
|
|
|
|
|
tags.append(format_row('Birth date', child['child_birth_date'])) |
|
|
|
|
|
tags.append(format_row('Child now living with', child['child_live_with'])) |
|
|
|
|
|
tags.append(format_row('Relationship to yourself (claimant 1)', child['child_relationship_to_you'])) |
|
|
|
|
|
tags.append(format_row('Relationship to your spouse (claimant 2)', child['child_relationship_to_spouse'])) |
|
|
|
|
|
|
|
|
tags = format_html( |
|
|
|
|
|
'{}{}{}{}{}{}', |
|
|
|
|
|
format_review_row_heading('Child {}'.format(child_counter), 'review-child-heading'), |
|
|
|
|
|
format_row('Child\'s name', child['child_name']), |
|
|
|
|
|
format_row('Birth date', child['child_birth_date']), |
|
|
|
|
|
format_row('Child now living with', child['child_live_with']), |
|
|
|
|
|
format_row('Relationship to yourself (claimant 1)', child['child_relationship_to_you']), |
|
|
|
|
|
format_row('Relationship to your spouse (claimant 2)', child['child_relationship_to_spouse'])) |
|
|
child_counter = child_counter + 1 |
|
|
child_counter = child_counter + 1 |
|
|
else: |
|
|
else: |
|
|
value = item['value'] |
|
|
value = item['value'] |
|
|
@ -220,16 +236,15 @@ def format_children(context, source): |
|
|
value = reformat_list(value) |
|
|
value = reformat_list(value) |
|
|
|
|
|
|
|
|
if isinstance(value, list): |
|
|
if isinstance(value, list): |
|
|
tags.append(format_row(question_name, process_list(value, q_id))) |
|
|
|
|
|
|
|
|
tags = format_html('{}{}', tags, format_row(question_name, process_list(value, q_id))) |
|
|
elif isinstance(value, str): |
|
|
elif isinstance(value, str): |
|
|
if len(value): |
|
|
if len(value): |
|
|
tags.append(format_row(question_name, value)) |
|
|
|
|
|
|
|
|
tags = format_html('{}{}', tags, format_row(question_name, value)) |
|
|
else: |
|
|
else: |
|
|
tags.append(format_row(question_name, value)) |
|
|
|
|
|
tags.append('</tbody>') |
|
|
|
|
|
tags.append('<tbody class="review-table-spacer">') |
|
|
|
|
|
tags.append('</tbody>') |
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
tags = format_html('{}{}', tags, format_row(question_name, value)) |
|
|
|
|
|
tags = format_html('{}</tbody> <tbody class="review-table-spacer">', tags) |
|
|
|
|
|
tags = format_html('{}</tbody>', tags) |
|
|
|
|
|
return tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag |
|
|
@register.simple_tag |
|
|
@ -238,10 +253,7 @@ def combine_address(source): |
|
|
Reformat address to combine them into one cell with multiple line |
|
|
Reformat address to combine them into one cell with multiple line |
|
|
Also show/hide optional questions |
|
|
Also show/hide optional questions |
|
|
""" |
|
|
""" |
|
|
tags = [] |
|
|
|
|
|
first_column = '<tr><td width="75%" style="padding-right: 5%">' |
|
|
|
|
|
second_column = '<td width="25%">' |
|
|
|
|
|
end_tag = '</td></tr>' |
|
|
|
|
|
|
|
|
tags = '' |
|
|
|
|
|
|
|
|
address_you = "" |
|
|
address_you = "" |
|
|
fax_you = "" |
|
|
fax_you = "" |
|
|
@ -258,7 +270,7 @@ def combine_address(source): |
|
|
if "email" not in q_id and "fax" not in q_id: |
|
|
if "email" not in q_id and "fax" not in q_id: |
|
|
if q_id == "address_to_send_official_document_country_you": |
|
|
if q_id == "address_to_send_official_document_country_you": |
|
|
continue |
|
|
continue |
|
|
address_you += item["value"] + '<br />' |
|
|
|
|
|
|
|
|
address_you = format_html('{}{}<br />', address_you, item["value"]) |
|
|
elif "fax" in q_id: |
|
|
elif "fax" in q_id: |
|
|
fax_you = item["value"] |
|
|
fax_you = item["value"] |
|
|
elif "email" in q_id: |
|
|
elif "email" in q_id: |
|
|
@ -267,7 +279,7 @@ def combine_address(source): |
|
|
if "email" not in q_id and "fax" not in q_id: |
|
|
if "email" not in q_id and "fax" not in q_id: |
|
|
if q_id == "address_to_send_official_document_country_spouse": |
|
|
if q_id == "address_to_send_official_document_country_spouse": |
|
|
continue |
|
|
continue |
|
|
address_spouse += item["value"] + '<br />' |
|
|
|
|
|
|
|
|
address_spouse = format_html('{}{}<br />', address_spouse, item["value"]) |
|
|
elif "fax" in q_id: |
|
|
elif "fax" in q_id: |
|
|
fax_spouse = item["value"] |
|
|
fax_spouse = item["value"] |
|
|
elif "email" in q_id: |
|
|
elif "email" in q_id: |
|
|
@ -281,27 +293,21 @@ def combine_address(source): |
|
|
effective_date = item['value'] |
|
|
effective_date = item['value'] |
|
|
|
|
|
|
|
|
if address_you != "": |
|
|
if address_you != "": |
|
|
tags.append(first_column + "What is the best address to send you official court documents?</td>" |
|
|
|
|
|
+ second_column + address_you + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "What is the best address to send you official court documents?", address_you) |
|
|
if fax_you != "": |
|
|
if fax_you != "": |
|
|
tags.append(first_column + "Fax</td>" + second_column + fax_you + end_tag) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "Fax", fax_you) |
|
|
if email_you != "": |
|
|
if email_you != "": |
|
|
tags.append(first_column + "Email</td>" + second_column + email_you + end_tag) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "Email", email_you) |
|
|
if address_spouse != "": |
|
|
if address_spouse != "": |
|
|
tags.append(first_column + "What is the best address to send your spouse official court documents?</td>" |
|
|
|
|
|
+ second_column + address_spouse + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "What is the best address to send your spouse official court documents?", address_spouse) |
|
|
if fax_spouse != "": |
|
|
if fax_spouse != "": |
|
|
tags.append(first_column + "Fax</td>" + second_column + fax_spouse + end_tag) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "Fax", fax_spouse) |
|
|
if email_spouse != "": |
|
|
if email_spouse != "": |
|
|
tags.append(first_column + "Email</td>" + second_column + email_spouse + end_tag) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "Email", email_spouse) |
|
|
if effective_date != "": |
|
|
if effective_date != "": |
|
|
tags.append(first_column + "Divorce is to take effect on </td>" + second_column + effective_date + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "Divorce is to take effect on", effective_date) |
|
|
|
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
return tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag(takes_context=True) |
|
|
@register.simple_tag(takes_context=True) |
|
|
@ -311,10 +317,7 @@ def marriage_tag(context, source): |
|
|
Also show/hide optional questions |
|
|
Also show/hide optional questions |
|
|
""" |
|
|
""" |
|
|
show_all = False |
|
|
show_all = False |
|
|
tags = [] |
|
|
|
|
|
first_column = '<tr><td width="75%" style="padding-right: 5%">' |
|
|
|
|
|
second_column = '</td><td width="25%">' |
|
|
|
|
|
end_tag = '</td></tr>' |
|
|
|
|
|
|
|
|
tags = '' |
|
|
|
|
|
|
|
|
marriage_location = "" |
|
|
marriage_location = "" |
|
|
married_date = "" |
|
|
married_date = "" |
|
|
@ -348,7 +351,7 @@ def marriage_tag(context, source): |
|
|
elif q_id.startswith('where_were_you_married'): |
|
|
elif q_id.startswith('where_were_you_married'): |
|
|
if value == 'Other': |
|
|
if value == 'Other': |
|
|
continue |
|
|
continue |
|
|
marriage_location += value + '<br />' |
|
|
|
|
|
|
|
|
marriage_location = format_html('{}{}<br />', marriage_location, value) |
|
|
elif q_id == 'marital_status_before_you': |
|
|
elif q_id == 'marital_status_before_you': |
|
|
marital_status_you_q = q_name |
|
|
marital_status_you_q = q_name |
|
|
marital_status_you = value |
|
|
marital_status_you = value |
|
|
@ -357,17 +360,17 @@ def marriage_tag(context, source): |
|
|
marital_status_spouse = value |
|
|
marital_status_spouse = value |
|
|
|
|
|
|
|
|
if show_all and married_date != "": |
|
|
if show_all and married_date != "": |
|
|
tags.append(first_column + married_date_q + second_column + married_date + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, married_date_q, married_date) |
|
|
if common_law_date != "": |
|
|
if common_law_date != "": |
|
|
tags.append(first_column + common_law_date_q + second_column + common_law_date + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, common_law_date_q, common_law_date) |
|
|
if show_all and marriage_location != "": |
|
|
if show_all and marriage_location != "": |
|
|
tags.append(first_column + "Where were you married" + second_column + marriage_location + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, "Where were you married", marriage_location) |
|
|
if marital_status_you != "": |
|
|
if marital_status_you != "": |
|
|
tags.append(first_column + marital_status_you_q + second_column + marital_status_you + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, marital_status_you_q, marital_status_you) |
|
|
if marital_status_spouse != "": |
|
|
if marital_status_spouse != "": |
|
|
tags.append(first_column + marital_status_spouse_q + second_column + marital_status_spouse + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, marital_status_spouse_q, marital_status_spouse) |
|
|
|
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
return tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag |
|
|
@register.simple_tag |
|
|
@ -376,10 +379,7 @@ def property_tag(source): |
|
|
Reformat your_property and debt step |
|
|
Reformat your_property and debt step |
|
|
Also show/hide optional questions |
|
|
Also show/hide optional questions |
|
|
""" |
|
|
""" |
|
|
tags = [] |
|
|
|
|
|
first_column = '<tr><td width="75%" style="padding-right: 5%">' |
|
|
|
|
|
second_column = '</td><td width="25%">' |
|
|
|
|
|
end_tag = '</td></tr>' |
|
|
|
|
|
|
|
|
tags = '' |
|
|
|
|
|
|
|
|
division = division_detail = other_detail = None |
|
|
division = division_detail = other_detail = None |
|
|
|
|
|
|
|
|
@ -394,13 +394,13 @@ def property_tag(source): |
|
|
other_detail = item |
|
|
other_detail = item |
|
|
|
|
|
|
|
|
if division: |
|
|
if division: |
|
|
tags.append(first_column + division['question__name'] + second_column + division['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, division['question__name'], division['value']) |
|
|
if division and division['value'] == "Unequal division" and division_detail: |
|
|
if division and division['value'] == "Unequal division" and division_detail: |
|
|
tags.append(first_column + division_detail['question__name'] + second_column + process_list(division_detail['value'].split('\n'), division_detail['question_id']) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, division_detail['question__name'], process_list(division_detail['value'].split('\n'), division_detail['question_id'])) |
|
|
if other_detail and other_detail['value'].strip(): |
|
|
if other_detail and other_detail['value'].strip(): |
|
|
tags.append(first_column + other_detail['question__name'] + second_column + process_list(other_detail['value'].split('\n'), other_detail['question_id']) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, other_detail['question__name'], process_list(other_detail['value'].split('\n'), other_detail['question_id'])) |
|
|
|
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
return tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag |
|
|
@register.simple_tag |
|
|
@ -409,10 +409,7 @@ def prequal_tag(source): |
|
|
Reformat prequalification step |
|
|
Reformat prequalification step |
|
|
Also show/hide optional questions |
|
|
Also show/hide optional questions |
|
|
""" |
|
|
""" |
|
|
tags = [] |
|
|
|
|
|
first_column = '<tr><td width="75%" style="padding-right: 5%">' |
|
|
|
|
|
second_column = '</td><td width="25%">' |
|
|
|
|
|
end_tag = '</td></tr>' |
|
|
|
|
|
|
|
|
tags = '' |
|
|
|
|
|
|
|
|
marriage_status = lived_in_bc = live_at_least_year = separation_date = try_reconcile = reconciliation_period = None |
|
|
marriage_status = lived_in_bc = live_at_least_year = separation_date = try_reconcile = reconciliation_period = None |
|
|
children_of_marriage = number_children_under_19 = number_children_over_19 = financial_support = certificate = provide_later = None |
|
|
children_of_marriage = number_children_under_19 = number_children_over_19 = financial_support = certificate = provide_later = None |
|
|
@ -456,39 +453,39 @@ def prequal_tag(source): |
|
|
divorce_reason['value'] = 'Lived apart for one year' |
|
|
divorce_reason['value'] = 'Lived apart for one year' |
|
|
|
|
|
|
|
|
if marriage_status: |
|
|
if marriage_status: |
|
|
tags.append(first_column + marriage_status['question__name'] + second_column + marriage_status['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, marriage_status['question__name'], marriage_status['value']) |
|
|
if lived_in_bc: |
|
|
if lived_in_bc: |
|
|
tags.append(first_column + lived_in_bc['question__name'] + second_column + lived_in_bc['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, lived_in_bc['question__name'], lived_in_bc['value']) |
|
|
if live_at_least_year: |
|
|
if live_at_least_year: |
|
|
tags.append(first_column + live_at_least_year['question__name'] + second_column + live_at_least_year['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, live_at_least_year['question__name'], live_at_least_year['value']) |
|
|
if separation_date: |
|
|
if separation_date: |
|
|
tags.append(first_column + separation_date['question__name'] + second_column + separation_date['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, separation_date['question__name'], separation_date['value']) |
|
|
if try_reconcile: |
|
|
if try_reconcile: |
|
|
tags.append(first_column + try_reconcile['question__name'] + second_column + try_reconcile['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, try_reconcile['question__name'], try_reconcile['value']) |
|
|
if try_reconcile and try_reconcile['value'] == 'YES' and reconciliation_period: |
|
|
if try_reconcile and try_reconcile['value'] == 'YES' and reconciliation_period: |
|
|
tags.append(first_column + reconciliation_period['question__name'] + second_column + reconciliation_period_reformat(reconciliation_period['value']) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, reconciliation_period['question__name'], reconciliation_period_reformat(reconciliation_period['value'])) |
|
|
if children_of_marriage: |
|
|
if children_of_marriage: |
|
|
tags.append(first_column + children_of_marriage['question__name'] + second_column + children_of_marriage['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, children_of_marriage['question__name'], children_of_marriage['value']) |
|
|
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_under_19: |
|
|
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_under_19: |
|
|
tags.append(first_column + number_children_under_19['question__name'] + second_column + number_children_under_19['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, number_children_under_19['question__name'], number_children_under_19['value']) |
|
|
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19: |
|
|
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19: |
|
|
tags.append(first_column + number_children_over_19['question__name'] + second_column + number_children_over_19['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, number_children_over_19['question__name'], number_children_over_19['value']) |
|
|
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19 and financial_support and financial_support['value']: |
|
|
if children_of_marriage and children_of_marriage['value'] == 'YES' and number_children_over_19 and financial_support and financial_support['value']: |
|
|
tags.append(first_column + financial_support['question__name'] + second_column + '<br>'.join(json.loads(financial_support['value'])) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, financial_support['question__name'], '<br>'.join(json.loads(financial_support['value']))) |
|
|
if certificate: |
|
|
if certificate: |
|
|
tags.append(first_column + certificate['question__name'] + second_column + certificate['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, certificate['question__name'], certificate['value']) |
|
|
if certificate and certificate['value'] == 'NO' and provide_later: |
|
|
if certificate and certificate['value'] == 'NO' and provide_later: |
|
|
tags.append(first_column + provide_later['question__name'] + second_column + provide_later['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, provide_later['question__name'], provide_later['value']) |
|
|
if certificate and provide_later and certificate['value'] == 'NO' and provide_later['value'] == 'YES' and provide_later_reason: |
|
|
if certificate and provide_later and certificate['value'] == 'NO' and provide_later['value'] == 'YES' and provide_later_reason: |
|
|
tags.append(first_column + provide_later_reason['question__name'] + second_column + process_list(provide_later_reason['value'].split('\n'), provide_later_reason['question_id']) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, provide_later_reason['question__name'], process_list(provide_later_reason['value'].split('\n'), provide_later_reason['question_id'])) |
|
|
if certificate and provide_later and certificate['value'] == 'NO' and provide_later['value'] == 'NO' and not_provide_later_reason: |
|
|
if certificate and provide_later and certificate['value'] == 'NO' and provide_later['value'] == 'NO' and not_provide_later_reason: |
|
|
tags.append(first_column + not_provide_later_reason['question__name'] + second_column + process_list(not_provide_later_reason['value'].split('\n'), not_provide_later_reason['question_id']) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, not_provide_later_reason['question__name'], process_list(not_provide_later_reason['value'].split('\n'), not_provide_later_reason['question_id'])) |
|
|
if marriage_status and marriage_status['value'] == 'Living together in a marriage like relationship' and in_english: |
|
|
if marriage_status and marriage_status['value'] == 'Living together in a marriage like relationship' and in_english: |
|
|
tags.append(first_column + in_english['question__name'] + second_column + in_english['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, in_english['question__name'], in_english['value']) |
|
|
if divorce_reason: |
|
|
if divorce_reason: |
|
|
tags.append(first_column + divorce_reason['question__name'] + second_column + divorce_reason['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, divorce_reason['question__name'], divorce_reason['value']) |
|
|
|
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
return tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@register.simple_tag |
|
|
@register.simple_tag |
|
|
@ -497,10 +494,7 @@ def personal_info_tag(source): |
|
|
Reformat your information and your spouse step |
|
|
Reformat your information and your spouse step |
|
|
Also show/hide optional questions |
|
|
Also show/hide optional questions |
|
|
""" |
|
|
""" |
|
|
tags = [] |
|
|
|
|
|
first_column = '<tr><td width="75%" style="padding-right: 5%">' |
|
|
|
|
|
second_column = '</td><td width="25%">' |
|
|
|
|
|
end_tag = '</td></tr>' |
|
|
|
|
|
|
|
|
tags = '' |
|
|
|
|
|
|
|
|
name = other_name = other_name_list = last_name_born = last_name_before = None |
|
|
name = other_name = other_name_list = last_name_born = last_name_before = None |
|
|
birthday = occupation = lived_bc = moved_bc = None |
|
|
birthday = occupation = lived_bc = moved_bc = None |
|
|
@ -528,25 +522,33 @@ def personal_info_tag(source): |
|
|
moved_bc = item |
|
|
moved_bc = item |
|
|
|
|
|
|
|
|
if name: |
|
|
if name: |
|
|
tags.append(first_column + name['question__name'] + second_column + name['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, name['question__name'], name['value']) |
|
|
if other_name: |
|
|
if other_name: |
|
|
tags.append(first_column + other_name['question__name'] + second_column + other_name['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, other_name['question__name'], other_name['value']) |
|
|
if other_name and other_name['value'] == 'YES' and other_name_list: |
|
|
if other_name and other_name['value'] == 'YES' and other_name_list: |
|
|
tags.append(first_column + other_name_list['question__name'] + second_column + process_list(json.loads(other_name_list['value']), other_name_list['question_id']) + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, other_name_list['question__name'], process_list(json.loads(other_name_list['value']), other_name_list['question_id'])) |
|
|
if last_name_born: |
|
|
if last_name_born: |
|
|
tags.append(first_column + last_name_born['question__name'] + second_column + last_name_born['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, last_name_born['question__name'], last_name_born['value']) |
|
|
if last_name_before: |
|
|
if last_name_before: |
|
|
tags.append(first_column + last_name_before['question__name'] + second_column + last_name_before['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, last_name_before['question__name'], last_name_before['value']) |
|
|
if birthday: |
|
|
if birthday: |
|
|
tags.append(first_column + birthday['question__name'] + second_column + birthday['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, birthday['question__name'], birthday['value']) |
|
|
if occupation: |
|
|
if occupation: |
|
|
tags.append(first_column + occupation['question__name'] + second_column + occupation['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, occupation['question__name'], occupation['value']) |
|
|
if lived_bc and moved_bc and lived_bc['value'] == "Moved to B.C. on": |
|
|
if lived_bc and moved_bc and lived_bc['value'] == "Moved to B.C. on": |
|
|
tags.append(first_column + lived_bc['question__name'] + second_column + lived_bc['value'] + ' ' + moved_bc['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, lived_bc['question__name'], lived_bc['value'] + ' ' + moved_bc['value']) |
|
|
if lived_bc and lived_bc['value'] != "Moved to B.C. on" and lived_bc: |
|
|
if lived_bc and lived_bc['value'] != "Moved to B.C. on" and lived_bc: |
|
|
tags.append(first_column + lived_bc['question__name'] + second_column + lived_bc['value'] + end_tag) |
|
|
|
|
|
|
|
|
tags = format_table_data(tags, lived_bc['question__name'], lived_bc['value']) |
|
|
|
|
|
|
|
|
|
|
|
return tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ''.join(tags) |
|
|
|
|
|
|
|
|
def format_table_data(tags, question, response): |
|
|
|
|
|
return format_html( |
|
|
|
|
|
'{}<tr><td width="75%" style="padding-right: 5%">{}</td><td width="25%">{}</td></tr>', |
|
|
|
|
|
tags, |
|
|
|
|
|
question, |
|
|
|
|
|
response) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def reconciliation_period_reformat(lst): |
|
|
def reconciliation_period_reformat(lst): |
|
|
@ -559,5 +561,5 @@ def reconciliation_period_reformat(lst): |
|
|
lst = [] |
|
|
lst = [] |
|
|
period = "" |
|
|
period = "" |
|
|
for f_date, t_date in lst: |
|
|
for f_date, t_date in lst: |
|
|
period += "From " + f_date + " to " + t_date + "<br />" |
|
|
|
|
|
|
|
|
period = format_html('{}From {} to {}<br />', period, f_date, t_date) |
|
|
return period |
|
|
return period |