Skip to content

Commit

Permalink
documents: fix document suppression problems
Browse files Browse the repository at this point in the history
* Fixes mef person index suppression problem when a document is deleted
* Fixes redirection after document suppression
* Closes rero#601, rero#552

Co-Authored-by: Renaud Michotte <renaud.michotte@gmail.com>
  • Loading branch information
zannkukai committed Nov 18, 2019
1 parent f9a2c1f commit 42c3723
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rero_ils/modules/documents/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def doc_item_view_method(pid, record, template=None, **kwargs):
pid=pid,
record=record,
holdings=holdings,
viewcode=viewcode
viewcode=viewcode,
recordType='documents'
)


Expand Down
4 changes: 4 additions & 0 deletions rero_ils/modules/indexer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def record_to_index(record):
# put all document in the same index
if re.search(r'/documents/', schema):
schema = re.sub(r'-.*\.json', '.json', schema)
# authorities specific transformation
if re.search(r'/authorities/', schema):
schema = re.sub(r'/authorities/', '/persons/', schema)
schema = re.sub(r'mef-person', 'mef_person', schema)
index, doc_type = schema_to_index(schema, index_names=index_names)

if index and doc_type:
Expand Down
6 changes: 6 additions & 0 deletions tests/ui/test_indexer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def test_record_to_index(app):
'documents/document-minimal-v0.0.1.json'
}) == ('documents-document', 'document')

# for mef-persons
assert record_to_index({
'$schema': 'http://mef.rero.ch/schemas/'
'authorities/mef-person-v0.0.1.json'
}) == ('persons-mef_person-v0.0.1', 'mef_person-v0.0.1')

# for others
assert record_to_index({
'$schema': 'https://ils.rero.ch/schema/'
Expand Down

0 comments on commit 42c3723

Please sign in to comment.