Commit e0f1cdcd authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Modify the callback INHIBIT_HARVESTER_ON_CATEGORY.

Rename it INHIBIT_HARVESTER
Avoid the duplication of identical harvester which is very easy with the wizard.
parent c6e772a7
......@@ -88,6 +88,7 @@
"Can't delete this record since several publications refer to it.": 'Impossible de détruire cet enregistrement car des publications lui font référence.',
"Can't insert the article.": 'Impossible de créer cet article.',
"Can't insert the harvester.": 'Impossible de créer ce moissonneur.',
"Can't insert the harvester. ": "Impossible de créer ce moissonneur. ",
"Can't insert the report.": 'Impossible de créer ce rapport.',
"Can't insert the talk/proceeding.": 'Impossible de créer cet acte ou présentation.',
"Can't updated a publication marked OK.": "Impossible d'actualiser une publication marquée OK.",
......@@ -293,6 +294,7 @@
'HTTP Error': 'HTTP Error',
'id': 'id',
'Id': 'Id',
'Identical harvester already exists.': 'Ce moissonneur existe dans la base de données.',
'Import/Export': 'Importer/Exporter',
'insert MARCXML': 'insérer MARCXML',
'insert new': 'insert new',
......
......@@ -12,7 +12,7 @@ from callbacks import (INHIBIT_CASCADE_DELETE,
INHIBIT_CONTROLLER_INSERT,
INHIBIT_CONTROLLER_UPDATE,
INHIBIT_DUPLICATE_PUBLICATION,
INHIBIT_HARVESTER_ON_CATEGORY,
INHIBIT_HARVESTER,
INHIBIT_PUBLICATION_DELETE_ON_OK,
INHIBIT_PUBLICATION_UPDATE_ON_OK)
......
......@@ -24,7 +24,7 @@ db.define_table("harvesters",
Field("scan", "boolean", comment=tp_scan, default=False),
migrate="harvesters.table")
db.harvesters._before_insert.append(INHIBIT_HARVESTER_ON_CATEGORY)
db.harvesters._before_insert.append(INHIBIT_HARVESTER)
db.harvesters.collections.filter_in = dbui.CLEAN_SPACES
db.harvesters.controller.filter_in = dbui.CLEAN_SPACES
......
......@@ -187,12 +187,15 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
return False
def INHIBIT_HARVESTER_ON_CATEGORY(harvester):
"""Inhibit the insert of similar harvesters.
def INHIBIT_HARVESTER(harvester):
"""Inhibit the insert of similar harvesters:
For a project, one automaton can only proceed publication
of the same code, e.g ACL or ACLN but not both, but automatons
can scan different stores.
* For a project, one automaton can only proceed publication
of the same code, e.g ACL or ACLN but not both, but automatons
can scan different stores.
* Reject identical harvester, same project, controller, store,
collection and category.
Args:
harvester (dict): harvester fields passed to insert.
......@@ -209,7 +212,7 @@ def INHIBIT_HARVESTER_ON_CATEGORY(harvester):
id_projects=harvester['id_projects'],
id_teams=harvester['id_teams'])
if not id_harvester:
if id_harvester is None:
return False
# for a project, one automaton can only proceed publication
......@@ -226,6 +229,23 @@ def INHIBIT_HARVESTER_ON_CATEGORY(harvester):
return True
# duplicate harvesters
id_harvester = get_id(db.harvesters,
collections=harvester['collections'],
controller=harvester['controller'],
host=harvester['host'],
id_categories=harvester['id_categories'],
id_projects=harvester['id_projects'],
id_teams=harvester['id_teams'])
if id_harvester is not None:
db.harvesters[CALLBACK_ERRORS] = [
T("Can't insert the harvester. "),
T("Identical harvester already exists.")]
return True
return False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment