Browse Source

DIV-240: Updated complete state for each step

pull/160/head
Charles Shin 8 years ago
parent
commit
ee6d05dbed
7 changed files with 395 additions and 57 deletions
  1. +34
    -34
      edivorce/apps/core/templates/overview.html
  2. +2
    -1
      edivorce/apps/core/templates/partials/review_user_responses.html
  3. +30
    -19
      edivorce/apps/core/templates/progress.html
  4. +255
    -0
      edivorce/apps/core/tests.py
  5. +32
    -0
      edivorce/apps/core/utils/question_step_mapping.py
  6. +39
    -3
      edivorce/apps/core/utils/user_response.py
  7. +3
    -0
      edivorce/settings/local.py

+ 34
- 34
edivorce/apps/core/templates/overview.html View File

@ -15,65 +15,65 @@
<span class="progress-content">Qualifying Questions</span> <span class="progress-content">Qualifying Questions</span>
<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> <span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span>
</a> </a>
<a href="{% url 'question_steps' 'orders' %}" class="progress-question">
<a href="{% url 'question_steps' '01_orders' %}" class="progress-question {% if step_status.which_orders == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-commenting" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-commenting" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 1</small><br />What Are You Asking For?</span> <span class="progress-content"><small>Step 1</small><br />What Are You Asking For?</span>
{% if step_status.which_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.which_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.which_orders == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'claimant' %}" class="progress-question">
<a href="{% url 'question_steps' '02_claimant' %}" class="progress-question {% if step_status.your_information == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-info" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-info" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 2</small><br />Your information</span> <span class="progress-content"><small>Step 2</small><br />Your information</span>
{% if step_status.your_information == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_information == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_information == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'respondent' %}" class="progress-question">
<a href="{% url 'question_steps' '03_respondent' %}" class="progress-question {% if step_status.your_spouse == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-user" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-user" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 3</small><br />Your spouse</span> <span class="progress-content"><small>Step 3</small><br />Your spouse</span>
{% if step_status.your_spouse == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_spouse == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_spouse == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'marriage' %}" class="progress-question">
<a href="{% url 'question_steps' '04_marriage' %}" class="progress-question {% if step_status.your_marriage == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-link" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-link" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 4</small><br />Your marriage</span> <span class="progress-content"><small>Step 4</small><br />Your marriage</span>
{% if step_status.your_marriage == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_marriage == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_marriage == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'separation' %}" class="progress-question">
<a href="{% url 'question_steps' '05_separation' %}" class="progress-question {% if step_status.your_separation == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-chain-broken" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-chain-broken" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 5</small><br />Your separation</span> <span class="progress-content"><small>Step 5</small><br />Your separation</span>
{% if step_status.your_separation == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_separation == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_separation == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% if 'Spousal support' in want_which_orders|load_json %}
<a href="{% url 'question_steps' 'support' %}" class="progress-question">
<a href="{% url 'question_steps' '06_support' %}" class="progress-question {% if step_status.spousal_support == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-life-ring" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-life-ring" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 6</small><br />Spousal support</span> <span class="progress-content"><small>Step 6</small><br />Spousal support</span>
{% if step_status.spousal_support == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.spousal_support == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.spousal_support == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% endif %}
{% if 'Division of property and debts' in want_which_orders|load_json %}
<a href="{% url 'question_steps' 'property' %}" class="progress-question">
<a href="{% url 'question_steps' '07_property' %}" class="progress-question {% if step_status.property_and_debt == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-home" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-home" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="property" %}</small><br />Property and debt</span>
{% if step_status.property_and_debt == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
<span class="progress-content"><small>Step 7</small><br />Property and debt</span>
{% if step_status.property_and_debt == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.property_and_debt == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% endif %}
{% if 'Other orders' in want_which_orders|load_json %}
<a href="{% url 'question_steps' 'other_orders' %}" class="progress-question">
<a href="{% url 'question_steps' '08_other_orders' %}" class="progress-question {% if step_status.other_orders == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-gavel" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-gavel" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="other_orders" %}</small><br />Other orders</span>
{% if step_status.other_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
<span class="progress-content"><small>Step 8</small><br />Other orders</span>
{% if step_status.other_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.other_orders == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% endif %}
<a href="{% url 'question_steps' 'other_questions' %}" class="progress-question">
<a href="{% url 'question_steps' '09_other_questions' %}" class="progress-question {% if step_status.other_questions == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-question" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-question" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="other_questions" %}</small><br />Other questions</span>
{% if step_status.other_questions == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
<span class="progress-content"><small>Step 9</small><br />Other questions</span>
{% if step_status.other_questions == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.other_questions == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'location' %}" class="progress-question">
<a href="{% url 'question_steps' '10_location' %}" class="progress-question {% if step_status.filing_locations == 'Complete' %} complete {% endif %}">
<span class="progress-icon"><i class="fa fa-location-arrow" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-location-arrow" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="location" %}</small><br />Filing location</span>
{% if step_status.filing_locations == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
<span class="progress-content"><small>Step 10</small><br />Filing locations</span>
{% if step_status.filing_locations == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.filing_locations == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'review' %}" class="progress-question"> <a href="{% url 'question_steps' 'review' %}" class="progress-question">
<span class="progress-icon"><i class="fa fa-file" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-file" aria-hidden="true"></i></span>


+ 2
- 1
edivorce/apps/core/templates/partials/review_user_responses.html View File

@ -5,8 +5,9 @@
<th>User response</th> <th>User response</th>
</tr> </tr>
{% for question in questions %} {% for question in questions %}
{{question.question}}
<tr> <tr>
<td width="75%" style="padding-right: 5%">{{question.question.name}}</td>
<td width="75%" style="padding-right: 5%">{{question.question__name}}</td>
<td width="25%">{{question.value}}</td> <td width="25%">{{question.value}}</td>
</tr> </tr>
{% endfor %} {% endfor %}


+ 30
- 19
edivorce/apps/core/templates/progress.html View File

@ -8,65 +8,76 @@
<span class="progress-content">Qualifying Questions</span> <span class="progress-content">Qualifying Questions</span>
<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> <span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span>
</a> </a>
<a href="{% url 'question_steps' 'orders' %}" class="progress-question {% if active_page == 'orders' %} active {% endif %}">
<a href="{% url 'question_steps' 'orders' %}" class="progress-question {% if step_status.which_orders == 'Complete' %} complete {% endif %} {% if active_page == 'orders' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-commenting" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-commenting" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 1</small><br />What Are You Asking For?</span> <span class="progress-content"><small>Step 1</small><br />What Are You Asking For?</span>
{% if step_status.which_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.which_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.which_orders == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'claimant' %}" class="progress-question {% if active_page == 'claimant' %} active {% endif %}">
<a href="{% url 'question_steps' 'claimant' %}" class="progress-question {% if step_status.your_information == 'Complete' %} complete {% endif %} {% if active_page == 'claimant' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-info" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-info" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 2</small><br />Your information</span> <span class="progress-content"><small>Step 2</small><br />Your information</span>
{% if step_status.your_information == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_information == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_information == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'respondent' %}" class="progress-question {% if active_page == 'respondent' %} active {% endif %}">
<a href="{% url 'question_steps' 'respondent' %}" class="progress-question {% if step_status.your_spouse == 'Complete' %} complete {% endif %} {% if active_page == 'respondent' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-user" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-user" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 3</small><br />Your spouse</span> <span class="progress-content"><small>Step 3</small><br />Your spouse</span>
{% if step_status.your_spouse == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_spouse == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_spouse == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'marriage' %}" class="progress-question {% if active_page == 'marriage' %} active {% endif %}">
<a href="{% url 'question_steps' 'marriage' %}" class="progress-question {% if step_status.your_marriage == 'Complete' %} complete {% endif %} {% if active_page == 'marriage' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-link" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-link" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 4</small><br />Your marriage</span> <span class="progress-content"><small>Step 4</small><br />Your marriage</span>
{% if step_status.your_marriage == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_marriage == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_marriage == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'separation' %}" class="progress-question {% if active_page == 'separation' %} active {% endif %}">
<a href="{% url 'question_steps' 'separation' %}" class="progress-question {% if step_status.your_separation == 'Complete' %} complete {% endif %} {% if active_page == 'separation' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-chain-broken" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-chain-broken" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 5</small><br />Your separation</span> <span class="progress-content"><small>Step 5</small><br />Your separation</span>
{% if step_status.your_separation == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.your_separation == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.your_separation == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'support' %}" class="progress-question {% if step_status.spousal_support == 'Complete' %} complete {% endif %} {% if active_page == '06_support' %} active {% endif %}">
{% if 'Spousal support' in want_which_orders|load_json %} {% if 'Spousal support' in want_which_orders|load_json %}
<a href="{% url 'question_steps' 'support' %}" class="progress-question {% if active_page == 'support' %} active {% endif %}"> <a href="{% url 'question_steps' 'support' %}" class="progress-question {% if active_page == 'support' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-life-ring" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-life-ring" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step 6</small><br />Spousal support</span> <span class="progress-content"><small>Step 6</small><br />Spousal support</span>
{% if step_status.spousal_support == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.spousal_support == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.spousal_support == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% endif %} {% endif %}
{% if 'Division of property and debts' in want_which_orders|load_json %} {% if 'Division of property and debts' in want_which_orders|load_json %}
<a href="{% url 'question_steps' 'property' %}" class="progress-question {% if active_page == 'property' %} active {% endif %}">
<a href="{% url 'question_steps' 'property' %}" class="progress-question {% if step_status.property_and_debt == 'Complete' %} complete {% endif %} {% if active_page == 'property' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-home" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-home" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="property" %}</small><br />Property and debt</span> <span class="progress-content"><small>Step {% step_order step="property" %}</small><br />Property and debt</span>
{% if step_status.property_and_debt == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.property_and_debt == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.property_and_debt == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% endif %} {% endif %}
{% if 'Other orders' in want_which_orders|load_json %} {% if 'Other orders' in want_which_orders|load_json %}
<a href="{% url 'question_steps' 'other_orders' %}" class="progress-question {% if active_page == 'other_orders' %} active {% endif %}">
<a href="{% url 'question_steps' 'other_orders' %}" class="progress-question {% if step_status.other_orders == 'Complete' %} complete {% endif %} {% if active_page == 'other_orders' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-gavel" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-gavel" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="other_orders" %}</small><br />Other orders</span> <span class="progress-content"><small>Step {% step_order step="other_orders" %}</small><br />Other orders</span>
{% if step_status.other_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.other_orders == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.other_orders == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
{% endif %} {% endif %}
<a href="{% url 'question_steps' 'other_questions' %}" class="progress-question {% if active_page == 'other_questions' %} active {% endif %}">
<a href="{% url 'question_steps' 'other_questions' %}" class="progress-question {% if step_status.other_questions == 'Complete' %} complete {% endif %} {% if active_page == 'other_questions' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-question" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-question" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="other_questions" %}</small><br />Other questions</span> <span class="progress-content"><small>Step {% step_order step="other_questions" %}</small><br />Other questions</span>
{% if step_status.other_questions == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.other_questions == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.other_questions == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'location' %}" class="progress-question {% if active_page == 'location' %} active {% endif %}">
<a href="{% url 'question_steps' 'location' %}" class="progress-question {% if step_status.filing_locations == 'Complete' %} complete {% endif %} {% if active_page == 'location' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-location-arrow" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-location-arrow" aria-hidden="true"></i></span>
<span class="progress-content"><small>Step {% step_order step="location" %}</small><br />Filing location</span> <span class="progress-content"><small>Step {% step_order step="location" %}</small><br />Filing location</span>
{% if step_status.filing_locations == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span> {% endif %}
{% if step_status.filing_locations == 'Started' %}<span class="progress-status"><i class="fa fa-adjust" aria-hidden="true"></i></span>
{% elif step_status.filing_locations == 'Complete' %}<span class="progress-status"><i class="fa fa-check" aria-hidden="true"></i></span> {% endif %}
</a> </a>
<a href="{% url 'question_steps' 'review' %}" class="progress-question {% if active_page == 'review' %} active {% endif %}"> <a href="{% url 'question_steps' 'review' %}" class="progress-question {% if active_page == 'review' %} active {% endif %}">
<span class="progress-icon"><i class="fa fa-file" aria-hidden="true"></i></span> <span class="progress-icon"><i class="fa fa-file" aria-hidden="true"></i></span>


+ 255
- 0
edivorce/apps/core/tests.py View File

@ -1,3 +1,258 @@
from django.test import TestCase from django.test import TestCase
from edivorce.apps.core.models import UserResponse, Question, BceidUser
from edivorce.apps.core.utils.user_response import is_complete
from edivorce.apps.core.utils.question_step_mapping import question_step_mapping
# Create your tests here. # Create your tests here.
class UserResponseTestCase(TestCase):
fixtures = ['Question.json']
def setUp(self):
BceidUser.objects.create(user_guid='1234')
Question.objects.create(key='test', name='this is test')
def test_which_order(self):
step = 'which_orders'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required question
create_response(user, 'want_which_orders', '["nothing"]')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
def test_your_info(self):
step = 'your_information'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# Testing required questions
# Missing few required questions
create_response(user, 'name_you', 'John Doe')
create_response(user, 'last_name_before_married_you', 'Jackson')
create_response(user, 'birthday_you', '11/11/1111')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# Few required questions with one checking question with hidden question not shown
create_response(user, 'lived_in_bc_you', '11/11/1111')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question not shown
create_response(user, 'last_name_born_you', 'Jackson')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question missing
UserResponse.objects.filter(question_id='lived_in_bc_you').update(value="Moved to British Columbia on")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question
create_response(user, 'moved_to_bc_date_you', '12/12/1212')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with two checking question with one hidden and one shown
create_response(user, 'any_other_name_you', 'NO')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# All required questions with two checking question with one hidden question missing
UserResponse.objects.filter(question_id='any_other_name_you').update(value="YES")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with all checking question with all hidden questions
create_response(user, 'other_name_you', 'Smith')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
def test_your_spouse(self):
step = 'your_spouse'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# Testing required questions
# Missing few required questions
create_response(user, 'name_spouse', 'John Doe')
create_response(user, 'last_name_before_married_spouse', 'Jackson')
create_response(user, 'birthday_spouse', '11/11/1111')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# Few required questions with one checking question with hidden question not shown
create_response(user, 'any_other_name_spouse', 'NO')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question not shown
create_response(user, 'last_name_born_spouse', 'Jackson')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question missing
UserResponse.objects.filter(question_id='any_other_name_spouse').update(value="YES")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with one checking question with hidden question
create_response(user, 'lived_in_bc_spouse', '11/11/1111')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with two checking question with one hidden and one shown
create_response(user, 'other_name_spouse', 'Smith')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# All required questions with two checking question with one hidden question missing
UserResponse.objects.filter(question_id='lived_in_bc_spouse').update(value="Moved to British Columbia on")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required questions with all checking question with all hidden questions
create_response(user, 'moved_to_bc_date_spouse', '12/12/1212')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
def test_your_marriage(self):
pass
def test_your_separation(self):
step = 'your_separation'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required question
create_response(user, 'no_reconciliation_possible', 'I agree')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
def test_spousal_support(self):
step = 'spousal_support'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# One required question
create_response(user, 'spouse_support_details', 'I will support you')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# Two required questions
create_response(user, 'spouse_support_act', 'Family Law')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# Remove first added required response to test the second required question
UserResponse.objects.get(question_id='spouse_support_details').delete()
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
def test_property_and_debt(self):
step = 'property_and_debt'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required question with no hidden shown
create_response(user, 'deal_with_property_debt', 'equal division')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# All required question with hidden shown but no response
UserResponse.objects.filter(question_id='deal_with_property_debt').update(value="unequal division")
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required question with hidden shown and answered
create_response(user, 'how_to_divide_property_debt', 'Do not divide them')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
def test_other_orders(self):
step = 'other_orders'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required question
create_response(user, 'other_orders_detail', 'I want more orders')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
def test_other_questions(self):
pass
def test_filing_locations(self):
step = 'filing_locations'
questions = question_step_mapping[step]
user = BceidUser.objects.get(user_guid='1234')
# No response should be False
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), False)
# All required question
create_response(user, 'court_registry_for_filing', 'Vancouver')
lst = UserResponse.objects.filter(question_id__in=questions).values('question_id', 'value')
self.assertEqual(is_complete(step, lst), True)
# Helper functions
def create_response(user, question, value):
UserResponse.objects.create(bceid_user=user, question=Question.objects.get(key=question), value=value)

+ 32
- 0
edivorce/apps/core/utils/question_step_mapping.py View File

@ -46,3 +46,35 @@ list_of_registries = ['Fort St. John', 'Dawson Creek', 'Prince Rupert', 'Terrace
'Williams Lake', 'Campbell River', 'Powell River', 'Courtenay', 'Port Alberni', 'Duncan', 'Nanaimo', 'Williams Lake', 'Campbell River', 'Powell River', 'Courtenay', 'Port Alberni', 'Duncan', 'Nanaimo',
'Victoria', 'Golden', 'Kamloops', 'Salmon Arm', 'Vernon', 'Kelowna', 'Penticton', 'Nelson', 'Rossland', 'Victoria', 'Golden', 'Kamloops', 'Salmon Arm', 'Vernon', 'Kelowna', 'Penticton', 'Nelson', 'Rossland',
'Cranbrook', 'Chilliwack', 'New Westminster', 'Vancouver', 'Fort Nelson', 'Revelstoke',] 'Cranbrook', 'Chilliwack', 'New Westminster', 'Vancouver', 'Fort Nelson', 'Revelstoke',]
complete_state_for_step = {'which_orders': {'required': ['want_which_orders']},
'your_information': {'required': ['name_you', 'last_name_born_you',
'last_name_before_married_you', 'birthday_you'],
'conditional': {'any_other_name_you': ['YES', 'other_name_you'],
'lived_in_bc_you': ['Moved to British Columbia on', 'moved_to_bc_date_you']},},
'your_spouse': {'required': ['name_spouse', 'last_name_born_spouse',
'last_name_before_married_spouse', 'birthday_spouse'],
'conditional': {'any_other_name_spouse': ['YES', 'other_name_spouse'],
'lived_in_bc_spouse': ['Moved to British Columbia on', 'moved_to_bc_date_spouse']},},
'your_marriage': {'required': ['']},
'your_separation': {'required': ['no_reconciliation_possible']},
'spousal_support': {'required': ['spouse_support_details', 'spouse_support_act']},
'property_and_debt': {'required': [],
'conditional': {'deal_with_property_debt': ['unequal division', 'how_to_divide_property_debt']}},
'other_orders': {'required': ['other_orders_detail']},
'other_questions': {'required': ['address_to_send_official_document_street_you',
'address_to_send_official_document_city_you',
'address_to_send_official_document_prov_you',
'address_to_send_official_document_country_you',
'address_to_send_official_document_other_country_you',
'address_to_send_official_document_postal_code_you',
'address_to_send_official_document_street_spouse',
'address_to_send_official_document_city_spouse',
'address_to_send_official_document_prov_spouse',
'address_to_send_official_document_country_spouse',
'address_to_send_official_document_other_country_spouse',
'address_to_send_official_document_postal_code_spouse',
'divorce_take_effect_on_specific_date']},
'filing_locations': {'required': ['court_registry_for_filing']},
}

+ 39
- 3
edivorce/apps/core/utils/user_response.py View File

@ -1,5 +1,6 @@
from edivorce.apps.core.models import UserResponse, Question 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.question_step_mapping import question_step_mapping, complete_state_for_step
from copy import deepcopy
def get_responses_from_db(bceid_user): def get_responses_from_db(bceid_user):
@ -15,7 +16,7 @@ def get_responses_from_db_grouped_by_steps(bceid_user):
responses = UserResponse.objects.filter(bceid_user=bceid_user) responses = UserResponse.objects.filter(bceid_user=bceid_user)
responses_dict = {} responses_dict = {}
for step, questions in question_step_mapping.items(): for step, questions in question_step_mapping.items():
responses_dict[step] = responses.filter(question_id__in=questions)
responses_dict[step] = responses.filter(question_id__in=questions).values('question_id', 'value', 'question__name')
return responses_dict return responses_dict
@ -25,7 +26,11 @@ def get_step_status(responses_by_step):
if not lst: if not lst:
status_dict[step] = "Not started" status_dict[step] = "Not started"
else: else:
status_dict[step] = "Started"
if step != 'prequalification':
if is_complete(step, lst):
status_dict[step] = "Complete"
else:
status_dict[step] = "Started"
return status_dict return status_dict
@ -65,3 +70,34 @@ def copy_session_to_db(request, bceid_user):
# clear the response from the session # clear the response from the session
request.session[q.key] = None request.session[q.key] = None
def is_complete(step, lst):
if not lst:
return False
required_dict = deepcopy(complete_state_for_step)
if step in required_dict:
required_list = required_dict[step]['required']
conditional_list = required_dict[step]['conditional'] if 'conditional' in required_dict[step] else []
for question in lst:
q_id = question['question_id']
if q_id in required_list:
required_list.remove(q_id)
elif q_id in conditional_list:
value = question['value']
if q_id in conditional_list and value == conditional_list[q_id][0]:
key_in_list = False
for key in lst:
if key['question_id'] == conditional_list[q_id][1]:
key_in_list = True
break
if key_in_list is False:
return False
conditional_list.pop(q_id, None)
else:
conditional_list.pop(q_id, None)
if not required_list and not conditional_list:
return True
return False

+ 3
- 0
edivorce/settings/local.py View File

@ -20,3 +20,6 @@ WEASYPRINT_CSS_LOOPBACK = 'http://10.200.10.1:8000'
DEPLOYMENT_TYPE = 'localdev' DEPLOYMENT_TYPE = 'localdev'
REGISTER_URL = '#' REGISTER_URL = '#'
FIXTURE_DIRS = FIXTURE_DIRS = (
os.path.join(PROJECT_ROOT, 'edivorce', 'fixtures'),
)

Loading…
Cancel
Save