mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
18
people/migrations/0032_personquestion_answer_is_public.py
Normal file
18
people/migrations/0032_personquestion_answer_is_public.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.10 on 2021-02-08 13:32
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('people', '0031_question_allow_free_text'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='personquestion',
|
||||
name='answer_is_public',
|
||||
field=models.BooleanField(default=True, help_text='Should answers to this question be displayed on profiles?'),
|
||||
),
|
||||
]
|
||||
@@ -95,6 +95,12 @@ class Theme(models.Model):
|
||||
|
||||
class PersonQuestion(Question):
|
||||
"""Question which may be asked about a person."""
|
||||
#: Should answers to this question be displayed on public profiles?
|
||||
answer_is_public = models.BooleanField(
|
||||
help_text='Should answers to this question be displayed on profiles?',
|
||||
default=True,
|
||||
blank=False,
|
||||
null=False)
|
||||
|
||||
|
||||
class PersonQuestionChoice(QuestionChoice):
|
||||
@@ -193,6 +199,10 @@ class PersonAnswerSet(AnswerSet):
|
||||
#: Longitude for displaying location on a map
|
||||
longitude = models.FloatField(blank=True, null=True)
|
||||
|
||||
def public_answers(self) -> models.QuerySet:
|
||||
"""Get answers to questions which are public."""
|
||||
return self.question_answers.filter(question__answer_is_public=True)
|
||||
|
||||
def as_dict(self):
|
||||
"""Get the answers from this set as a dictionary for use in Form.initial."""
|
||||
exclude_fields = {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<tr><td>Organisation</td><td>{{ answer_set.organisation }}</td></tr>
|
||||
{% endif %}
|
||||
|
||||
{% for answer in answer_set.question_answers.all %}
|
||||
{% for answer in answer_set.public_answers.all %}
|
||||
<tr>
|
||||
<td>{{ answer.question }}</td>
|
||||
<td>{{ answer }}</td>
|
||||
|
||||
Reference in New Issue
Block a user