diff --git a/data/complete_document_sample.json b/data/complete_document_sample.json index aa8e5e8a..dd6ca4c9 100644 --- a/data/complete_document_sample.json +++ b/data/complete_document_sample.json @@ -1,4 +1,5 @@ { + "documentType": "coar:c_3248", "identifiedBy": [ { "value": "urn:nbn:ch:rero-006-108713", @@ -15,11 +16,17 @@ "type": "bf:Language" } ], + "classification": [ + { + "classificationPortion": "621.38", + "type": "bf:ClassificationUdc" + } + ], "contribution": [ { "agent": { "type": "bf:Person", - "preferred_name": "John, Doe", + "preferred_name": "Brenda, Collins", "date_of_birth": "1960", "date_of_death": "2000" }, @@ -27,6 +34,54 @@ "cre" ], "affiliation": "Institute for Research" + }, + { + "agent": { + "type": "bf:Person", + "preferred_name": "Esther, Owens", + "identifiedBy": { + "source": "ORCID", + "type": "bf:Doi", + "value": "1111-2222-3333-4444" + } + }, + "role": [ + "cre" + ], + "controlledAffiliation": [ + "HEP Vaud" + ], + "affiliation": "Haute école Pédagogique de Lausanne" + }, + { + "agent": { + "type": "bf:Person", + "preferred_name": "Joe, Holloway" + }, + "role": [ + "cre" + ], + "affiliation": "Institute for Research" + }, + { + "agent": { + "type": "bf:Person", + "preferred_name": "Edgar, Sowards" + }, + "role": [ + "cre" + ], + "affiliation": "Institute for Research" + }, + { + "agent": { + "type": "bf:Person", + "preferred_name": "Lauren, Sena" + }, + "role": [ + "ctb" + ], + "affiliation": "Institute for Research" } ], "title": [ @@ -50,16 +105,51 @@ "abstracts": [ { "language": "eng", - "value": "Abstract of the document" + "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id ex vitae ipsum fermentum auctor vitae eget sem. Nam sed facilisis metus. Nullam dignissim massa vel leo euismod, quis rutrum neque cursus. Quisque fermentum libero ut urna tincidunt interdum. Fusce condimentum accumsan ipsum vel mattis. Sed ultricies tellus sed ultrices semper. Vestibulum hendrerit risus at dui gravida, nec pulvinar mauris imperdiet. Cras iaculis massa a pellentesque vulputate. Mauris ac tellus sit amet risus suscipit ullamcorper. Donec fermentum tellus in ligula ullamcorper, eu condimentum elit tincidunt. Suspendisse lacinia porta velit, quis mattis quam posuere eu. Nam feugiat massa magna, bibendum vestibulum eros feugiat nec. Ut quis semper lectus, in porttitor nibh." + }, + { + "language": "fre", + "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum id ex vitae ipsum fermentum auctor vitae eget sem. Nam sed facilisis metus. Nullam dignissim massa vel leo euismod, quis rutrum neque cursus. Quisque fermentum libero ut urna tincidunt interdum. Fusce condimentum accumsan ipsum vel mattis. Sed ultricies tellus sed ultrices semper. Vestibulum hendrerit risus at dui gravida, nec pulvinar mauris imperdiet. Cras iaculis massa a pellentesque vulputate. Mauris ac tellus sit amet risus suscipit ullamcorper. Donec fermentum tellus in ligula ullamcorper, eu condimentum elit tincidunt. Suspendisse lacinia porta velit, quis mattis quam posuere eu. Nam feugiat massa magna, bibendum vestibulum eros feugiat nec. Ut quis semper lectus, in porttitor nibh." } ], "subjects": [ { - "language": "eng", - "value": [ - "Time series models", - "GARCH models" - ] + "label": { + "language": "eng", + "value": [ + "Time series models", + "GARCH models" + ] + }, + "source": "Source" + }, + { + "label": { + "language": "fre", + "value": [ + "Sujet 1", + "Sujet 2" + ] + } + } + ], + "partOf": [ + { + "document": { + "contribution": [ + "Renato, Ferrari", + "Albano, Mesta" + ], + "publication": { + "startDate": "2019-05-05", + "statement": "John Doe Publications inc." + }, + "title": "Journal du dimanche" + }, + "numberingPages": "135-139", + "numberingYear": "2020", + "numberingVolume": "6", + "numberingIssue": "12" } ], "provisionActivity": [ @@ -125,24 +215,15 @@ "value": "Zeng Lingliang zhu bian" } }, - "copyrightDate": [ - "© 1971" - ], - "series": [ + "otherEdition": [ { - "name": "Collection One", - "number": "5" - }, - { - "name": "Collection Two", - "number": "123" + "document": { + "electronicLocator": "https://www.rero.ch" + }, + "publicNote": "Published version" } ], - "notes": [ - "Note 1", - "Note 2" - ], "organisation": { - "$ref": "https://sonar.ch/api/organisations/org" + "$ref": "https://sonar.ch/api/organisations/rero" } } diff --git a/sonar/modules/deposits/api.py b/sonar/modules/deposits/api.py index 8d9d484c..370b9a83 100644 --- a/sonar/modules/deposits/api.py +++ b/sonar/modules/deposits/api.py @@ -238,7 +238,7 @@ def create_document(self): # ORCID for contributor if contributor.get('orcid'): data['agent']['identifiedBy'] = { - 'type': 'bf:Doi', + 'type': 'bf:Local', 'source': 'ORCID', 'value': contributor['orcid'] } diff --git a/sonar/modules/documents/api.py b/sonar/modules/documents/api.py index 74ee6193..71555f3a 100644 --- a/sonar/modules/documents/api.py +++ b/sonar/modules/documents/api.py @@ -20,6 +20,8 @@ import csv from functools import partial +from flask import current_app + from ..api import SonarIndexer, SonarRecord, SonarSearch from ..fetchers import id_fetcher from ..minters import id_minter @@ -94,6 +96,21 @@ def get_affiliations(full_affiliation): return controlled_affiliations + @staticmethod + def get_permanent_link(host, pid, org=None): + """Return the permanent link for the document. + + :param host: Application server host. + :param org: Organisation key. + :param pid: PID of the document. + :returns: Document's full URL as string. + """ + if not org: + org = current_app.config.get('SONAR_APP_DEFAULT_ORGANISATION') + + return current_app.config.get('SONAR_DOCUMENTS_PERMALINK').format( + host=host, org=org, pid=pid) + @classmethod def get_record_by_identifier(cls, identifiers): """Get a record by its identifier. diff --git a/sonar/modules/documents/config.py b/sonar/modules/documents/config.py index a7b14b08..984b5323 100644 --- a/sonar/modules/documents/config.py +++ b/sonar/modules/documents/config.py @@ -28,3 +28,6 @@ SONAR_DOCUMENTS_ORGANISATIONS_EXTERNAL_FILES = ['csal'] """Display external files URL for these organisations.""" + +SONAR_DOCUMENTS_PERMALINK = '{host}organisation/{org}/documents/{pid}' +"""Permalink for accessing documents details.""" diff --git a/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json b/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json index c82c100f..2bf4a54f 100644 --- a/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json +++ b/sonar/modules/documents/jsonschemas/documents/document-v1.0.0_src.json @@ -1066,13 +1066,18 @@ "title": "Type", "type": "string", "enum": [ - "bf:Doi" + "bf:Doi", + "bf:Local" ], "form": { "options": [ { "label": "bf:Doi", "value": "bf:Doi" + }, + { + "label": "bf:Local", + "value": "bf:Local" } ] } diff --git a/sonar/modules/documents/marshmallow/json.py b/sonar/modules/documents/marshmallow/json.py index 635d88ec..d670fae1 100644 --- a/sonar/modules/documents/marshmallow/json.py +++ b/sonar/modules/documents/marshmallow/json.py @@ -21,6 +21,7 @@ from functools import partial +from flask import request from flask_security import current_user from invenio_records_rest.schemas import Nested, StrictKeysMixin from invenio_records_rest.schemas.fields import GenFunction, \ @@ -29,7 +30,8 @@ from sonar.modules.documents.api import DocumentRecord from sonar.modules.documents.permissions import DocumentPermission -from sonar.modules.documents.views import is_file_restricted +from sonar.modules.documents.views import create_publication_statement, \ + is_file_restricted, part_of_format from sonar.modules.serializers import schema_from_context from sonar.modules.users.api import current_user_record @@ -96,6 +98,7 @@ class DocumentMetadataSchemaV1(StrictKeysMixin): data_key="$schema", deserialize=schema_from_document) permissions = fields.Dict(dump_only=True) + permalink = fields.Dict(dump_only=True) @pre_dump def add_files_restrictions(self, item): @@ -135,6 +138,34 @@ def add_permissions(self, item): return item + @pre_dump + def add_permalink(self, item): + """Add permanent link to document.""" + item['permalink'] = DocumentRecord.get_permanent_link( + request.host_url, item['pid']) + return item + + @pre_dump + def add_formatted_texts(self, item): + """Add formatted texts for objects which are processing in backend. + + :param item: Dict of record data. + :returns: Modified data. + """ + # Provision activity processing + for index, provision_activity in enumerate( + item.get('provisionActivity', [])): + item['provisionActivity'][index][ + 'text'] = create_publication_statement(provision_activity) + + # Part of proccessing + for index, part_of in enumerate( + item.get('partOf', [])): + item['partOf'][index][ + 'text'] = part_of_format(part_of) + + return item + @pre_load def guess_organisation(self, data, **kwargs): """Guess organisation from current logged user. @@ -152,6 +183,19 @@ def guess_organisation(self, data, **kwargs): return data + @pre_load + def remove_formatted_texts(self, data): + """Removes formatted texts from `provisionActivity` and `partOf` fields. + + :param data: Dict of record data. + :returns: Modified data. + """ + for provision_activity in data.get('provisionActivity', []): + provision_activity.pop('text', None) + + for part_of in data.get('partOf', []): + part_of.pop('text', None) + class DocumentSchemaV1(StrictKeysMixin): """Document schema.""" diff --git a/sonar/modules/documents/templates/documents/record.html b/sonar/modules/documents/templates/documents/record.html index 3e589b7d..a774769c 100644 --- a/sonar/modules/documents/templates/documents/record.html +++ b/sonar/modules/documents/templates/documents/record.html @@ -17,234 +17,200 @@ {%- extends config.RECORDS_UI_BASE_TEMPLATE %} -{% from 'sonar/macros/macro.html' import dl, dl_dict, dl_list, thumbnail %} +{% from 'sonar/macros/macro.html' import thumbnail %} {%- block body %} {% set record = record.replace_refs() %} {% set title = record.title[0] | title_format(current_i18n.language) %} +{% set files = record._files | files_by_type %} -

{{ title }}

-{% if record.organisation %} -
{{ _(record.organisation.name) }}
-{% endif %}
-
-
- {% set main_file = record._files | files_by_type | first %} - {% if main_file %} - {{ thumbnail('documents', record, main_file, 'col-sm-3') }} +
+
+ {% if files and files | length > 0 %} +
+ {{ thumbnail('documents', record, files | first) }} +
{% endif %} -
-
- - {% if record.specificCollections %} - {{ dl_list(_('Specific collections'), record.specificCollections) }} - {% endif %} - - - {% if record.contribution|length > 0 %} -
- {{ _('Contributions') }}: -
-
-
    - {% for contribution in record.contribution %} -
  • - {{ _(contribution.agent.type) }} - {% for role in contribution.role %} - {{ _('contribution_role_' + role) }} - {% endfor %} - {{ contribution.agent.preferred_name }} -
  • - {% endfor %} -
-
- {% endif %} - - - {% if record.documentType %} - {{ dl(_('Document type'), _('document_type_' + record.documentType)) }} - {% endif %} - - - {% if record.editionStatement %} - {{ dl(_('Edition'), record.editionStatement.editionDesignation.value ~ ' / ' ~ record.editionStatement.responsibility.value) }} - {% endif %} - - - {% for provision_activity in record.provisionActivity %} - {{ dl_dict(_(provision_activity.type), provision_activity|create_publication_statement ) }} + + {% if record.documentType %} +
{{ _('document_type_' + record.documentType) }}
+ {% endif %} + {% if files and files | length > 1 %} +

+ + {{ (files | length) - 1 }} {{ _('other files') }} +

+ {% endif %} +
+
+

{{ title }}

+ + + {% set contributors = record | contributors %} + {% if contributors | length > 0 %} +
+
    + {% for contribution in contributors %} +
  • + {{ contribution.agent.preferred_name }} + {% if not 'cre' in contribution.role %} + ({{ _('contribution_role_' + contribution.role[0]) | lower }}) + {% endif %} + {% if contribution.agent.get('identifiedBy', {}).get('value') %} + + ORCID + + {% endif %} + + {% if contribution.get('affiliation') %} + {% if contribution.get('controlledAffiliation') %} + {{ contribution.affiliation }} + {% else %} + {{ contribution.affiliation }} + {% endif %} + {% endif %} +
  • {% endfor %} +
+ {% if record.contribution | length > 3 %} + {{ _('Show more') }}… + {% endif %} + {% endif %} +
- - {% if record.copyrightDate %} - {{ dl(_('Copyright date'), record.copyrightDate|join(', ')) }} - {% endif %} - - - {% if record.abstracts|length > 0 %} - {{ dl(_('Abstract'), record.abstracts|abstracts_format|nl2br) }} - {% endif %} - - - {% if record.extent or record.otherMaterialCharacteristics or record.formats %} - {% set formats = ', '.join(record.formats) %} - {% set description = ', '.join([record.extent, record.otherMaterialCharacteristics, formats]|select) %} - {{ dl(_('Physical description'), description) }} - {% endif %} - - - {% if record.additionalMaterials %} - {{ dl(_('Additional Materials'), record.additionalMaterials) }} - {% endif %} - - - {% if record.series|length > 0 %} - {{ dl(_('Series'), record.series|series_format) }} - {% endif %} - - - {% if record.partOf %} -
- {{ _('Is part of') }}: -
-
-
    - {% for item in record.partOf %} -
  • {{ item | part_of_format }}
  • - {% endfor %} -
-
- {% endif %} - - - {% if record.subjects|length > 0 %} -
- {{ _('Subjects') }}: -
-
-
    - {% for subject in record.subjects|subjects_format(current_i18n.language) %} -
  • - {{ subject.value }} - {% if subject.source %} - {{ subject.source }} - {% endif %} -
  • - {% endfor %} -
-
- {% endif %} - - - {% if record.notes|length > 0 %} -
- {{ _('Notes') }}: -
-
-
    - {% for note in record.notes %} -
  • - {{ note }} -
  • - {% endfor %} -
-
- {% endif %} + + {% for provision_activity in record.provisionActivity %} +
    + {% set statement = provision_activity | create_publication_statement %} + {% for element in statement %} +
  • {{ statement[element] }}
  • + {% endfor %} +
+ {% endfor %} - - {% if record.contentNote|length > 0 %} -
- {{ _('Contains') }}: -
-
-
    - {% for note in record.contentNote %} -
  • - {{ note }} -
  • - {% endfor %} -
-
- {% endif %} + + {% if record.extent %} +

{{ record.extent }}

+ {% endif %} - {% if record.identifiedBy|identifiedby_format|length > 0 %} -
- {{ _('Identifiers') }}: -
-
-
    - {% for identifier in record.identifiedBy|identifiedby_format %} -
  • - {{ identifier.value }} - {{ identifier.type }} -
  • - {% endfor %} -
-
- {% endif %} + + {% if record.partOf and record.partOf | length > 0 %} +
+
{{ _('Published in') }}:
+
+
    + {% for item in record.partOf %} +
  • {{ item | part_of_format }}
  • + {% endfor %} +
+
+
+ {% endif %} - {% if record.language %} -
- {{ _('Languages') }}: -
-
-
    - {% for language in record.language %} -
  • - {{ _('lang_' + language.value) }} -
  • - {% endfor %} -
-
- {% endif %} + + {% if record.subjects|length > 0 %} +
+ {% for subject in record.subjects %} + {% for value in subject.label.value %} +
+ + {{ value }} + +
+ {% endfor %} + {% endfor %} +
+ {% endif %} - {% if record.dissertation %} - {% if record.dissertation.degree %} - {{ dl(_('Thesis note'), record.dissertation.degree) }} - {% endif %} - {% if record.dissertation.note %} - {{ dl_list(_('Jury note'), record.dissertation.note) }} - {% endif %} + + {% set abstracts = record | abstracts %} + {% if abstracts|length > 0 %} +
+ {% for abstract in abstracts %} + {{ _('lang_' + abstract.language) }} + {% endfor %} + {% for abstract in abstracts %} + + {% if abstract.value | length > 400 %} + {{ abstract.value | truncate(400) }} {{ _('Show more') }}… + {% else %} + {{ abstract.value | nl2br | safe }} {% endif %} + + {% endfor %} +
+ {% endif %} - - {% if record.otherEdition %} -
- {{ _('Other editions') }}: -
-
- {% for otherEdition in record.otherEdition %} -

{{ _(otherEdition.publicNote) }} : {{ otherEdition.document.electronicLocator }}

+
+ + {% if record.otherEdition %} +
+ {{ _('Other electronic version') }} +
+
+ {% for otherEdition in record.otherEdition %} +

{{ otherEdition.publicNote }} : {{ otherEdition.document.electronicLocator }}

+ {% endfor %} +
+ {% endif %} + + + {% if record.language %} +
+ {{ _('Language') }} +
+
+
    + {% for language in record.language %} +
  • + {{ _('lang_' + language.value) }} +
  • {% endfor %} -
- {% endif %} - - {% if record.usageAndAccessPolicy %} - {{ dl_list(_('Usage and access policy'), record.usageAndAccessPolicy) }} - {% endif %} - - - {% set link = url_for('documents.detail', pid_value=record.pid, view=view_code, _external=True) %} - {{ dl(_('Permalink'), '' + link + '') }} -
-
+ + + {% endif %} + + + {% if record.classification and record.classification | length > 0 %} + {% for classification in record.classification %} +
+ {{ _('Classification') }} +
+
+ {{ _('classification_' + classification.classificationPortion) }} +
+ {% endfor %} + {% endif %} + + + {% set link = record.get_permanent_link(request.host_url, record.pid, view_code) %} +
+ {{ _('Permalink') }} +
+
+ {{ link }} +
+
+
- {% set files = record._files | files_by_type %} - {% if files and files | length > 1 %} -
{{ _('Other files') }}
- -
- {% for file in files %} - {% if loop.index > 1 %} - {{ thumbnail('documents', record, file, 'col-sm-3 mb-4') }} - {% endif %} - {% endfor %} -
+ {% if files and files | length > 1 %} +
{{ _('Other files') }}
+
+
+ {% for file in files %} + {% if loop.index > 1 %} + {{ thumbnail('documents', record, file, 'col-lg-2 mb-4') }} {% endif %} -
+ {% endfor %} + + {% endif %}
-
diff --git a/sonar/theme/templates/sonar/macros/macro.html b/sonar/theme/templates/sonar/macros/macro.html index f43113ad..7087f2bd 100644 --- a/sonar/theme/templates/sonar/macros/macro.html +++ b/sonar/theme/templates/sonar/macros/macro.html @@ -15,53 +15,6 @@ along with this program. If not, see . #} -{% macro dl(title, content) %} -
- {{ title }}: -
-
- {{ content|safe }} -
-{% endmacro %} - -{% macro dl_dict(name, dict_or_string) %} -{% if dict_or_string %} -
- {{ name }}: -
-
- {% if dict_or_string is string %} - {{ dict_or_string }} - {% else %} -
    - {% for element in dict_or_string %} -
  • {{ dict_or_string[element] }}
  • - {% endfor %} -
- {% endif %} -
-{% endif %} -{% endmacro %} - -{% macro dl_list(name, list_or_string) %} -{% if list_or_string %} -
- {{ name }}: -
-
- {% if list_or_string is string %} - {{ list_or_string }} - {% else %} -
    - {% for element in list_or_string %} -
  • {{ element }}
  • - {% endfor %} -
- {% endif %} -
-{% endif %} -{% endmacro %} - {% macro thumbnail(resource_type, record, file, class = '') %} {% set thumbnail = file | thumbnail(record._files) %} {% if thumbnail %} diff --git a/sonar/theme/templates/sonar/manage.html b/sonar/theme/templates/sonar/manage.html index 45213f8a..d0236c63 100644 --- a/sonar/theme/templates/sonar/manage.html +++ b/sonar/theme/templates/sonar/manage.html @@ -1,5 +1,5 @@ - + {{ _("SONAR administration") }} diff --git a/sonar/translations/de/LC_MESSAGES/messages.po b/sonar/translations/de/LC_MESSAGES/messages.po index 2f551007..b9b70e28 100644 --- a/sonar/translations/de/LC_MESSAGES/messages.po +++ b/sonar/translations/de/LC_MESSAGES/messages.po @@ -6,7 +6,6 @@ # Translators: # Nicolas Prongué , 2020 # Sébastien Délèze , 2020 -#, fuzzy msgid "" msgstr "" "Project-Id-Version: sonar 0.4.0\n" @@ -41,9 +40,6 @@ msgstr "" msgid "Action" msgstr "" -msgid "Additional Materials" -msgstr "" - msgid "Additional materials" msgstr "" @@ -109,9 +105,6 @@ msgstr "" msgid "Comment" msgstr "" -msgid "Contains" -msgstr "" - msgid "Content note" msgstr "" @@ -136,9 +129,6 @@ msgstr "" msgid "Controlled affiliations" msgstr "" -msgid "Copyright date" -msgstr "" - msgid "Current cataloguing step." msgstr "" @@ -316,9 +306,6 @@ msgstr "" msgid "Is dedicated" msgstr "" -msgid "Is part of" -msgstr "" - msgid "Is shared" msgstr "" @@ -328,9 +315,6 @@ msgstr "" msgid "Italian" msgstr "" -msgid "Jury note" -msgstr "" - msgid "Key" msgstr "" @@ -420,9 +404,6 @@ msgid "" "coloured." msgstr "" -msgid "Other editions" -msgstr "" - msgid "Other electronic version" msgstr "" @@ -447,9 +428,6 @@ msgstr "" msgid "Phone number with the international prefix, without spaces." msgstr "" -msgid "Physical description" -msgstr "" - msgid "Place" msgstr "" @@ -493,6 +471,9 @@ msgstr "" msgid "Publication" msgstr "" +msgid "Published in" +msgstr "" + msgid "Publisher" msgstr "" @@ -538,6 +519,9 @@ msgstr "" msgid "Series to which belongs the resource." msgstr "" +msgid "Show more" +msgstr "" + msgid "Sign Up" msgstr "" @@ -636,9 +620,6 @@ msgstr "" msgid "The project" msgstr "" -msgid "Thesis note" -msgstr "" - msgid "" "This field corresponds to the exact publication date of the article, if " "known." @@ -2717,6 +2698,9 @@ msgstr "Zazaisch" msgid "no." msgstr "" +msgid "other files" +msgstr "" + msgid "p." msgstr "" diff --git a/sonar/translations/en/LC_MESSAGES/messages.po b/sonar/translations/en/LC_MESSAGES/messages.po index a88ae00e..62bf6df1 100644 --- a/sonar/translations/en/LC_MESSAGES/messages.po +++ b/sonar/translations/en/LC_MESSAGES/messages.po @@ -5,12 +5,11 @@ # # Translators: # Sébastien Délèze , 2020 -#, fuzzy msgid "" msgstr "" "Project-Id-Version: sonar 0.4.0\n" "Report-Msgid-Bugs-To: software@rero.ch\n" -"POT-Creation-Date: 2020-07-15 13:31+0200\n" +"POT-Creation-Date: 2020-07-09 07:52+0200\n" "PO-Revision-Date: 2020-05-13 05:58+0000\n" "Last-Translator: Sébastien Délèze , 2020\n" "Language: en\n" @@ -40,9 +39,6 @@ msgstr "" msgid "Action" msgstr "" -msgid "Additional Materials" -msgstr "" - msgid "Additional materials" msgstr "" @@ -108,9 +104,6 @@ msgstr "" msgid "Comment" msgstr "" -msgid "Contains" -msgstr "" - msgid "Content note" msgstr "" @@ -135,9 +128,6 @@ msgstr "" msgid "Controlled affiliations" msgstr "" -msgid "Copyright date" -msgstr "" - msgid "Current cataloguing step." msgstr "" @@ -315,9 +305,6 @@ msgstr "" msgid "Is dedicated" msgstr "" -msgid "Is part of" -msgstr "" - msgid "Is shared" msgstr "" @@ -327,9 +314,6 @@ msgstr "" msgid "Italian" msgstr "" -msgid "Jury note" -msgstr "" - msgid "Key" msgstr "" @@ -419,9 +403,6 @@ msgid "" "coloured." msgstr "" -msgid "Other editions" -msgstr "" - msgid "Other electronic version" msgstr "" @@ -446,9 +427,6 @@ msgstr "" msgid "Phone number with the international prefix, without spaces." msgstr "" -msgid "Physical description" -msgstr "" - msgid "Place" msgstr "" @@ -492,6 +470,9 @@ msgstr "" msgid "Publication" msgstr "" +msgid "Published in" +msgstr "" + msgid "Publisher" msgstr "" @@ -537,6 +518,9 @@ msgstr "" msgid "Series to which belongs the resource." msgstr "" +msgid "Show more" +msgstr "" + msgid "Sign Up" msgstr "" @@ -635,9 +619,6 @@ msgstr "" msgid "The project" msgstr "" -msgid "Thesis note" -msgstr "" - msgid "" "This field corresponds to the exact publication date of the article, if " "known." @@ -2716,6 +2697,9 @@ msgstr "Zaza" msgid "no." msgstr "" +msgid "other files" +msgstr "" + msgid "p." msgstr "" diff --git a/sonar/translations/fr/LC_MESSAGES/messages.po b/sonar/translations/fr/LC_MESSAGES/messages.po index d18483cf..a3a1af4a 100644 --- a/sonar/translations/fr/LC_MESSAGES/messages.po +++ b/sonar/translations/fr/LC_MESSAGES/messages.po @@ -7,12 +7,11 @@ # Nicolas Prongué , 2020 # MarionRERO , 2020 # Sébastien Délèze , 2020 -#, fuzzy msgid "" msgstr "" "Project-Id-Version: sonar 0.4.0\n" "Report-Msgid-Bugs-To: software@rero.ch\n" -"POT-Creation-Date: 2020-07-15 13:31+0200\n" +"POT-Creation-Date: 2020-07-09 07:52+0200\n" "PO-Revision-Date: 2020-05-13 05:58+0000\n" "Last-Translator: Sébastien Délèze , 2020\n" "Language: fr\n" @@ -42,9 +41,6 @@ msgstr "Conditions d'acquisition" msgid "Action" msgstr "Action" -msgid "Additional Materials" -msgstr "Documents supplémentaires" - msgid "Additional materials" msgstr "Documents supplémentaires" @@ -110,9 +106,6 @@ msgstr "" msgid "Comment" msgstr "Commentaire" -msgid "Contains" -msgstr "Contient" - msgid "Content note" msgstr "Note de contenu" @@ -137,9 +130,6 @@ msgstr "Affiliation contrôlée" msgid "Controlled affiliations" msgstr "Affiliations contrôlées" -msgid "Copyright date" -msgstr "Date de droit d'auteur" - msgid "Current cataloguing step." msgstr "Etape actuelle de catalogage" @@ -323,9 +313,6 @@ msgstr "Invenio" msgid "Is dedicated" msgstr "" -msgid "Is part of" -msgstr "Fait partie de" - msgid "Is shared" msgstr "" @@ -335,9 +322,6 @@ msgstr "" msgid "Italian" msgstr "italien" -msgid "Jury note" -msgstr "Note du jury" - msgid "Key" msgstr "Clé" @@ -429,9 +413,6 @@ msgstr "" "Autres caractéristiques matérielles, par ex. illustrations, noir et blanc" " ou couleur." -msgid "Other editions" -msgstr "Autres éditions" - msgid "Other electronic version" msgstr "Autre version électronique" @@ -456,9 +437,6 @@ msgstr "Numéro de téléphone" msgid "Phone number with the international prefix, without spaces." msgstr "Numéro de téléphone avec le préfixe international, sans espaces." -msgid "Physical description" -msgstr "Description physique" - msgid "Place" msgstr "Lieu" @@ -502,6 +480,9 @@ msgstr "Note publique" msgid "Publication" msgstr "Publication" +msgid "Published in" +msgstr "" + msgid "Publisher" msgstr "Editeur" @@ -547,6 +528,9 @@ msgstr "Série" msgid "Series to which belongs the resource." msgstr "Série à laquelle appartient la ressource." +msgid "Show more" +msgstr "" + msgid "Sign Up" msgstr "S'inscrire" @@ -650,9 +634,6 @@ msgstr "" msgid "The project" msgstr "Le projet" -msgid "Thesis note" -msgstr "Note de thèse" - msgid "" "This field corresponds to the exact publication date of the article, if " "known." @@ -2733,6 +2714,9 @@ msgstr "zazaki" msgid "no." msgstr "no." +msgid "other files" +msgstr "Autres fichiers" + msgid "p." msgstr "p." diff --git a/sonar/translations/it/LC_MESSAGES/messages.po b/sonar/translations/it/LC_MESSAGES/messages.po index 168192c4..6d31f088 100644 --- a/sonar/translations/it/LC_MESSAGES/messages.po +++ b/sonar/translations/it/LC_MESSAGES/messages.po @@ -6,12 +6,11 @@ # Translators: # Nicolas Prongué , 2020 # Sébastien Délèze , 2020 -#, fuzzy msgid "" msgstr "" "Project-Id-Version: sonar 0.4.0\n" "Report-Msgid-Bugs-To: software@rero.ch\n" -"POT-Creation-Date: 2020-07-15 13:31+0200\n" +"POT-Creation-Date: 2020-07-09 07:52+0200\n" "PO-Revision-Date: 2020-05-13 05:58+0000\n" "Last-Translator: Sébastien Délèze , 2020\n" "Language: it\n" @@ -41,9 +40,6 @@ msgstr "" msgid "Action" msgstr "" -msgid "Additional Materials" -msgstr "" - msgid "Additional materials" msgstr "" @@ -109,9 +105,6 @@ msgstr "" msgid "Comment" msgstr "" -msgid "Contains" -msgstr "" - msgid "Content note" msgstr "" @@ -136,9 +129,6 @@ msgstr "" msgid "Controlled affiliations" msgstr "" -msgid "Copyright date" -msgstr "" - msgid "Current cataloguing step." msgstr "" @@ -316,9 +306,6 @@ msgstr "" msgid "Is dedicated" msgstr "" -msgid "Is part of" -msgstr "" - msgid "Is shared" msgstr "" @@ -328,9 +315,6 @@ msgstr "" msgid "Italian" msgstr "" -msgid "Jury note" -msgstr "" - msgid "Key" msgstr "" @@ -420,9 +404,6 @@ msgid "" "coloured." msgstr "" -msgid "Other editions" -msgstr "" - msgid "Other electronic version" msgstr "" @@ -447,9 +428,6 @@ msgstr "" msgid "Phone number with the international prefix, without spaces." msgstr "" -msgid "Physical description" -msgstr "" - msgid "Place" msgstr "" @@ -493,6 +471,9 @@ msgstr "" msgid "Publication" msgstr "" +msgid "Published in" +msgstr "" + msgid "Publisher" msgstr "" @@ -538,6 +519,9 @@ msgstr "" msgid "Series to which belongs the resource." msgstr "" +msgid "Show more" +msgstr "" + msgid "Sign Up" msgstr "" @@ -636,9 +620,6 @@ msgstr "" msgid "The project" msgstr "" -msgid "Thesis note" -msgstr "" - msgid "" "This field corresponds to the exact publication date of the article, if " "known." @@ -2717,6 +2698,9 @@ msgstr "zaza" msgid "no." msgstr "" +msgid "other files" +msgstr "" + msgid "p." msgstr "" diff --git a/sonar/translations/messages.pot b/sonar/translations/messages.pot index 70ca82dd..a99cbbeb 100644 --- a/sonar/translations/messages.pot +++ b/sonar/translations/messages.pot @@ -3,12 +3,11 @@ # This file is distributed under the same license as the sonar project. # FIRST AUTHOR , 2020. # -#, fuzzy msgid "" msgstr "" "Project-Id-Version: sonar 0.5.0\n" "Report-Msgid-Bugs-To: software@rero.ch\n" -"POT-Creation-Date: 2020-07-15 13:31+0200\n" +"POT-Creation-Date: 2020-07-09 07:52+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -36,9 +35,6 @@ msgstr "" msgid "Action" msgstr "" -msgid "Additional Materials" -msgstr "" - msgid "Additional materials" msgstr "" @@ -104,9 +100,6 @@ msgstr "" msgid "Comment" msgstr "" -msgid "Contains" -msgstr "" - msgid "Content note" msgstr "" @@ -131,9 +124,6 @@ msgstr "" msgid "Controlled affiliations" msgstr "" -msgid "Copyright date" -msgstr "" - msgid "Current cataloguing step." msgstr "" @@ -311,9 +301,6 @@ msgstr "" msgid "Is dedicated" msgstr "" -msgid "Is part of" -msgstr "" - msgid "Is shared" msgstr "" @@ -323,9 +310,6 @@ msgstr "" msgid "Italian" msgstr "" -msgid "Jury note" -msgstr "" - msgid "Key" msgstr "" @@ -415,9 +399,6 @@ msgid "" "coloured." msgstr "" -msgid "Other editions" -msgstr "" - msgid "Other electronic version" msgstr "" @@ -442,9 +423,6 @@ msgstr "" msgid "Phone number with the international prefix, without spaces." msgstr "" -msgid "Physical description" -msgstr "" - msgid "Place" msgstr "" @@ -488,6 +466,9 @@ msgstr "" msgid "Publication" msgstr "" +msgid "Published in" +msgstr "" + msgid "Publisher" msgstr "" @@ -533,6 +514,9 @@ msgstr "" msgid "Series to which belongs the resource." msgstr "" +msgid "Show more" +msgstr "" + msgid "Sign Up" msgstr "" @@ -631,9 +615,6 @@ msgstr "" msgid "The project" msgstr "" -msgid "Thesis note" -msgstr "" - msgid "" "This field corresponds to the exact publication date of the article, if " "known." @@ -2712,6 +2693,9 @@ msgstr "" msgid "no." msgstr "" +msgid "other files" +msgstr "" + msgid "p." msgstr "" diff --git a/tests/api/documents/test_documents_permissions.py b/tests/api/documents/test_documents_permissions.py index b2cc5d9a..dccc8e14 100644 --- a/tests/api/documents/test_documents_permissions.py +++ b/tests/api/documents/test_documents_permissions.py @@ -170,6 +170,12 @@ def test_read(client, document, make_user, superuser, admin, moderator, 'read': True, 'update': True } + assert res.json['metadata']['partOf'][0][ + 'text'] == 'Journal du dimanche, 2020, vol. 6, no. 12, p. 135-139' + assert res.json['metadata']['provisionActivity'][0]['text'] == { + 'default': + 'Bienne : Impr. Weber, [2006] ; Lausanne ; Rippone : Impr. Coustaud' + } # Logged as admin login_user_via_session(client, email=admin['email']) diff --git a/tests/conftest.py b/tests/conftest.py index 4b71c486..58a7d916 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -321,6 +321,20 @@ def document_json(app, db, organisation): 'type': 'bf:Agent' }] }], + 'partOf': [{ + 'document': { + 'contribution': ['Renato, Ferrari', 'Albano, Mesta'], + 'publication': { + 'startDate': '2019-05-05', + 'statement': 'John Doe Publications inc.' + }, + 'title': 'Journal du dimanche' + }, + 'numberingPages': '135-139', + 'numberingYear': '2020', + 'numberingVolume': '6', + 'numberingIssue': '12' + }], 'editionStatement': { 'editionDesignation': { 'value': 'Di 3 ban' diff --git a/tests/ui/deposits/test_deposits_api.py b/tests/ui/deposits/test_deposits_api.py index a2cfe8f8..5a271d57 100644 --- a/tests/ui/deposits/test_deposits_api.py +++ b/tests/ui/deposits/test_deposits_api.py @@ -101,7 +101,7 @@ def test_create_document(app, client, deposit, user): 'type': 'bf:Person', 'identifiedBy': { 'source': 'ORCID', - 'type': 'bf:Doi', + 'type': 'bf:Local', 'value': '1234-5678-1234-5678' } }, @@ -122,7 +122,7 @@ def test_create_document(app, client, deposit, user): 'type': 'bf:Person', 'identifiedBy': { 'source': 'ORCID', - 'type': 'bf:Doi', + 'type': 'bf:Local', 'value': '1234-5678-1234-5678' } }, diff --git a/tests/ui/documents/test_documents_views.py b/tests/ui/documents/test_documents_views.py index 9f0d89e4..f4026534 100644 --- a/tests/ui/documents/test_documents_views.py +++ b/tests/ui/documents/test_documents_views.py @@ -116,102 +116,6 @@ def test_title_format(document): assert views.title_format(title, 'it') == 'Title EN : Subtitle IT' -def test_publishers_format(): - """Test publishers format.""" - result = 'Foo; place1; place2: Foo; Bar' - assert result == views.publishers_format([{ - 'name': ['Foo'] - }, { - 'place': ['place1', 'place2'], - 'name': ['Foo', 'Bar'] - }]) - - -def test_series_format(): - """Test series format.""" - result = 'serie 1; serie 2, 2018' - assert result == views.series_format([{ - 'name': 'serie 1' - }, { - 'name': 'serie 2', - 'number': '2018' - }]) - - -def test_abstracts_format(): - """Test series format.""" - abstracts = [{ - 'language': 'eng', - 'value': 'Abstract' - }, { - 'language': 'fre', - 'value': 'Résumé' - }] - - result = 'Abstract\n\nRésumé' - assert result == views.abstracts_format(abstracts) - - -def test_subjects_format(document): - """Test subjects format.""" - subjects = [{ - 'label': { - 'value': ['subject 1', 'subject 2'], - 'language': 'eng' - } - }, { - 'label': { - 'value': ['sujet 1', 'sujet 2'], - 'language': 'fre' - } - }, { - 'label': { - 'value': ['subject with source 1', 'subject with source 2'] - }, - 'source': 'RERO' - }] - - assert views.subjects_format(subjects, 'en') == [{ - 'value': - 'subject 1 ; subject 2' - }, { - 'value': 'subject with source 1 ; subject with source 2', - 'source': 'RERO' - }] - - assert views.subjects_format(subjects, 'de') == [{ - 'value': 'subject with source 1 ; subject with source 2', - 'source': 'RERO' - }] - - -def test_identifiedby_format(): - """Test identifiedBy format.""" - identifiedby = [{ - 'type': 'bf:Local', - 'source': 'RERO', - 'value': 'R008745599' - }, { - 'type': 'bf:Isbn', - 'value': '9782844267788' - }, { - 'type': 'bf:Local', - 'source': 'BNF', - 'value': 'FRBNF452959040000002' - }, { - 'type': 'uri', - 'value': 'http://catalogue.bnf.fr/ark:/12148/cb45295904f' - }] - results = [{ - 'type': 'Isbn', - 'value': '9782844267788' - }, { - 'type': 'uri', - 'value': 'http://catalogue.bnf.fr/ark:/12148/cb45295904f' - }] - assert results == views.identifiedby_format(identifiedby) - - def test_create_publication_statement(document): """Test create publication statement.""" publication_statement = views.create_publication_statement( @@ -538,3 +442,43 @@ def test_get_current_organisation_code(app, organisation): with app.test_request_context() as req: req.request.args = {'view': 'unisi'} assert views.get_current_organisation_code() == 'unisi' + + +def test_abstracts(app): + """Test getting ordered abstracts.""" + # Abstracts are ordered, english first. + abstracts = [{ + 'language': 'fre', + 'value': 'Résumé' + }, { + 'language': 'eng', + 'value': 'Summary' + }] + assert views.abstracts({'abstracts': abstracts})[0]['language'] == 'eng' + + # No abstract + assert views.abstracts({}) == [] + + +def test_contributors(): + """Test ordering contributors.""" + contributors = [{ + 'role': ['dgs'] + }, { + 'role': ['ctb'] + }, { + 'role': ['prt'] + }, { + 'role': ['edt'] + }, { + 'role': ['cre'] + }] + + priorities = ['cre', 'ctb', 'dgs', 'edt', 'prt'] + + for index, contributor in enumerate( + views.contributors({'contribution': contributors})): + assert contributor['role'][0] == priorities[index] + + # No contributors + assert views.contributors({}) == []