Skip to content

Commit

Permalink
ES: fix listeners
Browse files Browse the repository at this point in the history
* Fixes patron listener for bulk indexing.

Co-Authored-by: Peter Weber <peter.weber@rero.ch>
  • Loading branch information
rerowep and rerowep committed Feb 7, 2020
1 parent e51ab17 commit 5bc39af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 3 additions & 1 deletion rero_ils/modules/fees/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def enrich_fee_data(sender, json=None, record=None, index=None,
:param doc_type: The doc_type for the record.
"""
if index == '-'.join([FeesSearch.Meta.index, doc_type]):
fee = Fee.get_record_by_pid(record.get('pid'))
fee = record
if not isinstance(record, Fee):
fee = Fee.get_record_by_pid(record.get('pid'))
org_pid = fee.organisation_pid
json['organisation'] = {
'pid': org_pid
Expand Down
7 changes: 5 additions & 2 deletions rero_ils/modules/patrons/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""Signals connector for patron."""

from .api import PatronsSearch
from .api import Patron, PatronsSearch


def enrich_patron_data(sender, json=None, record=None, index=None,
Expand All @@ -30,7 +30,10 @@ def enrich_patron_data(sender, json=None, record=None, index=None,
:param doc_type: The doc_type for the record.
"""
if index == '-'.join([PatronsSearch.Meta.index, doc_type]):
org_pid = record.get_organisation()['pid']
patron = record
if not isinstance(record, Patron):
patron = Patron.get_record_by_pid(record.get('pid'))
org_pid = patron.get_organisation()['pid']
if org_pid:
json['organisation'] = {
'pid': org_pid
Expand Down
4 changes: 3 additions & 1 deletion rero_ils/modules/persons/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,7 @@ def enrich_persons_data(sender, json=None, record=None, index=None,
:param doc_type: The doc_type for the record.
"""
if index == '-'.join([PersonsSearch.Meta.index, doc_type]):
person = Person.get_record_by_pid(record.get('pid'))
person = record
if not isinstance(record, Person):
person = Person.get_record_by_pid(record.get('pid'))
json['organisations'] = person.organisation_pids

0 comments on commit 5bc39af

Please sign in to comment.