diff --git a/README.md b/README.md
index 78c8dbef..7d6f7491 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@ To run this project in your development machine, follow these steps:
8. Start the [Weasyprint server](https://hub.docker.com/r/aquavitae/weasyprint/) server on port 5005
- 1. Bind the IP address 10.200.10.1 to the lo0 interface on your Mac computer. Weasyprint has been configured to use this IP address to request CSS files from Django *(You should only have to do this once)*.
+ 1. Bind the IP address 10.200.10.1 to the lo0 interface on your Mac computer. Weasyprint has been configured to use this IP address to request CSS files from Django.
```
sudo ifconfig lo0 alias 10.200.10.1/24
```
diff --git a/edivorce/apps/core/templates/partials/review_user_responses.html b/edivorce/apps/core/templates/partials/review_user_responses.html
index 14a5b16f..c3f6830b 100644
--- a/edivorce/apps/core/templates/partials/review_user_responses.html
+++ b/edivorce/apps/core/templates/partials/review_user_responses.html
@@ -1,6 +1,5 @@
{% load summary_format %}
{% if questions %}
-
{% if step == 'your_children' %}
@@ -11,7 +10,6 @@
{% format_children source=questions %}
-
{% else %}
diff --git a/edivorce/apps/core/templatetags/composites.py b/edivorce/apps/core/templatetags/composites.py
index 432755df..f28664a7 100644
--- a/edivorce/apps/core/templatetags/composites.py
+++ b/edivorce/apps/core/templatetags/composites.py
@@ -5,6 +5,7 @@ users full responses.
from django import template
from .format_utils import date_formatter
+from django.utils.html import format_html
register = template.Library()
@@ -17,7 +18,7 @@ def effective_date(context):
if context['responses'].get('divorce_take_effect_on', '') == 'specific date':
date = context['responses'].get('divorce_take_effect_on_specific_date', '')
if date == '':
- effective = ' '
+ effective = format_html(' ')
else:
effective = date_formatter(date)
return effective
diff --git a/edivorce/apps/core/templatetags/format_utils.py b/edivorce/apps/core/templatetags/format_utils.py
index 4cfdd181..9af81143 100644
--- a/edivorce/apps/core/templatetags/format_utils.py
+++ b/edivorce/apps/core/templatetags/format_utils.py
@@ -6,6 +6,7 @@ import locale
import re
from django import template
+from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.timesince import timesince
@@ -48,7 +49,7 @@ def response(field, size=None, trail='', as_date=False):
if field.strip():
return '%s%s' % (date_formatter(field) if as_date else field, trail)
style = ('min-width: %spx' % size) if size is not None else ''
- return ' ' % style
+ return format_html(' ', style)
@register.simple_tag()
diff --git a/edivorce/apps/core/templatetags/input_field.py b/edivorce/apps/core/templatetags/input_field.py
index 46f9e005..d7761e2b 100644
--- a/edivorce/apps/core/templatetags/input_field.py
+++ b/edivorce/apps/core/templatetags/input_field.py
@@ -2,6 +2,7 @@ from datetime import datetime
import json
from django import template
+from django.utils.html import format_html
from ..models import UserResponse
@@ -36,14 +37,25 @@ def money_input_field(context, input_type='number', name='', value_src=None, val
if kwargs.get('step', None):
step = kwargs.get('step')
- tag = [' ')
- return ''.join(tag)
+ attributes = additional_attributes(**kwargs)
+ tag = format_html(
+ '{}{} />',
+ tag,
+ attributes)
+
+ return tag
@register.simple_tag(takes_context=True)
@@ -52,18 +64,14 @@ def input_field(context, type, name='', value='', multiple='', **kwargs):
Usage: when specifying data attributes in templates, use "data_" instead of "data-".
"""
if type == "textarea":
- tag = ['')
+ value = context.get(name, '')
+ tag = format_html(
+ '',
+ name,
+ attributes,
+ value)
else:
# set initial value for textbox
if type == "text":
@@ -83,33 +91,44 @@ def input_field(context, type, name='', value='', multiple='', **kwargs):
pass # conversion to current format not needed
elif type == "number":
value = context.get(name, '')
- tag = [' ')
+ tag = format_html(
+ ' ',
+ type,
+ name,
+ value,
+ attributes,
+ checked)
- return ''.join(tag)
+ return tag
-def additional_attributes(tag, **kwargs):
+def additional_attributes(**kwargs):
+ attributes = ''
for key, data_val in kwargs.items():
if str.startswith(key, 'data_'):
key = str.replace(key, 'data_', 'data-')
- tag.append(' ' + key + '="' + data_val + '"')
- return tag
+ attributes = format_html(
+ '{} {}="{}"',
+ attributes,
+ key,
+ data_val)
+ return attributes
-@register.assignment_tag
+@register.simple_tag
def check_list(source, value):
"""
Check if given value is in the given source
@@ -120,7 +139,7 @@ def check_list(source, value):
return False
-@register.assignment_tag
+@register.simple_tag
def multiple_values_to_list(source):
try:
return json.loads(source)
diff --git a/edivorce/apps/core/templatetags/step_order.py b/edivorce/apps/core/templatetags/step_order.py
index e22c7212..6eda0ce9 100644
--- a/edivorce/apps/core/templatetags/step_order.py
+++ b/edivorce/apps/core/templatetags/step_order.py
@@ -1,7 +1,7 @@
from django import template
import json
-from django.core.urlresolvers import reverse
+from django.urls import reverse
from ..utils.template_step_order import template_step_order, template_sub_step_order, get_step_name, \
get_step_or_sub_step_name
diff --git a/edivorce/apps/core/templatetags/summary_format.py b/edivorce/apps/core/templatetags/summary_format.py
index 59b43e1a..a7476ed8 100644
--- a/edivorce/apps/core/templatetags/summary_format.py
+++ b/edivorce/apps/core/templatetags/summary_format.py
@@ -3,7 +3,8 @@ from collections import OrderedDict
from django import template
import json
-from django.core.urlresolvers import reverse
+from django.urls import reverse
+from django.utils.html import format_html, format_html_join
register = template.Library()
@@ -28,67 +29,58 @@ def reformat_value(source, question_key):
def process_list(lst, question_key):
- tag = [""]
if question_key.startswith('other_name_'):
- for alias_type, value in lst:
- if value:
- tag.append('' + alias_type + ' ' + value + ' ')
+ list_items = format_html_join(
+ '\n',
+ '{} {} ',
+ ((alias_type, value) for alias_type, value in lst if value))
else:
- for value in lst:
- if value and not value.isspace():
- tag.append('' + str(value) + ' ')
- tag.append(' ')
- return ''.join(tag)
+ list_items = format_html_join(
+ '\n',
+ '{0} ',
+ ((value, '') for value in lst if value and not value.isspace()))
+ tag = format_html(
+ '',
+ list_items)
+
+ return tag
def reformat_list(source):
text_list = source.split('\n')
if len(text_list) > 1:
- tag = [""]
- for value in text_list:
- if value and not value.isspace():
- tag.append('' + value + ' ')
- tag.append(' ')
- return ''.join(tag)
+ list_items = format_html_join(
+ '\n',
+ '{0} ',
+ ((value, '') for value in text_list if value))
+ tag = format_html(
+ '',
+ list_items)
+ return tag
else:
return text_list.pop()
def format_row(question, response):
- return '{0} {1} '.format(
- question, response
- )
+ return format_html(
+ '{0} {1} ',
+ question,
+ response)
def format_review_row_heading(title, style=""):
- return '{0} '.format(title, style)
-
-
-def format_head(headings):
- if len(headings) == 0:
- return '', []
-
- tags = [""]
- head_order = list()
- for key in headings[0].keys():
- tags.append('{} '.format(key.replace('_', ' ').title()))
- head_order.append(key)
- tags.append(' ')
- return ''.join(tags), head_order
-
-
-def process_fact_sheet_list(data, header):
- tags = list()
- for item in data:
- tags.append('')
- for key in header:
- tags.append('{} '.format(item.get(key, '')))
- tags.append(' ')
- return ''.join(tags)
+ return format_html(
+ '{0} ',
+ title,
+ style)
def format_fact_sheet(title, url, style=''):
- return '{2} '.format(style, url, title)
+ return format_html(
+ '{2} ',
+ style,
+ url,
+ title)
@register.simple_tag(takes_context=True)
@@ -152,12 +144,14 @@ def format_children(context, source):
child_support_orders = {'have_court_order', 'what_parenting_arrangements', 'order_respecting_arrangement', 'order_for_child_support'}
- tags = []
+ tags = ' '
# process mapped questions first
working_source = source.copy()
- tags.append(' ')
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:
if question in fact_sheet_mapping:
@@ -177,7 +171,10 @@ def format_children(context, source):
show_fact_sheet = True
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:
item = list(filter(lambda x: x['question_id'] == question, working_source))
@@ -187,7 +184,10 @@ def format_children(context, source):
item = item.pop()
if context['derived']['wants_child_support'] is True:
# 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
if len(item):
@@ -197,12 +197,14 @@ def format_children(context, source):
if q_id == 'claimant_children':
child_counter = 1
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
else:
value = item['value']
@@ -220,16 +222,15 @@ def format_children(context, source):
value = reformat_list(value)
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):
if len(value):
- tags.append(format_row(question_name, value))
+ tags = format_html('{}{}', tags, format_row(question_name, value))
else:
- tags.append(format_row(question_name, value))
- tags.append(' ')
- tags.append('')
- tags.append(' ')
- return ''.join(tags)
+ tags = format_html('{}{}', tags, format_row(question_name, value))
+ tags = format_html('{} ', tags)
+ tags = format_html('{} ', tags)
+ return tags
@register.simple_tag
@@ -238,10 +239,7 @@ def combine_address(source):
Reformat address to combine them into one cell with multiple line
Also show/hide optional questions
"""
- tags = []
- first_column = ''
- second_column = ' '
- end_tag = ' '
+ tags = ''
address_you = ""
fax_you = ""
@@ -258,7 +256,7 @@ def combine_address(source):
if "email" not in q_id and "fax" not in q_id:
if q_id == "address_to_send_official_document_country_you":
continue
- address_you += item["value"] + ' '
+ address_you = format_html('{}{} ', address_you, item["value"])
elif "fax" in q_id:
fax_you = item["value"]
elif "email" in q_id:
@@ -267,7 +265,7 @@ def combine_address(source):
if "email" not in q_id and "fax" not in q_id:
if q_id == "address_to_send_official_document_country_spouse":
continue
- address_spouse += item["value"] + ' '
+ address_spouse = format_html('{}{} ', address_spouse, item["value"])
elif "fax" in q_id:
fax_spouse = item["value"]
elif "email" in q_id:
@@ -281,27 +279,21 @@ def combine_address(source):
effective_date = item['value']
if address_you != "":
- tags.append(first_column + "What is the best address to send you official court documents?"
- + 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 != "":
- tags.append(first_column + "Fax" + second_column + fax_you + end_tag)
-
+ tags = format_table_data(tags, "Fax", fax_you)
if email_you != "":
- tags.append(first_column + "Email" + second_column + email_you + end_tag)
-
+ tags = format_table_data(tags, "Email", email_you)
if address_spouse != "":
- tags.append(first_column + "What is the best address to send your spouse official court documents?"
- + 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 != "":
- tags.append(first_column + "Fax" + second_column + fax_spouse + end_tag)
-
+ tags = format_table_data(tags, "Fax", fax_spouse)
if email_spouse != "":
- tags.append(first_column + "Email" + second_column + email_spouse + end_tag)
-
+ tags = format_table_data(tags, "Email", email_spouse)
if effective_date != "":
- tags.append(first_column + "Divorce is to take effect on " + 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)
@@ -311,10 +303,7 @@ def marriage_tag(context, source):
Also show/hide optional questions
"""
show_all = False
- tags = []
- first_column = ''
- second_column = ' '
- end_tag = ' '
+ tags = ''
marriage_location = ""
married_date = ""
@@ -348,7 +337,7 @@ def marriage_tag(context, source):
elif q_id.startswith('where_were_you_married'):
if value == 'Other':
continue
- marriage_location += value + ' '
+ marriage_location = format_html('{}{} ', marriage_location, value)
elif q_id == 'marital_status_before_you':
marital_status_you_q = q_name
marital_status_you = value
@@ -357,17 +346,17 @@ def marriage_tag(context, source):
marital_status_spouse = value
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 != "":
- 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 != "":
- 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 != "":
- 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 != "":
- 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
@@ -376,10 +365,7 @@ def property_tag(source):
Reformat your_property and debt step
Also show/hide optional questions
"""
- tags = []
- first_column = ''
- second_column = ' '
- end_tag = ' '
+ tags = ''
division = division_detail = other_detail = None
@@ -394,13 +380,13 @@ def property_tag(source):
other_detail = item
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:
- 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():
- 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
@@ -409,10 +395,7 @@ def prequal_tag(source):
Reformat prequalification step
Also show/hide optional questions
"""
- tags = []
- first_column = ''
- second_column = ' '
- end_tag = ' '
+ tags = ''
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
@@ -456,39 +439,39 @@ def prequal_tag(source):
divorce_reason['value'] = 'Lived apart for one year'
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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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']:
- tags.append(first_column + financial_support['question__name'] + second_column + ' '.join(json.loads(financial_support['value'])) + end_tag)
+ tags = format_table_data(tags, financial_support['question__name'], ' '.join(json.loads(financial_support['value'])))
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:
- 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:
- 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:
- 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:
- 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:
- 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
@@ -497,10 +480,7 @@ def personal_info_tag(source):
Reformat your information and your spouse step
Also show/hide optional questions
"""
- tags = []
- first_column = ''
- second_column = ' '
- end_tag = ' '
+ tags = ''
name = other_name = other_name_list = last_name_born = last_name_before = None
birthday = occupation = lived_bc = moved_bc = None
@@ -528,25 +508,33 @@ def personal_info_tag(source):
moved_bc = item
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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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":
- 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:
- 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(
+ '{}{} {} ',
+ tags,
+ question,
+ response)
def reconciliation_period_reformat(lst):
@@ -559,5 +547,5 @@ def reconciliation_period_reformat(lst):
lst = []
period = ""
for f_date, t_date in lst:
- period += "From " + f_date + " to " + t_date + " "
+ period = format_html('{}From {} to {} ', period, f_date, t_date)
return period
diff --git a/edivorce/apps/core/urls.py b/edivorce/apps/core/urls.py
index e3c9d920..9235d716 100644
--- a/edivorce/apps/core/urls.py
+++ b/edivorce/apps/core/urls.py
@@ -2,9 +2,6 @@ from django.conf.urls import url
from .views import main, system, pdf, api, localdev
-handler404 = 'core.views.main.page_not_found'
-handler500 = 'core.views.main.server_error'
-
urlpatterns = [
# url(r'^guide$', styleguide.guide),
url(r'^api/response$', api.UserResponseHandler.as_view()),
diff --git a/edivorce/apps/core/utils/step_completeness.py b/edivorce/apps/core/utils/step_completeness.py
index 7f984856..757d7ca2 100644
--- a/edivorce/apps/core/utils/step_completeness.py
+++ b/edivorce/apps/core/utils/step_completeness.py
@@ -1,4 +1,4 @@
-from django.core.urlresolvers import reverse
+from django.urls import reverse
from edivorce.apps.core.models import Question
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping, pre_qual_step_question_mapping
diff --git a/edivorce/apps/core/utils/user_response.py b/edivorce/apps/core/utils/user_response.py
index fedd0820..884a49f4 100644
--- a/edivorce/apps/core/utils/user_response.py
+++ b/edivorce/apps/core/utils/user_response.py
@@ -1,6 +1,7 @@
from edivorce.apps.core.models import UserResponse, Question
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping
from edivorce.apps.core.utils.step_completeness import evaluate_numeric_condition
+from collections import OrderedDict
def get_responses_from_db(bceid_user):
@@ -85,7 +86,7 @@ def get_responses_from_db_grouped_by_steps(bceid_user, hide_failed_conditionals=
def get_responses_from_session(request):
- return sorted(request.session.items())
+ return OrderedDict(sorted(request.session.items()))
def get_responses_from_session_grouped_by_steps(request):
diff --git a/edivorce/apps/core/views/main.py b/edivorce/apps/core/views/main.py
index a739fffe..dc699528 100644
--- a/edivorce/apps/core/views/main.py
+++ b/edivorce/apps/core/views/main.py
@@ -1,7 +1,7 @@
import datetime
from django.conf import settings
-from django.shortcuts import render, redirect, render_to_response
+from django.shortcuts import render, redirect
from django.utils import timezone
from django.template import RequestContext
@@ -72,8 +72,8 @@ def incomplete(request):
missed_questions = get_formatted_incomplete_list(missed_question_keys)
responses_dict = get_responses_from_session(request)
- responses_dict.append(('debug', settings.DEBUG, ))
- responses_dict.append(('missed_questions', missed_questions, ))
+ responses_dict['debug'] = settings.DEBUG
+ responses_dict['missed_questions'] = missed_questions
return render(request, 'incomplete.html', context=responses_dict)
@@ -204,20 +204,14 @@ def page_not_found(request):
"""
404 Error Page
"""
- response = render_to_response('404.html', {},
- context_instance=RequestContext(request))
- response.status_code = 404
- return response
+ return render(request, '404.html', status=404)
def server_error(request):
"""
500 Error Page
"""
- response = render_to_response('500.html', {},
- context_instance=RequestContext(request))
- response.status_code = 500
- return response
+ return render(request, '500.html', status=500)
def legal(request):
diff --git a/edivorce/apps/core/views/system.py b/edivorce/apps/core/views/system.py
index 72b9eb58..abdd4720 100644
--- a/edivorce/apps/core/views/system.py
+++ b/edivorce/apps/core/views/system.py
@@ -1,7 +1,7 @@
from django.conf import settings
from django.http import HttpResponse, Http404
from django.shortcuts import render, redirect
-from django.core.urlresolvers import reverse
+from django.urls import reverse
from edivorce.apps.core.models import Question
diff --git a/edivorce/settings/base.py b/edivorce/settings/base.py
index c5bdb0ef..28345194 100644
--- a/edivorce/settings/base.py
+++ b/edivorce/settings/base.py
@@ -56,7 +56,6 @@ MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'edivorce.apps.core.middleware.bceid_middleware.BceidMiddleware',
@@ -144,3 +143,5 @@ DEBUG_TOOLBAR_CONFIG = {
}
SECURE_BROWSER_XSS_FILTER = True
+
+LOGOUT_URL = '/accounts/logout/'
diff --git a/edivorce/settings/local.py b/edivorce/settings/local.py
index 64503673..8b215fed 100644
--- a/edivorce/settings/local.py
+++ b/edivorce/settings/local.py
@@ -25,3 +25,5 @@ PROXY_BASE_URL = ''
SASS_PROCESSOR_ENABLED = True
SASS_PROCESSOR_ROOT = PROJECT_ROOT + '/edivorce/apps/core/static'
SASS_OUTPUT_STYLE = 'compressed'
+
+LOGOUT_URL = '/accounts/logout/'
diff --git a/edivorce/urls.py b/edivorce/urls.py
index 73bfa2d0..2e09695a 100644
--- a/edivorce/urls.py
+++ b/edivorce/urls.py
@@ -1,6 +1,7 @@
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
+from .apps.core.views import main
urlpatterns = []
@@ -12,3 +13,6 @@ if settings.ENVIRONMENT in ['localdev', 'minishift']:
urlpatterns.append(url(r'^admin/', admin.site.urls))
urlpatterns.append(url(r'^', include('edivorce.apps.core.urls')))
+
+handler404 = main.page_not_found
+handler500 = main.server_error
diff --git a/requirements.txt b/requirements.txt
index 3d4c2e1e..bf2abfba 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-Django<1.9
+Django<1.12
django-compressor==2.1
django-crispy-forms==1.6.1
django-debug-toolbar==1.9
diff --git a/wsgi.py b/wsgi.py
index 30e572d4..ea1040ac 100644
--- a/wsgi.py
+++ b/wsgi.py
@@ -15,6 +15,7 @@ from django.core.management import execute_from_command_line
# check if the app is running on OpenShift
if not os.environ.get('OPENSHIFT_BUILD_NAMESPACE', False):
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "edivorce.settings.local")
+ is_local = True
else:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "edivorce.settings.openshift")
@@ -32,6 +33,7 @@ if platform_name == "Windows":
question_fixture_path = os.path.realpath("./edivorce/fixtures/Question.json")
# load the Question fixture
-execute_from_command_line(['manage.py', 'loaddata', question_fixture_path])
+if not is_local:
+ execute_from_command_line(['manage.py', 'loaddata', question_fixture_path])
application = get_wsgi_application()