refactor: views to handled ended relationships

Add ending of organisation relationships
This commit is contained in:
James Graham
2021-03-19 12:41:36 +00:00
parent 42d95beb5a
commit 74fffb0cac
8 changed files with 156 additions and 56 deletions

View File

@@ -17,6 +17,24 @@
<hr>
<div class="row justify-content-md-center">
<div class="col-md-3">
<a class="btn btn-warning btn-block"
href="{% url 'people:organisation.relationship.update' pk=relationship.pk %}">Update Relationship
</a>
</div>
{% if relationship.is_current %}
<div class="col-md-3">
<a class="btn btn-danger btn-block"
href="{% url 'people:organisation.relationship.end' pk=relationship.pk %}">End Relationship
</a>
</div>
{% endif %}
</div>
<hr>
<div class="row align-content-center align-items-center">
<div class="col-md-5 text-center">
<h2>Source</h2>
@@ -39,34 +57,40 @@
<hr>
<a class="btn btn-success"
href="{% url 'people:organisation.relationship.update' pk=relationship.pk %}">Update</a>
{% with relationship.current_answers as answer_set %}
<table class="table table-borderless">
<thead>
<tr>
<th>Question</th>
<th>Answer</th>
</tr>
</thead>
{% if answer_set is None %}
<div class="alert alert-warning mt-3">
This relationship has ended. You can start it again by updating it.
</div>
<tbody>
{% for answer in answer_set.question_answers.all %}
{% else %}
<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>
Last updated: {{ answer_set.timestamp }}
{% empty %}
<tr>
<td>No records</td>
</tr>
{% endfor %}
</tbody>
</table>
<p>
Last updated: {{ answer_set.timestamp }}
</p>
{% endif %}
{% endwith %}
{% endblock %}

View File

@@ -42,6 +42,14 @@
</a>
{% endif %}
</div>
{% if relationship %}
<div class="col-md-3">
<a class="btn btn-danger btn-block"
href="{% url 'people:organisation.relationship.end' pk=relationship.pk %}">End Relationship
</a>
</div>
{% endif %}
</div>
<hr>

View File

@@ -56,7 +56,15 @@
<tbody>
{% for relationship in person.organisation_relationships_as_source.all %}
<tr>
<td>{{ relationship.target }}</td>
<td>
{% if relationship.is_current %}
{{ relationship.target }}
{% else %}
<del>
{{ relationship.target }}
</del>
{% endif %}
</td>
<td>
<a class="btn btn-sm btn-info"
href="{% url 'people:organisation.detail' pk=relationship.target.pk %}">Profile</a>

View File

@@ -17,6 +17,24 @@
<hr>
<div class="row justify-content-md-center">
<div class="col-md-3">
<a class="btn btn-warning btn-block"
href="{% url 'people:relationship.update' pk=relationship.pk %}">Update Relationship
</a>
</div>
{% if relationship.is_current %}
<div class="col-md-3">
<a class="btn btn-danger btn-block"
href="{% url 'people:relationship.end' pk=relationship.pk %}">End Relationship
</a>
</div>
{% endif %}
</div>
<hr>
<div class="row align-content-center align-items-center">
<div class="col-md-5 text-center">
<h2>Source</h2>
@@ -45,34 +63,40 @@
<hr>
<a class="btn btn-success"
href="{% url 'people:relationship.update' pk=relationship.pk %}">Update</a>
{% with relationship.current_answers as answer_set %}
<table class="table table-borderless">
<thead>
<tr>
<th>Question</th>
<th>Answer</th>
</tr>
</thead>
{% if answer_set is None %}
<div class="alert alert-warning mt-3">
This relationship has ended. You can start it again by updating it.
</div>
<tbody>
{% for answer in answer_set.question_answers.all %}
{% else %}
<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>
Last updated: {{ answer_set.timestamp }}
{% empty %}
<tr>
<td>No records</td>
</tr>
{% endfor %}
</tbody>
</table>
<p>
Last updated: {{ answer_set.timestamp }}
</p>
{% endif %}
{% endwith %}
{% endblock %}