From a46dea03c9ebfdf7cb947d7367d59ea33ea63e08 Mon Sep 17 00:00:00 2001 From: Charles Shin Date: Fri, 7 Jul 2017 16:25:00 -0700 Subject: [PATCH] DIV-478: Updated PDF date format to be dd/mmm/yyyy --- edivorce/apps/core/templates/pdf/form1.html | 38 +++++++++---------- edivorce/apps/core/templates/pdf/form35.html | 4 +- edivorce/apps/core/templates/pdf/form38.html | 5 ++- .../apps/core/templates/pdf/form38_we.html | 5 ++- edivorce/apps/core/templates/pdf/form52.html | 5 ++- .../apps/core/templatetags/format_utils.py | 11 ++++++ 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/edivorce/apps/core/templates/pdf/form1.html b/edivorce/apps/core/templates/pdf/form1.html index 8433417e..e1a00e13 100644 --- a/edivorce/apps/core/templates/pdf/form1.html +++ b/edivorce/apps/core/templates/pdf/form1.html @@ -55,19 +55,19 @@ Claimant 1 and Claimant 2: - {% else %} fa-square-o" aria-hidden="true"> {% endif %} began to live together in a marriage-like relationship on [dd/mm/yyyy] - {% if responses.when_were_you_live_married_like %} {{ responses.when_were_you_live_married_like }} {% else %}   {% endif %} + {% else %} fa-square-o" aria-hidden="true"> {% endif %} began to live together in a marriage-like relationship on [dd/mmm/yyyy] + {% if responses.when_were_you_live_married_like %} {{ responses.when_were_you_live_married_like|date_formatter }} {% else %}   {% endif %} - {% else %} fa-square-o" aria-hidden="true"> {% endif %} were married on [dd/mm/yyyy] - {% if responses.when_were_you_married %} {{ responses.when_were_you_married }} {% else %}   {% endif %} + {% else %} fa-square-o" aria-hidden="true"> {% endif %} were married on [dd/mmm/yyyy] + {% if responses.when_were_you_married %} {{ responses.when_were_you_married|date_formatter }} {% else %}   {% endif %} - {% else %} fa-square-o" aria-hidden="true"> {% endif %} separated on [dd/mm/yyyy] - {% if responses.separation_date %} {{ responses.separation_date }} {% else %}   {% endif %} + {% else %} fa-square-o" aria-hidden="true"> {% endif %} separated on [dd/mmm/yyyy] + {% if responses.separation_date %} {{ responses.separation_date|date_formatter }} {% else %}   {% endif %} - were divorced from each other by order made on [dd/mm/yyyy] + were divorced from each other by order made on [dd/mmm/yyyy]   @@ -93,18 +93,18 @@ Claimant 2 - Birthdate: [dd/mm/yyyy] - {% if responses.birthday_you %} {{ responses.birthday_you }} {% else %}   {% endif %} - {% if responses.birthday_spouse %} {{ responses.birthday_spouse }} {% else %}   {% endif %} + Birthdate: [dd/mmm/yyyy] + {% if responses.birthday_you %} {{ responses.birthday_you|date_formatter }} {% else %}   {% endif %} + {% if responses.birthday_spouse %} {{ responses.birthday_spouse|date_formatter }} {% else %}   {% endif %} - Ordinarily resident in British Columbia since: [dd/mm/yyyy] + Ordinarily resident in British Columbia since: [dd/mmm/yyyy] {% if responses.lived_in_bc_you == 'Since birth' %} {{ responses.birthday_you }} - {% elif responses.lived_in_bc_you == 'Moved to B.C. on' %} {{ responses.moved_to_bc_date_you }} + {% elif responses.lived_in_bc_you == 'Moved to B.C. on' %} {{ responses.moved_to_bc_date_you|date_formatter }} {% elif responses.lived_in_bc_you == 'Do not live in B.C.' %} {% else %}   {% endif %} {% if responses.lived_in_bc_spouse == 'Since birth' %} {{ responses.birthday_spouse }} - {% elif responses.lived_in_bc_spouse == 'Moved to B.C. on' %} {{ responses.moved_to_bc_date_spouse }} + {% elif responses.lived_in_bc_spouse == 'Moved to B.C. on' %} {{ responses.moved_to_bc_date_spouse|date_formatter }} {% elif responses.lived_in_bc_spouse == 'Does not live in B.C.' %} {% else %}   {% endif %} @@ -147,7 +147,7 @@ B. Grounds for claim for divorce: - (i) {% else %} fa-square-o" aria-hidden="true"> {% endif %} Claimant 1 and Claimant 2 have lived separate and apart since {% if responses.separation_date %} {{ responses.separation_date }} {% else %}  {% endif %} + (i) {% else %} fa-square-o" aria-hidden="true"> {% endif %} Claimant 1 and Claimant 2 have lived separate and apart since {% if responses.separation_date %} {{ responses.separation_date|date_formatter }} {% else %}  {% endif %} AND @@ -243,7 +243,7 @@ - + @@ -390,7 +390,7 @@ - + - + - + - + - + - +
Full name: Birth date:
[dd/mm/yyyy]
Birth date:
[dd/mmm/yyyy]
Resides with:
[dd/mm/yyyy][dd/mmm/yyyy]

@@ -414,7 +414,7 @@

[dd/mm/yyyy][dd/mmm/yyyy]

@@ -457,7 +457,7 @@

[dd/mm/yyyy][dd/mmm/yyyy]

@@ -505,7 +505,7 @@

[dd/mm/yyyy][dd/mmm/yyyy]

diff --git a/edivorce/apps/core/templates/pdf/form35.html b/edivorce/apps/core/templates/pdf/form35.html index ddd471ea..7f790d3e 100644 --- a/edivorce/apps/core/templates/pdf/form35.html +++ b/edivorce/apps/core/templates/pdf/form35.html @@ -101,7 +101,7 @@

[dd/mm/yyyy][dd/mmm/yyyy]

Signature of

@@ -135,7 +135,7 @@
[dd/mm/yyyy][dd/mmm/yyyy]

Signature of

diff --git a/edivorce/apps/core/templates/pdf/form38.html b/edivorce/apps/core/templates/pdf/form38.html index b5646d60..bb00f358 100644 --- a/edivorce/apps/core/templates/pdf/form38.html +++ b/edivorce/apps/core/templates/pdf/form38.html @@ -1,5 +1,6 @@ {% load static %} {% load input_field %} +{% load format_utils %} @@ -81,11 +82,11 @@

5 I was living separate and apart from my spouse at the start of this family law case and I have lived separate and apart from my spouse since - {% if responses.separation_date %} {{ responses.separation_date }}{% else %} {% endif %}, except: + {% if responses.separation_date %} {{ responses.separation_date|date_formatter }}{% else %} {% endif %}, except: {% multiple_values_to_list source=responses.reconciliation_period as periods %} {% if periods != '[]' and responses.try_reconcile_after_separated == 'YES' %} {% for period in periods %} - from {{ period | first }} to {{ period | last }}{% if not forloop.last %}, {% endif %} + from {{ period | first |date_formatter }} to {{ period | last |date_formatter }}{% if not forloop.last %}, {% endif %} {% endfor %}. {% else %}{% endif %}

diff --git a/edivorce/apps/core/templates/pdf/form38_we.html b/edivorce/apps/core/templates/pdf/form38_we.html index 60475a3d..cef6d941 100644 --- a/edivorce/apps/core/templates/pdf/form38_we.html +++ b/edivorce/apps/core/templates/pdf/form38_we.html @@ -1,5 +1,6 @@ {% load static %} {% load input_field %} +{% load format_utils %} @@ -91,11 +92,11 @@

5 Claimant 1 and claimant 2 were living separate and apart from each other at the start of this family law case and claimant 1 and claimant 2 have lived separate and apart from each other since - {% if responses.separation_date %} {{ responses.separation_date }}{% else %} {% endif %}, except: + {% if responses.separation_date %} {{ responses.separation_date|date_formatter }}{% else %} {% endif %}, except: {% multiple_values_to_list source=responses.reconciliation_period as periods %} {% if periods != '[]' and responses.try_reconcile_after_separated == 'YES' %} {% for period in periods %} - from {{ period | first }} to {{ period | last }}{% if not forloop.last %}, {% endif %} + from {{ period | first|date_formatter }} to {{ period | last|date_formatter }}{% if not forloop.last %}, {% endif %} {% endfor %}. {% else %}{% endif %}

diff --git a/edivorce/apps/core/templates/pdf/form52.html b/edivorce/apps/core/templates/pdf/form52.html index d07d758f..eaeebe57 100644 --- a/edivorce/apps/core/templates/pdf/form52.html +++ b/edivorce/apps/core/templates/pdf/form52.html @@ -1,5 +1,6 @@ {% load static %} {% load input_field %} +{% load format_utils %} @@ -90,11 +91,11 @@ {% if responses.where_were_you_married_country == 'Other' %} {{ responses.where_were_you_married_other_country }} {% else %} {{responses.where_were_you_married_country}}{% endif %} {% else %}{% endif %} - on {% if responses.when_were_you_married %} {{ responses.when_were_you_married }} {% else %}{% endif %}, are divorced from each other, + on {% if responses.when_were_you_married %} {{ responses.when_were_you_married|date_formatter }} {% else %}{% endif %}, are divorced from each other, {% if responses.divorce_take_effect_on == 'the 31st day after the date of this order' %} the divorce to take effect on the 31st day after the date of this order. {% else %} - the divorce to take effect on {% if responses.divorce_take_effect_on_specific_date %}{{ responses.divorce_take_effect_on_specific_date }}{% else %}{% endif %}. + the divorce to take effect on {% if responses.divorce_take_effect_on_specific_date %}{{ responses.divorce_take_effect_on_specific_date|date_formatter }}{% else %}{% endif %}. {% endif %}

diff --git a/edivorce/apps/core/templatetags/format_utils.py b/edivorce/apps/core/templatetags/format_utils.py index 76fb64fb..8cfdf856 100644 --- a/edivorce/apps/core/templatetags/format_utils.py +++ b/edivorce/apps/core/templatetags/format_utils.py @@ -1,4 +1,5 @@ from django import template +from datetime import datetime import re from django.utils.safestring import mark_safe @@ -12,3 +13,13 @@ def linebreaksul(value): lines = re.split('\n', value) lines = ['
  • %s
  • ' % line for line in lines if line and not line.isspace()] return mark_safe('
      %s
    ' % '\n'.join(lines)) + + +@register.filter +def date_formatter(value): + """ + Changes date format from dd/mm/yyyy to dd/mmm/yyyy + """ + d = datetime.strptime(value, '%d/%m/%Y') + return d.strftime('%d %b %Y') +