Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contributions: restore missing Jinja templates #1874

Merged
merged 1 commit into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
12 changes: 6 additions & 6 deletions tests/fixtures/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def contribution_person_response_data(contribution_person_data):


@pytest.fixture(scope="module")
def contribution_person(contribution_person_data):
def contribution_person(app, contribution_person_data):
"""Load contribution person record."""
cont = Contribution.create(
data=contribution_person_data,
Expand Down Expand Up @@ -294,15 +294,15 @@ def contribution_organisation_response_data(contribution_organisation_data):


@pytest.fixture(scope="module")
def contribution_person(app, contribution_person_data):
"""Create mef contribution record."""
pers = Contribution.create(
data=contribution_person_data,
def contribution_organisation(app, contribution_organisation_data):
"""Create mef contribution organisation record."""
org = Contribution.create(
data=contribution_organisation_data,
delete_pid=False,
dbcommit=True,
reindex=True)
flush_index(ContributionsSearch.Meta.index)
return pers
return org


@pytest.fixture(scope="module")
Expand Down
37 changes: 37 additions & 0 deletions tests/ui/contributions/test_contributions_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- 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_person_detailed_view(client, contribution_person):
"""Test contribution person detailed view."""
res = client.get(url_for(
'contributions.persons_proxy',
viewcode='global', pid=contribution_person.pid))
assert res.status_code == 200


def test_contributions_organisation_detailed_view(
client, contribution_organisation):
"""Test contribution organisation detailed view."""
res = client.get(url_for(
'contributions.corporate_bodies_proxy',
viewcode='global', pid='cont_org'))
assert res.status_code == 200