From bc28748eefaa0a4c2b431dbe49cfac9c271c99b5 Mon Sep 17 00:00:00 2001 From: Benard Ebinu Date: Wed, 17 Jan 2018 16:11:57 -0800 Subject: [PATCH] DIV-724: formatting children into review table --- .../partials/review_user_responses.html | 2 ++ .../core/templates/question/13_review.html | 2 +- .../apps/core/templatetags/summary_format.py | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/edivorce/apps/core/templates/partials/review_user_responses.html b/edivorce/apps/core/templates/partials/review_user_responses.html index 5c27dbbf..1cc1d061 100644 --- a/edivorce/apps/core/templates/partials/review_user_responses.html +++ b/edivorce/apps/core/templates/partials/review_user_responses.html @@ -18,6 +18,8 @@ {% marriage_tag source=questions %} {% elif step == 'other_questions' %} {% combine_address source=questions %} + {% elif step == 'your_children' %} + {% format_children source=questions %} {% else %} {% for question in questions %} diff --git a/edivorce/apps/core/templates/question/13_review.html b/edivorce/apps/core/templates/question/13_review.html index 8da58e33..5df6f4c7 100644 --- a/edivorce/apps/core/templates/question/13_review.html +++ b/edivorce/apps/core/templates/question/13_review.html @@ -117,7 +117,7 @@
- {% include "partials/review_user_responses.html" with questions=your_children %} + {% include "partials/review_user_responses.html" with questions=your_children step='your_children' %}
diff --git a/edivorce/apps/core/templatetags/summary_format.py b/edivorce/apps/core/templatetags/summary_format.py index 7ed4ce87..46d445cc 100644 --- a/edivorce/apps/core/templatetags/summary_format.py +++ b/edivorce/apps/core/templatetags/summary_format.py @@ -43,6 +43,33 @@ def process_list(lst, question_key): return ''.join(tag) +def format_row(question, response): + return '{0}{1}'.format( + question, response + ) + + +@register.simple_tag +def format_children(source): + """ + + :param source: + :return: + """ + tags = [] + for item in source: + q_id = item['question_id'] + if q_id == 'claimant_children': + tags.append(format_row('{}'.format(item['question__name']), '')) + for child in json.loads(item['value']): + 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 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'])) + return ''.join(tags) + + @register.simple_tag def combine_address(source): """