Skip to content

Commit

Permalink
homepage: custom description for organisations
Browse files Browse the repository at this point in the history
* Adds the possibility to define a custom template for the homepage of a dedicated organisation.
* Creates a blueprint for dedicated templates.
* Configures homepage template for HEPVS.
* Hides `allowedIps` in editor if the organisation is not shared.
* Hides label for custom fields by default.
* Moves field `platformName` after `allowedIps`.
* Closes #583.

Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
  • Loading branch information
Sébastien Délèze committed Jun 16, 2021
1 parent 3088bb3 commit 58671cf
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 12 deletions.
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
'pdf_extractor = \
sonar.modules.pdf_extractor.views.client:blueprint',
'validation = sonar.modules.validation.views:blueprint',
'collections = sonar.modules.collections.views:blueprint'
'collections = sonar.modules.collections.views:blueprint',
'dedicated = sonar.dedicated.views:blueprint'
],
'invenio_base.api_blueprints': [
'pdf_extractor = sonar.modules.pdf_extractor.views.api:blueprint',
Expand Down
1 change: 1 addition & 0 deletions sonar/config_sonar.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

SONAR_APP_ORGANISATION_CONFIG = {
'hepvs': {
'home_template': 'dedicated/hepvs/home.html',
'projects': True
}
}
Expand Down
19 changes: 19 additions & 0 deletions sonar/dedicated/templates/dedicated/hepvs/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<p>FREDI est l'acronyme de "Forschung – Recherche – Entwicklung – Développement – Innova(z)tion" la nouvelle
plateforme de dépôt des productions scientifiques et professionnelles en Open Access ainsi que des projets de
recherche de la Haute école pédagogique du Valais. De plus, selon la logique d'amélioration continue, la plateforme
FREDI permet de centraliser l'intégralité des données des projets de recherche à des fins d'optimisation du système
d'assurance qualité pour le domaine Recherche & Développement.</p>
<p class="m-0"><a href="#" class="toggle-display" data-target="long-description">En savoir plus&hellip;</a></p>
<p id="long-description" class="d-none mt-4">
Les résultats des travaux de recherche au sein d'équipes interdisciplinaires sont partagés avec l'ensemble du système
scolaire valaisan, de la communauté scientifique et professionnelle nationale et internationale. La HEP-VS joue un
rôle prépondérant dans la production des connaissances. Pour ce faire, elle met en place un outil pour les
utilisateurs et utilisatrices afin de rendre visible la production de savoirs théoriques et pratiques de l'institution
et les projets de recherche. La base de données de la plateforme FREDI regroupe l'ensemble des productions
scientifiques et professionnelles réalisées par les différentes équipes de recherche de l'institution. Dans la
perspective stratégique de la circularité des savoirs, la mise à disposition de ses publications et projets de
recherche est utile pour la communauté scientifique, mais aussi pour l'ensemble des acteurs et actrices du terrain. Ce
rôle et cet engagement de notre institution est une volonté de diffuser à l'échelle nationale et internationale la
littérature scientifique produite en son sein avec un accès public ou sous embargo afin que toutes personnes
intéressées par ces recherches puissent y accéder.
</p>
22 changes: 22 additions & 0 deletions sonar/dedicated/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
#
# Swiss Open Access Repository
# Copyright (C) 2021 RERO
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Dedicated organisations views."""

from flask import Blueprint

blueprint = Blueprint('dedicated', __name__, template_folder='templates')
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@
"type": "textarea",
"templateOptions": {
"rows": 10
}
},
"hideExpression": "!field.model.isShared"
}
},
"platformName": {
"title": "Platform name",
"type": "string",
"minLength": 1,
"form": {
"type": "markdown",
"templateOptions": {
"rows": 5
},
"hideExpression": "!field.model.isDedicated"
}
},
Expand All @@ -89,7 +94,7 @@
"label": {
"title": "Labels",
"type": "array",
"minItems": 1,
"default": [],
"items": {
"title": "Label",
"type": "object",
Expand Down Expand Up @@ -136,7 +141,7 @@
"label": {
"title": "Labels",
"type": "array",
"minItems": 1,
"default": [],
"items": {
"title": "Label",
"type": "object",
Expand Down Expand Up @@ -183,7 +188,7 @@
"label": {
"title": "Labels",
"type": "array",
"minItems": 1,
"default": [],
"items": {
"title": "Label",
"type": "object",
Expand Down Expand Up @@ -289,8 +294,8 @@
"description",
"isShared",
"isDedicated",
"platformName",
"allowedIps",
"platformName",
"documentsCustomField1",
"documentsCustomField2",
"documentsCustomField3"
Expand Down
20 changes: 14 additions & 6 deletions sonar/theme/templates/sonar/frontpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ <h1>{{ g.organisation.name }}</h1>
class="img-fluid" alt="{{ 'SONAR logo' }}">
{% endif %}
</a>
{% if g.get('organisation', {}).get('isDedicated') and g.get('organisation', {}).get('platformName') %}
<h1 class="mt-4 mb-0">{{ g.organisation['platformName'] }}</h1>
{% endif%}
</div>
</div>
{% if g.get('organisation', {}).get('isDedicated') and g.get('organisation', {}).get('platformName') %}
<div class="row justify-content-center">
<div class="col text-center">
<div class="mt-4 mb-0">{{ g.organisation['platformName'] | markdown_filter | safe }}</div>
</div>
</div>
{% endif%}
<div class="row justify-content-center">
<div class="col-lg-8 text-right my-4">
<form class="justify-content-end"
Expand Down Expand Up @@ -80,11 +84,15 @@ <h6 class="m-0 mt-1">
{%- block body %}
<div class="row justify-content-between">
{% if g.get('organisation', {}).get('isDedicated') %}
<div class="col-12">
{% if config.get('SONAR_APP_ORGANISATION_CONFIG', {}).get(g.organisation.pid, {}).get('home_template') %}
{% include config['SONAR_APP_ORGANISATION_CONFIG'][g.organisation.pid]['home_template'] %}
{% else %}
{% if g.organisation.get('description') %}
<div class="col-12">
{{ g.organisation.description | markdown_filter | safe }}
</div>
{{ g.organisation.description | markdown_filter | safe }}
{% endif %}
{% endif %}
</div>
{% else %}
<div class="col-lg-7">
<h5 class="home-text">
Expand Down
21 changes: 21 additions & 0 deletions sonar/theme/templates/sonar/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,30 @@
{%- block javascript %}
<script>
document.addEventListener("DOMContentLoaded", function () {
// Toggle display
const toggleDisplay = document.getElementsByClassName('toggle-display');
Array.prototype.forEach.call(toggleDisplay, function (el, i) {
el.addEventListener('click', function (event) {
const targetElement = document.getElementById(el.dataset.target);
if (targetElement) {
if (targetElement.className.search('d-none') !== -1) {
targetElement.classList.remove('d-none')
} else {
targetElement.classList.add('d-none')
}
}
event.preventDefault();
});
});

document.addEventListener('click', function (event) {
let link = event.target;

// Don't do anything if .toggle-display, the process is just above.
if (link.matches('.toggle-display')) {
return;
}

const dropdowns = document.getElementsByClassName('dropdown-menu show');

// If the clicked element doesn't have the right selector, bail
Expand Down

0 comments on commit 58671cf

Please # to comment.