diff --git a/people/templates/people/person/detail_full.html b/people/templates/people/person/detail_full.html index 96c4480..39651b0 100644 --- a/people/templates/people/person/detail_full.html +++ b/people/templates/people/person/detail_full.html @@ -49,7 +49,7 @@ {% endif %} - {% include 'people/person/includes/answer_set_full.html' %} + {% include 'people/person/includes/answer_set.html' %} Update diff --git a/people/templates/people/person/detail_partial.html b/people/templates/people/person/detail_partial.html index 15135b7..ec9c04c 100644 --- a/people/templates/people/person/detail_partial.html +++ b/people/templates/people/person/detail_partial.html @@ -41,7 +41,7 @@
- {% include 'people/person/includes/answer_set_partial.html' %} + {% include 'people/person/includes/answer_set.html' %}
diff --git a/people/templates/people/person/includes/answer_set.html b/people/templates/people/person/includes/answer_set.html new file mode 100644 index 0000000..3ab6dc8 --- /dev/null +++ b/people/templates/people/person/includes/answer_set.html @@ -0,0 +1,25 @@ + + + + + + + + + + {% for question, answers in question_answers.items %} + + + + + {% endfor %} + + {% if answer_set is None %} + + + + {% endif %} + +
QuestionAnswer
{{ question }}{{ answers }}
No answers
+ +

Last updated: {{ answer_set.timestamp }}

diff --git a/people/templates/people/person/includes/answer_set_full.html b/people/templates/people/person/includes/answer_set_full.html deleted file mode 100644 index 1b747c7..0000000 --- a/people/templates/people/person/includes/answer_set_full.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - {% if answer_set.nationality %} - - {% endif %} - - {% if answer_set.country_of_residence %} - - {% endif %} - - {% if answer_set.organisation %} - - {% endif %} - - {% if answer_set.organisation_started_date %} - - {% endif %} - - {% if answer_set.project_started_date %} - - {% endif %} - - {% if answer_set.job_title %} - - {% endif %} - - {% if answer_set.disciplinary_background %} - - {% endif %} - - {% if answer_set.external_organisations %} - - {% endif %} - - {% for question, answers in question_answers.items %} - - - - - {% endfor %} - - {% if answer_set is None %} - - - - {% endif %} - -
QuestionAnswer
Nationality{{ answer_set.nationality.name }}
Country of Residence{{ answer_set.country_of_residence.name }}
Organisation{{ answer_set.organisation }}
Organisation Started Date{{ answer_set.organisation_started_date }}
{{ settings.PARENT_PROJECT_NAME }} Started Date{{ answer_set.project_started_date }}
Job Title{{ answer_set.job_title }}
Disciplinary Background{{ answer_set.disciplinary_background }}
External Organisations Worked With{{ answer_set.external_organisations }}
{{ question }}{{ answers }}
No answers
- -

Last updated: {{ answer_set.timestamp }}

diff --git a/people/templates/people/person/includes/answer_set_partial.html b/people/templates/people/person/includes/answer_set_partial.html deleted file mode 100644 index a3228df..0000000 --- a/people/templates/people/person/includes/answer_set_partial.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - {% if answer_set.country_of_residence %} - - {% endif %} - - {% if answer_set.organisation %} - - {% endif %} - - {% if answer_set.disciplinary_background %} - - {% endif %} - - {% for question, answers in question_answers.items %} - - - - - {% endfor %} - - {% if answer_set is None %} - - - - {% endif %} - -
QuestionAnswer
Country of Residence{{ answer_set.country_of_residence.name }}
Organisation{{ answer_set.organisation }}
Disciplinary Background{{ answer_set.disciplinary_background }}
{{ question }}{{ answers }}
No answers
- -

Last updated: {{ answer_set.timestamp }}

diff --git a/people/views/person.py b/people/views/person.py index fe4578a..498abf9 100644 --- a/people/views/person.py +++ b/people/views/person.py @@ -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