From c6c4d2b5043fded135ffe860b9b776fe0c6d10bb Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Thu, 1 Mar 2018 13:27:26 -0800 Subject: [PATCH] DIV-821: Reformatting free form text --- .../apps/core/templatetags/summary_format.py | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/edivorce/apps/core/templatetags/summary_format.py b/edivorce/apps/core/templatetags/summary_format.py index 526d464f..7652f66a 100644 --- a/edivorce/apps/core/templatetags/summary_format.py +++ b/edivorce/apps/core/templatetags/summary_format.py @@ -23,13 +23,7 @@ def reformat_value(source, question_key): except: if question_key == 'spouse_support_details' or question_key == 'other_orders_detail'\ or question_key == 'provide_certificate_later_reason' or question_key == 'not_provide_certificate_reason': - text_list = source.split('\n') - tag = ["') - return ''.join(tag) + return reformat_list(source) return source @@ -47,6 +41,19 @@ def process_list(lst, question_key): return ''.join(tag) +def reformat_list(source): + text_list = source.split('\n') + if len(text_list) > 1: + tag = ["') + return ''.join(tag) + else: + return text_list.pop() + + def format_row(question, response): return '{0}{1}'.format( question, response @@ -170,12 +177,15 @@ def format_children(context, source): tags.append(format_fact_sheet(question, fact_sheet_mapping[question])) else: + item = list(filter(lambda x: x['question_id'] == question, working_source)) + # skip child support order related questions if user did not select that option - if question in child_support_orders and context['derived']['wants_child_support'] is False: + if question in child_support_orders: + item = item.pop() + if context['derived']['wants_child_support'] is True: + tags.append(format_row(item['question__name'], reformat_list(item['value']))) continue - item = list(filter(lambda x: x['question_id'] == question, working_source)) - if len(item): item = item.pop() q_id = item['question_id']