feat: specify whether question answers are public

Resolves #62
This commit is contained in:
James Graham
2021-02-08 14:42:07 +00:00
parent 9164ea8a05
commit a141b93644
3 changed files with 29 additions and 1 deletions

View File

@@ -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 = {