diff --git a/rero_ils/modules/contributions/templates/rero_ils/_contribution_by_source.html b/rero_ils/modules/contributions/templates/rero_ils/_contribution_by_source.html new file mode 100644 index 0000000000..c052d7b2aa --- /dev/null +++ b/rero_ils/modules/contributions/templates/rero_ils/_contribution_by_source.html @@ -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 . + +#} + + +{% for agency in ["rero", "gnd", "idref"] %} +{% if record[agency] %} +
+
+
+
+ + + +
+
+

+ {{ _(agency) }} +

+
+
+
+
+
+
+   +
+
+
+ {% with data=record[agency], source_name='agency' %} + {% include('rero_ils/_contribution_by_source_data.html') %} + {% endwith %} +
+
+
+
+
+{% endif %} +{% endfor %} diff --git a/rero_ils/modules/contributions/templates/rero_ils/_contribution_by_source_data.html b/rero_ils/modules/contributions/templates/rero_ils/_contribution_by_source_data.html new file mode 100644 index 0000000000..2f7a8e2210 --- /dev/null +++ b/rero_ils/modules/contributions/templates/rero_ils/_contribution_by_source_data.html @@ -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 . + +#} + +{% 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) }} diff --git a/rero_ils/modules/contributions/templates/rero_ils/_contribution_unified.html b/rero_ils/modules/contributions/templates/rero_ils/_contribution_unified.html new file mode 100644 index 0000000000..c051ea7701 --- /dev/null +++ b/rero_ils/modules/contributions/templates/rero_ils/_contribution_unified.html @@ -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 . + +#} + +{% from 'rero_ils/macros/contribution.html' import dl, dl_bool, dl_permalink %} +{% set record = record %} +{% set data = record|contribution_merge_data_values %} + +
+ {{ 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) }} +
diff --git a/rero_ils/modules/contributions/templates/rero_ils/detailed_view_contribution.html b/rero_ils/modules/contributions/templates/rero_ils/detailed_view_contribution.html new file mode 100644 index 0000000000..d44ac1ffa7 --- /dev/null +++ b/rero_ils/modules/contributions/templates/rero_ils/detailed_view_contribution.html @@ -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 . + +#} + +{%- extends 'rero_ils/page.html' %} + +{%- block body %} +
+
+ {% if record.type == "bf:Organisation" %} + + {% else %} + + {% endif %} +
+
+

{{ record | contribution_label(current_i18n.language) }}

+ MEF ID: {{ record.pid }} +
+
+ + +{%- if record.documents %} +
+
+

{{ _('Documents') }}

+
+ +
+{% endif %} + +{% endblock body %} diff --git a/rero_ils/modules/contributions/templates/rero_ils/macros/contribution.html b/rero_ils/modules/contributions/templates/rero_ils/macros/contribution.html new file mode 100644 index 0000000000..8cf0970410 --- /dev/null +++ b/rero_ils/modules/contributions/templates/rero_ils/macros/contribution.html @@ -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 . + +#} + +{% macro dl(name, value, prefix) %} + {% if value %} +
+ {{ name }}: +
+
+ {% if value is string %} + {% if prefix %} + {{ _(prefix.format(v=value)) }} + {% else %} + {{ value }} + {% endif %} + {% else %} +
    + {% for element in value %} +
  • + {% if prefix %} + {{ _(prefix.format(v=element)) }} + {% else %} + {{ element | safe }} + {% endif %} + {% for source in value[element] %} + {{ source }} + {% endfor %} +
  • + {% endfor %} +
+ {% endif %} +
+ {% endif %} +{% endmacro %} + +{% macro dl_bool(name, value) %} + {% if value %} +
+ {{ name }}: +
+
+ +
+ {% endif %} +{% endmacro %} + +{% macro dl_permalink(name, record) %} +
+ {{ _(name) }}: +
+
+
    + {% for source in config.RERO_ILS_CONTRIBUTIONS_SOURCES %} + {% if record[source] %} +
  • + {{ record[source].pid }} + {{ source }} +
  • + {% endif %} + {% endfor %} +
+
+{% endmacro %} + +{% macro dl_permalink_by_source(name, data) %} + {% if data.pid %} +
+ {{ _(name) }}: +
+
+ {{ data.pid }} +
+ {% endif %} +{% endmacro %} diff --git a/tests/fixtures/metadata.py b/tests/fixtures/metadata.py index b511eb711f..3097909933 100644 --- a/tests/fixtures/metadata.py +++ b/tests/fixtures/metadata.py @@ -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, @@ -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") diff --git a/tests/ui/contributions/test_contributions_ui.py b/tests/ui/contributions/test_contributions_ui.py new file mode 100644 index 0000000000..66bdeb22d8 --- /dev/null +++ b/tests/ui/contributions/test_contributions_ui.py @@ -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 . + +"""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