forked from rero/rero-ils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fees: add organisation search filter
* Create new signal to enrich data before indexing. * Add organisation pid in indexed fields. * Closes rero#560 (search api return 0 records). Co-Authored-by: Lauren-D <laurent.dubois@itld-solutions.be>
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- 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 <http://www.gnu.org/licenses/>. | ||
|
||
"""Signals connector for Fee.""" | ||
|
||
from .api import Fee, FeesSearch | ||
|
||
|
||
def enrich_fee_data(sender, json=None, record=None, index=None, | ||
**dummy_kwargs): | ||
"""Signal sent before a record is indexed. | ||
:params json: The dumped record dictionary which can be modified. | ||
:params record: The record being indexed. | ||
:params index: The index in which the record will be indexed. | ||
:params doc_type: The doc_type for the record. | ||
""" | ||
fee_index_name = FeesSearch.Meta.index | ||
if index.startswith(fee_index_name): | ||
fee = Fee.get_record_by_pid(record.get('pid')) | ||
org_pid = fee.organisation_pid | ||
json['organisation'] = { | ||
'pid': org_pid | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters