Skip to content

Commit

Permalink
editor: add manual_merge endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Aslanoglou <[email protected]>
  • Loading branch information
chris-asl authored and ammirate committed Nov 1, 2017
1 parent 026db04 commit 314596e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions inspirehep/modules/editor/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from inspirehep.modules.pidstore.utils import get_pid_type_from_endpoint
from inspirehep.modules.tools import authorlist
from inspirehep.modules.workflows.workflows.manual_merge import start_merger
from inspirehep.utils.record_getter import get_db_record
from inspirehep.utils.references import (
get_refextract_kbs_path,
Expand Down Expand Up @@ -216,6 +217,17 @@ def get_rt_queues():
return jsonify(tickets.get_queues())


@blueprint.route('/manual_merge', methods=['POST'])
@editor_use_api_permission.require(http_exception=403)
def start_manual_merge():
"""Initiate manual merge on two records."""
assert request.json['head_recid']
assert request.json['update_recid']

workflow_id = start_merger(request.json['head_recid'], request.json['update_recid'], current_user.get_id())
return jsonify(workflow_object_id=workflow_id)


def _simplify_ticket_response(ticket):
return dict(
id=ticket['Id'],
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/editor/test_editor_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,21 @@ def test_refextract_url(log_in_as_cataloger, api_client):
assert response.status_code == 200
assert validate(references, subschema) is None
assert get_value({'references': references}, 'references.reference.publication_info.journal_title')


@patch('inspirehep.modules.editor.views.start_merger')
def test_manual_merge(mock_start_merger, log_in_as_cataloger, api_client):
mock_start_merger.return_value = 100

response = api_client.post(
'/editor/manual_merge',
content_type='application/json',
data=json.dumps({
'head_recid': 1000,
'update_recid': 1001,
})
)
assert response.status_code == 200

response_json = json.loads(response.data)
assert response_json['workflow_object_id'] == 100

0 comments on commit 314596e

Please sign in to comment.