Skip to content

Commit

Permalink
documents: add linked documents button
Browse files Browse the repository at this point in the history
* Closes #3006.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Sep 13, 2022
1 parent 6d1642d commit 0bb684e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,22 @@ <h3>
{% endfor %}
</div>
{% endif %}

<!-- LINKED DOCUMENTS -->
{% if linked_documents_count > 0 %}
<a
class="btn btn-sm btn-outline-primary mt-3"
href="{{ url_for('rero_ils.search', viewcode=viewcode, recordType='documents', q='partOf.document.pid:' ~ record.pid, simple=0) }}"
>
<i class="fa fa-list" aria-hidden="true"></i>
{{ linked_documents_count }}
{% if linked_documents_count < 2 %}
{{ _('article/volume') }}
{% else %}
{{ _(' articles/volumes') }}
{% endif %}
</a>
{% endif %}
</div>
</div>

Expand Down
12 changes: 11 additions & 1 deletion rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,24 @@ def doc_item_view_method(pid, record, template=None, **kwargs):
query = query.filter('term', organisation__pid=organisation.pid)
holdings_count = query.count()

# Counting linked documents
from .api import DocumentsSearch
query = DocumentsSearch()\
.filter('term', partOf__document__pid=pid.pid_value)
if organisation:
query = query.filter(
'term', holdings__organisation__organisation_pid=organisation.pid)
linked_documents_count = query.count()

return render_template(
template,
pid=pid,
record=record,
holdings_count=holdings_count,
viewcode=viewcode,
recordType='documents',
current_patrons=current_patrons
current_patrons=current_patrons,
linked_documents_count=linked_documents_count
)


Expand Down

0 comments on commit 0bb684e

Please sign in to comment.