mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 03:17:07 +00:00
refactor: making static qs more admin configurable
This commit is contained in:
@@ -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