mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
17
people/migrations/0008_order_answer_by_question.py
Normal file
17
people/migrations/0008_order_answer_by_question.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Generated by Django 2.2.10 on 2020-02-20 15:23
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('people', '0007_relationship_question_answers'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='relationshipquestionchoice',
|
||||||
|
options={'ordering': ['question__order', 'order', 'text']},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -97,6 +97,7 @@ class RelationshipQuestionChoice(models.Model):
|
|||||||
name='unique_question_answer')
|
name='unique_question_answer')
|
||||||
]
|
]
|
||||||
ordering = [
|
ordering = [
|
||||||
|
'question__order',
|
||||||
'order',
|
'order',
|
||||||
'text',
|
'text',
|
||||||
]
|
]
|
||||||
@@ -147,3 +148,13 @@ class Relationship(models.Model):
|
|||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f'{self.source} -> {self.target}'
|
return f'{self.source} -> {self.target}'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reverse(self):
|
||||||
|
"""
|
||||||
|
Get the reverse of this relationship.
|
||||||
|
|
||||||
|
@raise Relationship.DoesNotExist: When the reverse relationship is not known
|
||||||
|
"""
|
||||||
|
return type(self).objects.get(source=self.target,
|
||||||
|
target=self.source)
|
||||||
|
|||||||
@@ -15,22 +15,55 @@
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="row align-content-center">
|
<div class="row align-content-center align-items-center">
|
||||||
<div class="col-md-6">
|
<div class="col-md-5 text-center">
|
||||||
<h2>Source</h2>
|
<h2>Source</h2>
|
||||||
{{ relationship.source }}
|
<p>{{ relationship.source }}</p>
|
||||||
|
|
||||||
<a class="btn btn-sm btn-info"
|
<a class="btn btn-sm btn-info"
|
||||||
href="{% url 'people:person.detail' pk=relationship.source.pk %}">Profile</a>
|
href="{% url 'people:person.detail' pk=relationship.source.pk %}">Profile</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-2 text-center">
|
||||||
|
{% if relationship.reverse %}
|
||||||
|
<a href="{% url 'people:relationship.detail' pk=relationship.reverse.pk %}">
|
||||||
|
<span class="fas fa-exchange-alt fa-5x"></span>
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-5 text-center">
|
||||||
<h2>Target</h2>
|
<h2>Target</h2>
|
||||||
{{ relationship.target }}
|
<p>{{ relationship.target }}</p>
|
||||||
|
|
||||||
<a class="btn btn-sm btn-info"
|
<a class="btn btn-sm btn-info"
|
||||||
href="{% url 'people:person.detail' pk=relationship.target.pk %}">Profile</a>
|
href="{% url 'people:person.detail' pk=relationship.target.pk %}">Profile</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<table class="table table-borderless">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Question</th>
|
||||||
|
<th>Answer</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
{% for answer in relationship.question_answers.all %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ answer.question }}</td>
|
||||||
|
<td>{{ answer }}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% empty %}
|
||||||
|
<tr>
|
||||||
|
<td>No records</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user