Skip to content

Commit

Permalink
contributions: restore missing Jinja templates
Browse files Browse the repository at this point in the history
* Restores the contribution Jinja templates detailed view.

Co-Authored-by: Johnny Mariéthoz <[email protected]>
  • Loading branch information
jma committed May 4, 2021
1 parent 8939098 commit 9cb48d0
Show file tree
Hide file tree
Showing 6 changed files with 342 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019 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/>.

#}


{% for agency in ["rero", "gnd", "idref"] %}
{% if record[agency] %}
<article class="card m-md-4 m-2">
<div id="online_access" class="card-header p-2">
<div class="row">
<div class="col-1">
<a class="collapse-link" data-toggle="collapse" href="#collapse-{{ agency }}" aria-expanded="true">
<i class="fa fa-caret-down fa-lg"></i>
</a>
</div>
<div class="col-10">
<h4 class="card-title mb-0">
{{ _(agency) }}
</h4>
</div>
</div>
</div>
<div id="collapse-{{ agency }}" class="card-body collapse show" role="tabpanel">
<div class="row my-2">
<div class="col-1">
&nbsp;
</div>
<div class="col-10">
<dl class="row">
{% with data=record[agency], source_name='agency' %}
{% include('rero_ils/_contribution_by_source_data.html') %}
{% endwith %}
</dl>
</div>
</div>
</div>
</article>
{% endif %}
{% endfor %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019 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/>.

#}

{% from 'rero_ils/macros/contribution.html' import dl, dl_bool, dl_permalink_by_source %}

{{ dl(_('Birth date'), data.date_of_birth) }}
{{ dl(_('Death date'), data.date_of_death) }}
{% if data.language %}
{{ dl(_('Language'), data.language|translat('lang_')) }}
{% endif %}
{{ dl(_('Gender'), data.gender) }}
{{ dl(_('Biographical information'), data.biographical_information | join('\n') | urlActive('_blank') | nl2br | safe ) }}
{{ dl(_('Qualifier'), data.qualifier) }}
{{ dl(_('Numeration'), data.numeration) }}
{{ dl(_('Date establishment'), data.date_of_establishment) }}
{{ dl(_('Death termination'), data.date_of_termination) }}
{{ dl_bool(_('Conference'), data.conference) }}
{% if data.country_associated %}
{{ dl(_('Associated country'), data.country_associated|translat('country_')) }}
{% endif %}
{{ dl_permalink_by_source(_('ID'), data) }}
{{ dl(_('Authorized access point'), data.authorized_access_point) }}
{{ dl(_('Variant access point'), data.variant_access_point) }}
{{ dl(_('Parallel access point'), data.parallel_access_point) }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019 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/>.

#}

{% from 'rero_ils/macros/contribution.html' import dl, dl_bool, dl_permalink %}
{% set record = record %}
{% set data = record|contribution_merge_data_values %}

<dl class="row">
{{ dl(_('Birth date'), data.date_of_birth) }}
{{ dl(_('Death date'), data.date_of_death) }}
{% if data.language %}
{{ dl(_('Language'), data.language|translat_unified('lang_')) }}
{% endif %}
{{ dl(_('Gender'), data.gender) }}
{{ dl(_('Biographical information'), data.biographical_information | biographicaUrl) }}
{{ dl(_('Qualifier'), data.qualifier) }}
{{ dl(_('Numeration'), data.numeration) }}
{{ dl(_('Date establishment'), data.date_of_establishment) }}
{{ dl(_('Death termination'), data.date_of_termination) }}
{{ dl_bool(_('Conference'), data.conference) }}
{% if data.country_associated %}
{{ dl(_('Associated country'), data.country_associated|translat_unified('country_')) }}
{% endif %}
{{ dl_permalink(_('ID'), data) }}
{{ dl(_('Authorized access point'), data.authorized_access_point) }}
{{ dl(_('Variant access point'), data.variant_access_point) }}
{{ dl(_('Parallel access point'), data.parallel_access_point) }}
</dl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019 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/>.

#}

{%- extends 'rero_ils/page.html' %}

{%- block body %}
<header class="row">
<div class="rero-ils-person-icon col-sm-2 col-lg-1">
{% if record.type == "bf:Organisation" %}
<i class="fa fa-building-o fa-5x" title="{{ _('Organisation') }}" aria-hidden="true"></i>
{% else %}
<i class="fa fa-user-o fa-5x" title="{{ _('Person') }}" aria-hidden="true"></i>
{% endif %}
</div>
<hgroup class="col-sm-10 col-lg-11 align-self-end">
<h1 class="mb-0">{{ record | contribution_label(current_i18n.language) }}</h1>
<small>MEF ID: {{ record.pid }}</small>
</hgroup>
</header>
<article class="mt-4">
<header>
<nav>
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" href="#all-sources" data-toggle="tab"
id="all-sources-tab" title="{{ _('All sources') }}" role="tab"
aria-controls="all-sources" aria-selected="true">
<i class="fa fa-list-ul"></i> {{ _('Unified') }}
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#by-source" data-toggle="tab"
id="by-source-tab" title="{{ _('By source') }}" role="tab"
aria-controls="by-source" aria-selected="false">
<i class="fa fa-bars"></i> {{ _('By source') }}
</a>
</li>
</ul>
</nav>
</header>
<article class="tab-content">
<section class="tab-pane show active p-4" id="all-sources" role="tabpanel" aria-labelledby="all-sources-tab">
{% include('rero_ils/_contribution_unified.html') %}
</section>
<section class="tab-pane row" id="by-source" role="tabpanel" aria-labelledby="by-source-tab">
{% include('rero_ils/_contribution_by_source.html') %}
</section>
</article>
</article>
<!-- Documents -->
{%- if record.documents %}
<section class="pt-4 border-top">
<header class="mb-2">
<h3>{{ _('Documents') }}</h3>
</header>
<ul class="list-group">
{% for document in record.documents %}
<li class="list-group-item border-0">
<a class="font-weight-bold" href="{{ url_for('invenio_records_ui.doc', viewcode=viewcode, pid_value=document.pid) }}">{{ document.title | create_title_text }}</a>
</li>
{% endfor %}
</ul>
</section>
{% endif %}

{% endblock body %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{# -*- coding: utf-8 -*-

RERO ILS
Copyright (C) 2019 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/>.

#}

{% macro dl(name, value, prefix) %}
{% if value %}
<dt class="col-md-3 col-lg-2 rero-ils-term">
{{ name }}:
</dt>
<dd class="col-md-9 col-lg-10">
{% if value is string %}
{% if prefix %}
{{ _(prefix.format(v=value)) }}
{% else %}
{{ value }}
{% endif %}
{% else %}
<ul class="list-unstyled rero-ils-contribution mb-0">
{% for element in value %}
<li>
{% if prefix %}
{{ _(prefix.format(v=element)) }}
{% else %}
{{ element | safe }}
{% endif %}
{% for source in value[element] %}
<small class="badge badge-secondary text-uppercase">{{ source }}</small>
{% endfor %}
</li>
{% endfor %}
</ul>
{% endif %}
</dd>
{% endif %}
{% endmacro %}

{% macro dl_bool(name, value) %}
{% if value %}
<dt class="col-md-3 col-lg-2 rero-ils-term">
{{ name }}:
</dt>
<dd class="col-md-9 col-lg-10">
<i class="fa fa-check fa-lg"></i>
</dd>
{% endif %}
{% endmacro %}

{% macro dl_permalink(name, record) %}
<dt class="col-md-3 col-lg-2 rero-ils-term">
{{ _(name) }}:
</dt>
<dd class="col-md-9 col-lg-10">
<ul class="list-unstyled rero-ils-contribution">
{% for source in config.RERO_ILS_CONTRIBUTIONS_SOURCES %}
{% if record[source] %}
<li>
<a class="rero-ils-external-link" href="{{ record[source].identifier }}">{{ record[source].pid }}</a>
<small class="badge badge-secondary text-uppercase">{{ source }}</small>
</li>
{% endif %}
{% endfor %}
</ul>
</dd>
{% endmacro %}

{% macro dl_permalink_by_source(name, data) %}
{% if data.pid %}
<dt class="col-md-3 col-lg-2 rero-ils-term">
{{ _(name) }}:
</dt>
<dd class="col-md-9 col-lg-10">
<a class="rero-ils-external-link" href="{{ data.identifier }}">{{ data.pid }}</a>
</dd>
{% endif %}
{% endmacro %}
32 changes: 32 additions & 0 deletions tests/ui/contributions/test_contributions_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# -*- coding: utf-8 -*-
#
# RERO ILS
# Copyright (C) 2019 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/>.

"""Tests UI view for patrons."""


from flask import url_for


def test_contributions_detailed_view(client, contribution_person_data,
document_ref):
"""Test contribution detailed view."""
# check redirection
res = client.get(url_for(
'invenio_records_ui.cont', viewcode='global', pid_value='cont_pers'))
assert res.status_code == 200

# TODO: add search view

0 comments on commit 9cb48d0

Please sign in to comment.