From 0ffb45b983a33c1ff603478a238f65e6e3125a82 Mon Sep 17 00:00:00 2001 From: Bertrand Zuchuat Date: Thu, 3 Dec 2020 13:58:47 +0100 Subject: [PATCH] document: holdings should be grouped by libraries The layout of the book type no longer shows the holdings structure. The buttons have been aligned on the vertical after the data. * closes #1399 Co-Authored-by: Bertrand Zuchuat --- rero_ils/config.py | 10 +++ .../templates/rero_ils/_anonymous_button.html | 27 ++++++ .../templates/rero_ils/_documents_get.html | 63 +++++++------- .../rero_ils/_documents_get_book.html | 83 +++++++++++++++++++ .../templates/rero_ils/_request_button.html | 71 ++++++++++++++++ .../rero_ils/detailed_view_documents.html | 6 +- rero_ils/modules/documents/views.py | 16 +++- .../scss/rero_ils/documents/detailed.scss | 6 +- .../theme/assets/scss/rero_ils/styles.scss | 15 ++++ 9 files changed, 256 insertions(+), 41 deletions(-) create mode 100644 rero_ils/modules/documents/templates/rero_ils/_anonymous_button.html create mode 100644 rero_ils/modules/documents/templates/rero_ils/_documents_get_book.html create mode 100644 rero_ils/modules/documents/templates/rero_ils/_request_button.html diff --git a/rero_ils/config.py b/rero_ils/config.py index 768a21d6a6..50035a59ad 100644 --- a/rero_ils/config.py +++ b/rero_ils/config.py @@ -1891,6 +1891,7 @@ def _(x): 'collections', 'contributions', 'documents', + 'holdings', 'items', 'item_types', 'ill_requests', @@ -1954,6 +1955,15 @@ def _(x): RECORDS_REST_DEFAULT_SORT['circ_policies'] = dict( query='bestmatch', noquery='name') +# ------ HOLDINGS SORT +RECORDS_REST_SORT_OPTIONS['holdings']['library_location'] = dict( + fields=['library.pid', 'location.pid'], + title='Holdings library location sort', + default_order='asc' +) +RECORDS_REST_DEFAULT_SORT['holdings'] = dict( + query='bestmatch', noquery='library_location') + # ------ ITEM TYPES SORT RECORDS_REST_SORT_OPTIONS['item_types']['name'] = dict( fields=['item_type_name'], title='Item type name', diff --git a/rero_ils/modules/documents/templates/rero_ils/_anonymous_button.html b/rero_ils/modules/documents/templates/rero_ils/_anonymous_button.html new file mode 100644 index 0000000000..c082d67912 --- /dev/null +++ b/rero_ils/modules/documents/templates/rero_ils/_anonymous_button.html @@ -0,0 +1,27 @@ +{# -*- coding: utf-8 -*- + + RERO ILS + Copyright (C) 2020 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 . + +#} +{%- if current_user.is_anonymous %} + + {{ _('Login (to see request options)') }} + +{%- endif %} diff --git a/rero_ils/modules/documents/templates/rero_ils/_documents_get.html b/rero_ils/modules/documents/templates/rero_ils/_documents_get.html index 11372409f7..62504b7ace 100644 --- a/rero_ils/modules/documents/templates/rero_ils/_documents_get.html +++ b/rero_ils/modules/documents/templates/rero_ils/_documents_get.html @@ -18,7 +18,6 @@ #} {% from 'rero_ils/macros/macro.html' import dl, dl_dict, dl_list, div_json %} - {% set accesses = record|get_accesses %} {% if accesses|length > 0 or holdings %} @@ -68,11 +67,8 @@ {%- if holdings %} - {%- if current_user.is_anonymous %} - - {{ _('Login (to see request options)') }} - - {%- endif %} + {% include 'rero_ils/_anonymous_button.html' %} + {%- for holding in holdings %} {% set items = holding.get_items | sort(attribute='enumerationAndChronology', reverse=True) %} {% set number_items = holding.get_items_count_by_holding_pid %} @@ -174,48 +170,34 @@ {%- if number_items > 0 %} {%- for item in items %} -
-
{{ _('Call number') }}
-
{{ item | format_record_call_number }}
-
- - {{ item|item_availability_text }} -
- {%- set collections = item.pid|in_collection %} +
{%- if collections|length > 0 %} -
{{ _('Temporary location') }}
-
- {%- for collection in collections %} - {%- if collection.published %} - - {{ collection.title }}{{ '' if loop.last else '; ' }} - - {%- endif %} - {%- endfor %} -
+
{{ _('Call number') }}
+
{{ item | format_record_call_number }}
{%- endif %} + {%- if item.get('enumerationAndChronology') %}
{{ _('Unit') }}
{{ item.get('enumerationAndChronology') }}
{%- endif %} +
{{ _('Barcode') }}
{{ item.barcode }}
+ {%- set public_notes = item|get_public_notes %} {%- for note in public_notes %}
{{ _(note.get('type')) }}
{{ note.get('content') | nl2br | safe }}
{%- endfor %} - - {%- if item|item_and_patron_in_same_organisation %} - {%- set can_request, reasons = item|can_request %} - {%- set locations = item|item_library_pickup_locations %} - {%- if can_request and locations %} -
-
+ {{ collection.title }}{{ '' if loop.last else '; ' }} {%- endif %} + {%- endif %} + {%- endfor %} +
{%- endif %} + +
{{ _('Status') }}
+
+ + {{ item|item_availability_text }} +
+ + {% with class='offset-1' %} + {% include 'rero_ils/_request_button.html' %} + {% endwith %}
{%- endfor %} {%- endif %} diff --git a/rero_ils/modules/documents/templates/rero_ils/_documents_get_book.html b/rero_ils/modules/documents/templates/rero_ils/_documents_get_book.html new file mode 100644 index 0000000000..3968b8f00a --- /dev/null +++ b/rero_ils/modules/documents/templates/rero_ils/_documents_get_book.html @@ -0,0 +1,83 @@ +{# -*- coding: utf-8 -*- + + RERO ILS + Copyright (C) 2020 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 . + +#} + +{%- if holdings %} + + +{% include 'rero_ils/_anonymous_button.html' %} + +
+{%- for holding in holdings %} +{% set items = holding.get_items | sort(attribute='enumerationAndChronology', reverse=True) %} + {%- for item in items %} +
+
{{ _('Location') }}
+
+ {{ holding|holding_location }} +
+ + {%- if collections|length > 0 %} +
{{ _('Call number') }}
+
{{ item | format_record_call_number }}
+ {%- endif %} + + {%- if item.get('enumerationAndChronology') %} +
{{ _('Unit') }}
+
+ {{ item.get('enumerationAndChronology') }} +
+ {%- endif %} + +
{{ _('Barcode') }}
+
{{ item.barcode }}
+ + {%- set public_notes = item|get_public_notes %} {%- for note in public_notes + %} +
{{ _(note.get('type')) }}
+
{{ note.get('content') | nl2br | safe }}
+ {%- endfor %} {%- set collections = item.pid|in_collection %} {%- if + collections|length > 0 %} +
{{ _('Temporary location') }}
+
+ {%- for collection in collections %} + {%- if collection.published %} + + {{ collection.title }}{{ '' if loop.last else '; ' }} + + {%- endif %} + {%- endfor %} +
+ {%- endif %} + +
{{ _('Status') }}
+
+ + {{ item|item_availability_text }} +
+ + {% include('rero_ils/_request_button.html') %} +
+ {%- endfor %} +{%- endfor %} +
+{%- endif %} diff --git a/rero_ils/modules/documents/templates/rero_ils/_request_button.html b/rero_ils/modules/documents/templates/rero_ils/_request_button.html new file mode 100644 index 0000000000..4e1555f01e --- /dev/null +++ b/rero_ils/modules/documents/templates/rero_ils/_request_button.html @@ -0,0 +1,71 @@ +{# -*- coding: utf-8 -*- + + RERO ILS + Copyright (C) 2020 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 . + +#} + +{%- if item|item_and_patron_in_same_organisation %} + {%- set can_request, reasons = item|can_request %} + {%- set locations = item|item_library_pickup_locations %} + {%- if can_request and locations %} +
+ + + +
+ {%- elif reasons %} +
+ + + +
+ {%- endif %} +{%- endif %} diff --git a/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html b/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html index 56a96e99ac..fb2adca3a2 100644 --- a/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html +++ b/rero_ils/modules/documents/templates/rero_ils/detailed_view_documents.html @@ -164,7 +164,11 @@

- {% include('rero_ils/_documents_get.html') %} + {%- if record.type == 'book' %} + {% include('rero_ils/_documents_get_book.html') %} + {%- else %} + {% include('rero_ils/_documents_get.html') %} + {%- endif %}
{% include('rero_ils/_documents_description.html') %} diff --git a/rero_ils/modules/documents/views.py b/rero_ils/modules/documents/views.py index 2eabe635f0..eb708772ec 100644 --- a/rero_ils/modules/documents/views.py +++ b/rero_ils/modules/documents/views.py @@ -59,14 +59,24 @@ def doc_item_view_method(pid, record, template=None, **kwargs): current_app._get_current_object(), pid=pid, record=record) viewcode = kwargs['viewcode'] + organisation = Organisation.get_record_by_viewcode(viewcode) record['available'] = record.is_available(viewcode) + # TODO: later Refactoring this part + # Use ES to order holdings records + # Pass directly the ES holdings to the template + # and create some pipe to process record + from ..holdings.api import HoldingsSearch + results = HoldingsSearch()\ + .filter('term', document__pid=pid.pid_value)\ + .filter('term', organisation__pid=organisation.pid)\ + .sort({'library_location': {"order": "asc"}})\ + .source('pid').scan() + holdings = [ Holding.get_record_by_pid(holding_pid).replace_refs() - for holding_pid in Holding.get_holdings_by_document_by_view_code( - document_pid=pid.pid_value, viewcode=viewcode - ) + for holding_pid in [r.pid for r in results] ] return render_template( diff --git a/rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss b/rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss index 86d1859284..9f67e51725 100644 --- a/rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss +++ b/rero_ils/theme/assets/scss/rero_ils/documents/detailed.scss @@ -28,9 +28,9 @@ content: ""; border-top: 1px solid #CCC; height: 1px; - width:80%; - left:10%; - top:0; + width: 96%; + left: 2%; + top: 0; } } dd { diff --git a/rero_ils/theme/assets/scss/rero_ils/styles.scss b/rero_ils/theme/assets/scss/rero_ils/styles.scss index 21ff015bdf..72aef1f2b4 100644 --- a/rero_ils/theme/assets/scss/rero_ils/styles.scss +++ b/rero_ils/theme/assets/scss/rero_ils/styles.scss @@ -147,3 +147,18 @@ div.tooltip div.tooltip-inner{ background-color: $red; color: white; } + + +/* + ********************************* + + BUTTON + + ******************************** +*/ +.btn-mini { + padding: .25rem .35rem .25rem .45rem; + font-size: .875rem; + line-height: 1.3; + border-radius: .2rem; +}