From ce91d1d197d6004918f358cd7ce28a3bd3933c5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org> Date: Sat, 30 Oct 2021 09:00:51 +0200 Subject: [PATCH] Populate portal journals tab --- .../templates/journals/journal_list.html | 3 - .../scipost/templates/scipost/bare_base.html | 2 + .../scipost/portal/_hx_journals.html | 70 +++++++++++++++++++ .../templates/scipost/portal/portal.html | 25 ++++--- scipost_django/scipost/urls.py | 5 ++ 5 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 scipost_django/scipost/templates/scipost/portal/_hx_journals.html diff --git a/scipost_django/journals/templates/journals/journal_list.html b/scipost_django/journals/templates/journals/journal_list.html index a70c0728d..3b1ab5291 100644 --- a/scipost_django/journals/templates/journals/journal_list.html +++ b/scipost_django/journals/templates/journals/journal_list.html @@ -5,9 +5,6 @@ {% load journals_extras %} {% load scipost_extras %} -{% block headsup %} - <style>{% for journal in object_list %}{% if journal.style %}{{ journal.style }}{% endif %}{% endfor %}</style> -{% endblock headsup %} {% block meta_description %}{{ block.super }} {% if acad_field %} in {{ acad_field.name }}{% endif %}{% endblock meta_description %} {% block pagetitle %}: Journals{% if acad_field %} in {{ acad_field.name }}{% endif %}{% endblock pagetitle %} diff --git a/scipost_django/scipost/templates/scipost/bare_base.html b/scipost_django/scipost/templates/scipost/bare_base.html index 365b663bc..940472be8 100644 --- a/scipost_django/scipost/templates/scipost/bare_base.html +++ b/scipost_django/scipost/templates/scipost/bare_base.html @@ -20,6 +20,8 @@ <title>SciPost{% block pagetitle %}{% endblock pagetitle %}</title> + <style>{% for journal in journals %}{% if journal.style %}{{ journal.style }}{% endif %}{% endfor %}</style> + {% block headsup %} {% endblock headsup %} </head> diff --git a/scipost_django/scipost/templates/scipost/portal/_hx_journals.html b/scipost_django/scipost/templates/scipost/portal/_hx_journals.html new file mode 100644 index 000000000..d964fa75a --- /dev/null +++ b/scipost_django/scipost/templates/scipost/portal/_hx_journals.html @@ -0,0 +1,70 @@ +{% load static %} +{% load automarkup %} +{% load journals_extras %} +{% load scipost_extras %} + + +{% if session_acad_field %} + + <div class="row"> + {% for journal in session_acad_field.journals %} + {% if journal.active or perms.scipost.can_view_pool %} + <div class="col-md-6 col-lg-4 mb-2" style="{{ journal.style }}"> + <div class="card"> + <div class="card-header {{ journal.doi_label }}"> + <a href="{{ journal.get_absolute_url }}">{{ journal.name }}</a> + {% if journal.has_DOAJ_Seal %} + <a href="https://doaj.org" class="float-end"><img src="{% static 'scipost/images/DOAJ_Seal_logo_big.png' %}" alt="DOAJ Seal" width="20em"></a> + {% endif %} + </div> + <div class="card-body"> + {{ journal.blurb|automarkup }} + </div> + {% if journal.series_set.all|length > 0 %} + <div class="card-footer"> + Series hosted in this Journal: + <ul> + {% for series in journal.series_set.all %} + <li> + <a href="{{ series.get_absolute_url }}" target="_blank">{{ series }}</a> + </li> + {% endfor %} + </ul> + </div> + {% endif %} + </div> + </div> + {% endif %} + {% empty %} + <p> + There are no Journals yet in this branch of academia. + <strong>Help us to get started: nominate potential Fellows by <a href="mailto:admin@{{ request.get_host }}">emailing us</a> with your suggestions!</strong> + </p> + {% endfor %} + +{% else %} + + <h2 class="highlight">Full list of our Journals</h2> + <table class="table table-borderless"> + {% for branch in branches %} + {% for acad_field in branch.academic_fields.all %} + {% if acad_field.journals.active.all|length > 0 %} + <tr> + <td class="align-middle"><strong>{{ acad_field.name }}</strong></td> + <td> + <ul class="list-group m-2"> + {% for journal in acad_field.journals.active.all %} + <li class="list-group-item m-1 px-3 py-2 {{ journal.doi_label }}"> + <a href="{{ journal.get_absolute_url }}">{{ journal.name }}</a> + </li> + {% endfor %} + </ul> + </td> + </tr> + {% endif %} + {% endfor %} + {% endfor %} + </table> + + +{% endif %} diff --git a/scipost_django/scipost/templates/scipost/portal/portal.html b/scipost_django/scipost/templates/scipost/portal/portal.html index cb9f91812..ed2ce3164 100644 --- a/scipost_django/scipost/templates/scipost/portal/portal.html +++ b/scipost_django/scipost/templates/scipost/portal/portal.html @@ -81,27 +81,30 @@ <div class="tab-pane fade" id="journals" role="tabpanel" aria-labelledby="journals-tab"> - Journals + <div hx-get="{% url 'scipost:portal_hx_journals' %}" + hx-trigger="click from:#journals-tab, session-acad-field-set[document.getElementById('journals').classList.contains('active')] from:body" + > + </div> </div> <div class="tab-pane fade show active" id="publications" role="tabpanel" aria-labelledby="publications-tab"> <div hx-get="{% url 'scipost:portal_hx_publications' %}" hx-trigger="load, click from:#publications-tab, session-acad-field-set[document.getElementById('publications').classList.contains('active')] from:body, session-specialty-set[document.getElementById('publications').classList.contains('active')] from:body" - > + > + </div> </div> - </div> - <div class="tab-pane fade" id="submissions" - role="tabpanel" aria-labelledby="submissions-tab"> - <div hx-get="{% url 'scipost:portal_hx_submissions' %}" - hx-trigger="click from:#submissions-tab, session-acad-field-set[document.getElementById('submissions').classList.contains('active')] from:body, session-specialty-set[document.getElementById('submissions').classList.contains('active')] from:body" - > + <div class="tab-pane fade" id="submissions" + role="tabpanel" aria-labelledby="submissions-tab"> + <div hx-get="{% url 'scipost:portal_hx_submissions' %}" + hx-trigger="click from:#submissions-tab, session-acad-field-set[document.getElementById('submissions').classList.contains('active')] from:body, session-specialty-set[document.getElementById('submissions').classList.contains('active')] from:body" + > + </div> </div> - </div> - <div class="tab-pane fade" id="reports-needed" - role="tabpanel" aria-labelledby="reports-needed-tab"> + <div class="tab-pane fade" id="reports-needed" + role="tabpanel" aria-labelledby="reports-needed-tab"> Reports needed! </div> diff --git a/scipost_django/scipost/urls.py b/scipost_django/scipost/urls.py index c846a9265..aca8b90e4 100644 --- a/scipost_django/scipost/urls.py +++ b/scipost_django/scipost/urls.py @@ -88,6 +88,11 @@ urlpatterns = [ ), # HTMX-delivered fragments + path( + 'portal/_hx_journals', + TemplateView.as_view(template_name='scipost/portal/_hx_journals.html'), + name='portal_hx_journals' + ), path( 'portal/_hx_publications', views.portal_hx_publications, -- GitLab