From df13bcf46d15ce5d7e570e6173b66d195f07296f Mon Sep 17 00:00:00 2001 From: James Graham Date: Wed, 10 Mar 2021 11:38:52 +0000 Subject: [PATCH] fix: exclude hardcoded qs from dynamic table --- people/views/organisation.py | 4 ++-- people/views/person.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/people/views/organisation.py b/people/views/organisation.py index 0a52b56..bc77f88 100644 --- a/people/views/organisation.py +++ b/people/views/organisation.py @@ -109,12 +109,12 @@ class OrganisationDetailView(LoginRequiredMixin, DetailView): def build_question_answers(self, answer_set: models.OrganisationAnswerSet) -> typing.Dict[str, str]: """Collect answers to dynamic questions and join with commas.""" show_all = self.request.user.is_superuser - questions = models.OrganisationQuestion.objects.all() + questions = models.OrganisationQuestion.objects.filter(is_hardcoded=False) if not show_all: questions = questions.filter(answer_is_public=True) question_answers = {} - for question in models.OrganisationQuestion.objects.all(): + for question in questions: answers = answer_set.question_answers.filter(question=question) question_answers[str(question)] = ', '.join(map(str, answers)) diff --git a/people/views/person.py b/people/views/person.py index 46ab8f6..14634eb 100644 --- a/people/views/person.py +++ b/people/views/person.py @@ -74,12 +74,12 @@ 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.all() + questions = models.PersonQuestion.objects.filter(is_hardcoded=False) if not show_all: questions = questions.filter(answer_is_public=True) question_answers = {} - for question in models.PersonQuestion.objects.all(): + for question in questions: answers = answer_set.question_answers.filter(question=question) question_answers[str(question)] = ', '.join(map(str, answers))