diff --git a/rero_ils/config.py b/rero_ils/config.py index be1e843502..038e30dd89 100644 --- a/rero_ils/config.py +++ b/rero_ils/config.py @@ -1897,6 +1897,7 @@ def _(x): 'collections', 'contributions', 'documents', + 'holdings', 'items', 'item_types', 'ill_requests', @@ -1961,6 +1962,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..01f2461ecb --- /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 %} + + {{ _('Log in (to see request options)') }} + +{%- endif %} diff --git a/rero_ils/modules/documents/templates/rero_ils/_document_online.html b/rero_ils/modules/documents/templates/rero_ils/_document_online.html new file mode 100644 index 0000000000..6b460516f3 --- /dev/null +++ b/rero_ils/modules/documents/templates/rero_ils/_document_online.html @@ -0,0 +1,60 @@ +{# -*- 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 . + +#} +{% if accesses|length > 0 %} +
+ +
+
+
+ +
+
+ {{ _("Online") }} +
+
+
+ +
+
+ {% for access in accesses %} +
+
+
+
+   +
+
+ {{ access.type }} +
+
+ {{ access.content }} + {% if access.public_note %} + ({{ access.public_note }}) + {% endif %} +
+
+
+
+ {% endfor %} +
+
+
+{% 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..454ffe71a3 100644 --- a/rero_ils/modules/documents/templates/rero_ils/_documents_get.html +++ b/rero_ils/modules/documents/templates/rero_ils/_documents_get.html @@ -21,49 +21,8 @@ {% set accesses = record|get_accesses %} {% if accesses|length > 0 or holdings %} - - {% if accesses|length > 0 %} -
- -
-
-
- -
-
- {{ _("Online") }} -
-
-
- -
-
- {% for access in accesses %} -
-
-
-
-   -
-
- {{ access.type }} -
-
- {{ access.content }} - {% if access.public_note %} - ({{ access.public_note }}) - {% endif %} -
-
-
-
- {% endfor %} -
-
-
- {% endif %} + + {% include('rero_ils/_document_online.html') %} {%- if holdings %} @@ -174,13 +133,12 @@ {%- if number_items > 0 %} {%- for item in items %} -
+
+ {%- set call_number = item | format_record_call_number -%} + {%- if call_number %}
{{ _('Call number') }}
-
{{ item | format_record_call_number }}
-
- - {{ item|item_availability_text }} -
+
{{ item | format_record_call_number }}
+ {%- endif %} {%- set collections = item.pid|in_collection %} {%- if collections|length > 0 %}
{{ _('Temporary location') }}
@@ -206,40 +164,16 @@
{{ 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 %} -
- - - -
- {%- elif reasons %} -
- - - -
- {%- endif %} - {%- 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..bbd1497ad7 --- /dev/null +++ b/rero_ils/modules/documents/templates/rero_ils/_documents_get_book.html @@ -0,0 +1,84 @@ +{# -*- 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..0bf1a5fea9 --- /dev/null +++ b/rero_ils/modules/documents/templates/rero_ils/_request_button.html @@ -0,0 +1,70 @@ +{# -*- 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..b4ca0d8fab 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 @@ -118,13 +118,6 @@

- {% 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..0ca3204540 100644 --- a/rero_ils/modules/documents/views.py +++ b/rero_ils/modules/documents/views.py @@ -59,14 +59,28 @@ def doc_item_view_method(pid, record, template=None, **kwargs): current_app._get_current_object(), pid=pid, record=record) viewcode = kwargs['viewcode'] + organisation = None + if viewcode != current_app.config.get('RERO_ILS_SEARCH_GLOBAL_VIEW_CODE'): + 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 + query = results = HoldingsSearch()\ + .filter('term', document__pid=pid.pid_value) + if organisation: + query = query.filter('term', organisation__pid=organisation.pid) + results = query\ + .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/modules/patrons/views.py b/rero_ils/modules/patrons/views.py index a2527d4440..78f14625d0 100644 --- a/rero_ils/modules/patrons/views.py +++ b/rero_ils/modules/patrons/views.py @@ -134,7 +134,7 @@ def logged_user(): organisation_pid = patron.organisation_pid patron = patron.replace_refs() patron = patron.dumps() - for index, library in enumerate(patron.get('libraries')): + for index, library in enumerate(patron.get('libraries', [])): data = { 'pid': library['pid'], 'organisation': { 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; +}