mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 11:27:09 +00:00
refactor: making static qs more admin configurable
This commit is contained in:
@@ -49,7 +49,7 @@
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% include 'people/person/includes/answer_set_full.html' %}
|
||||
{% include 'people/person/includes/answer_set.html' %}
|
||||
|
||||
<a class="btn btn-success"
|
||||
href="{% url 'people:person.update' pk=person.pk %}">Update</a>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
<hr>
|
||||
|
||||
{% include 'people/person/includes/answer_set_partial.html' %}
|
||||
{% include 'people/person/includes/answer_set.html' %}
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
25
people/templates/people/person/includes/answer_set.html
Normal file
25
people/templates/people/person/includes/answer_set.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">Question</th>
|
||||
<th>Answer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for question, answers in question_answers.items %}
|
||||
<tr>
|
||||
<td>{{ question }}</td>
|
||||
<td>{{ answers }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% if answer_set is None %}
|
||||
<tr>
|
||||
<td colspan="2">No answers</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>Last updated: {{ answer_set.timestamp }}</p>
|
||||
@@ -1,57 +0,0 @@
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">Question</th>
|
||||
<th>Answer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% if answer_set.nationality %}
|
||||
<tr><td>Nationality</td><td>{{ answer_set.nationality.name }}</td>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.country_of_residence %}
|
||||
<tr><td>Country of Residence</td><td>{{ answer_set.country_of_residence.name }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.organisation %}
|
||||
<tr><td>Organisation</td><td>{{ answer_set.organisation }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.organisation_started_date %}
|
||||
<tr><td>Organisation Started Date</td><td>{{ answer_set.organisation_started_date }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.project_started_date %}
|
||||
<tr><td>{{ settings.PARENT_PROJECT_NAME }} Started Date</td><td>{{ answer_set.project_started_date }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.job_title %}
|
||||
<tr><td>Job Title</td><td>{{ answer_set.job_title }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.disciplinary_background %}
|
||||
<tr><td>Disciplinary Background</td><td>{{ answer_set.disciplinary_background }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.external_organisations %}
|
||||
<tr><td>External Organisations Worked With</td><td>{{ answer_set.external_organisations }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% for question, answers in question_answers.items %}
|
||||
<tr>
|
||||
<td>{{ question }}</td>
|
||||
<td>{{ answers }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% if answer_set is None %}
|
||||
<tr>
|
||||
<td colspan="2">No answers</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>Last updated: {{ answer_set.timestamp }}</p>
|
||||
@@ -1,37 +0,0 @@
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">Question</th>
|
||||
<th>Answer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% if answer_set.country_of_residence %}
|
||||
<tr><td>Country of Residence</td><td>{{ answer_set.country_of_residence.name }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.organisation %}
|
||||
<tr><td>Organisation</td><td>{{ answer_set.organisation }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% if answer_set.disciplinary_background %}
|
||||
<tr><td>Disciplinary Background</td><td>{{ answer_set.disciplinary_background }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% for question, answers in question_answers.items %}
|
||||
<tr>
|
||||
<td>{{ question }}</td>
|
||||
<td>{{ answers }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
{% if answer_set is None %}
|
||||
<tr>
|
||||
<td colspan="2">No answers</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>Last updated: {{ answer_set.timestamp }}</p>
|
||||
@@ -95,17 +95,24 @@ class ProfileView(LoginRequiredMixin, DetailView):
|
||||
def build_question_answers(
|
||||
self, answer_set: models.PersonAnswerSet) -> typing.Dict[str, str]:
|
||||
"""Collect answers to dynamic questions and join with commas."""
|
||||
show_all = (self.object.user
|
||||
== self.request.user) or self.request.user.is_superuser
|
||||
questions = models.PersonQuestion.objects.filter(is_hardcoded=False)
|
||||
show_all = ((self.object.user == self.request.user)
|
||||
or self.request.user.is_superuser)
|
||||
questions = models.PersonQuestion.objects.all()
|
||||
if not show_all:
|
||||
questions = questions.filter(answer_is_public=True)
|
||||
|
||||
question_answers = {}
|
||||
try:
|
||||
for question in questions:
|
||||
answers = answer_set.question_answers.filter(question=question)
|
||||
question_answers[str(question)] = ', '.join(map(str, answers))
|
||||
if question.is_hardcoded:
|
||||
question_answers[str(question)] = getattr(
|
||||
answer_set, question.text)
|
||||
|
||||
else:
|
||||
answers = answer_set.question_answers.filter(
|
||||
question=question)
|
||||
question_answers[str(question)] = ', '.join(
|
||||
map(str, answers))
|
||||
|
||||
except AttributeError:
|
||||
# No AnswerSet yet
|
||||
|
||||
Reference in New Issue
Block a user