From b8877892d6e8cc286d635faa50690135c90223fb Mon Sep 17 00:00:00 2001 From: Geert Kapteijns <ghkapteijns@gmail.com> Date: Fri, 19 May 2017 17:52:03 +0200 Subject: [PATCH] move more html from Contributor to partial templates --- scipost/models.py | 8 -------- .../templates/scipost/_assignments_summary_as_td.html | 0 scipost/templates/scipost/_expertises_as_ul.html | 9 +++++++++ scipost/templates/scipost/personal_page.html | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 scipost/templates/scipost/_assignments_summary_as_td.html create mode 100644 scipost/templates/scipost/_expertises_as_ul.html diff --git a/scipost/models.py b/scipost/models.py index 9b9314b7e..de7a46a6b 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -112,14 +112,6 @@ class Contributor(models.Model): # Redundant, to be removed in future return self.get_discipline_display() - def expertises_as_ul(self): - output = '<ul>' - if self.expertises: - for exp in self.expertises: - output += '<li>%s</li>' % subject_areas_dict[exp] - output += '</ul>' - return mark_safe(output) - def expertises_as_string(self): if self.expertises: return ', '.join([subject_areas_dict[exp].lower() for exp in self.expertises]) diff --git a/scipost/templates/scipost/_assignments_summary_as_td.html b/scipost/templates/scipost/_assignments_summary_as_td.html new file mode 100644 index 000000000..e69de29bb diff --git a/scipost/templates/scipost/_expertises_as_ul.html b/scipost/templates/scipost/_expertises_as_ul.html new file mode 100644 index 000000000..16150eeff --- /dev/null +++ b/scipost/templates/scipost/_expertises_as_ul.html @@ -0,0 +1,9 @@ +{% load scipost_extras %} + +<ul> + {% for expertise in contributor.expertises %} + <li> + {{ expertise|get_specialization_display }} + </li> + {% endfor %} +</ul> diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index b1121e1b5..6f3c572d5 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -88,7 +88,7 @@ <h3 class="mt-3">Your expertises:</h3> {% if contributor.expertises %} - {{ contributor.expertises_as_ul }} + {% include "scipost/_expertises_as_ul.html" with contributor=contributor %} {% else %} <p>You haven't listed your expertise(s).<br/> Do so by <a href="{% url 'scipost:update_personal_data' %}">updating your personal data</a> -- GitLab