refactor(people): Move relationship answers to answer set

Answers to the relationship questions have been moved from the relationship
to another model RelationshipAnswerSet.  A new answer set is created each
time a user answers the relationship questions.

Resolves #16
Resolves #17
Resolves #18
This commit is contained in:
James Graham
2020-03-05 15:22:28 +00:00
parent 1a9ba731cf
commit 9b3b759254
10 changed files with 375 additions and 148 deletions

View File

@@ -43,27 +43,34 @@
<hr>
<table class="table table-borderless">
<thead>
<tr>
<th>Question</th>
<th>Answer</th>
</tr>
</thead>
<a class="btn btn-success"
href="{% url 'people:relationship.update' relationship_pk=relationship.pk %}">Update</a>
<tbody>
{% for answer in relationship.question_answers.all %}
{% with relationship.current_answers as answer_set %}
<table class="table table-borderless">
<thead>
<tr>
<td>{{ answer.question }}</td>
<td>{{ answer }}</td>
<th>Question</th>
<th>Answer</th>
</tr>
</thead>
{% empty %}
<tr>
<td>No records</td>
</tr>
{% endfor %}
</tbody>
</table>
<tbody>
{% for answer in answer_set.question_answers.all %}
<tr>
<td>{{ answer.question }}</td>
<td>{{ answer }}</td>
</tr>
{% empty %}
<tr>
<td>No records</td>
</tr>
{% endfor %}
</tbody>
</table>
Last updated: {{ answer_set.timestamp }}
{% endwith %}
{% endblock %}

View File

@@ -0,0 +1,33 @@
{% extends 'base.html' %}
{% block content %}
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{% url 'people:person.list' %}">People</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'people:person.detail' pk=person.pk %}">{{ person }}</a>
</li>
<li class="breadcrumb-item">
<a href="{% url 'people:relationship.detail' pk=relationship.pk %}">{{ relationship.target }}</a>
</li>
<li class="breadcrumb-item active" aria-current="page">Update Relationship</li>
</ol>
</nav>
<hr>
<form class="form"
method="POST">
{% csrf_token %}
{% load bootstrap4 %}
{% bootstrap_form form %}
{% buttons %}
<button class="btn btn-success" type="submit">Submit</button>
{% endbuttons %}
</form>
{% endblock %}