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

Migrate check and fix methos to edit_insert controller

parent f01ca146
...@@ -8,8 +8,8 @@ import traceback ...@@ -8,8 +8,8 @@ import traceback
from gluon import current from gluon import current
from gluon.restricted import RestrictedError from gluon.restricted import RestrictedError
from harvest_tools import (build_harvester_tool, from harvest_tools import (build_harvester_tool,
CheckAndFix,
DRY_RUN, DRY_RUN,
get_rex_institute,
MsgCollection) MsgCollection)
from plugin_dbui import (inline_alert, from plugin_dbui import (inline_alert,
Selector, Selector,
...@@ -21,6 +21,8 @@ from store_tools import (CheckException, ...@@ -21,6 +21,8 @@ from store_tools import (CheckException,
OAI_URL, OAI_URL,
RecordCdsConfPaper, RecordCdsConfPaper,
RecordCdsThesis, RecordCdsThesis,
RecordHepConfPaper,
RecordHepThesis,
search_synonym, search_synonym,
ToolException) ToolException)
...@@ -92,7 +94,7 @@ def free_run(): ...@@ -92,7 +94,7 @@ def free_run():
def edit_insert(): def edit_insert():
"""Edit an invenio record and insert it in the database. """Edit a record and insert it in the database.
Note: Note:
Recovery procedures are applied to fix basic non-conformity, but Recovery procedures are applied to fix basic non-conformity, but
...@@ -177,19 +179,20 @@ def edit_insert(): ...@@ -177,19 +179,20 @@ def edit_insert():
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# #
# CheckAndFix (general) # fix basic non-conformity (general)
# - is record with authors
# - is record with authors form my institute
# - standardise name of collaboration
# - format authors according to my format
# - extract authors form my institute signing the publication
# - check and fix submitted date
# #
check = CheckAndFix()
# authors # authors
try: try:
check.authors(record) record.check_and_fix(fmt_author="F. Last",
check.format_authors(record, fmt="F. Last") rex_institute=get_rex_institute(db, current.app),
sep_author=", ",
check.my_affiliation( sort_author=True)
record, selector.id_projects, selector.id_teams)
check.get_my_authors(record, sort=True)
except CheckException as e: except CheckException as e:
logger.debug(str(e)) logger.debug(str(e))
...@@ -203,14 +206,13 @@ def edit_insert(): ...@@ -203,14 +206,13 @@ def edit_insert():
values["PublicationsAuthors"] = record.authors() values["PublicationsAuthors"] = record.authors()
values["PublicationsAuthors_institute"] = record.my_authors values["PublicationsAuthors_institute"] = record.my_authors
# collaboration # repeat collaboration check
recId = UNDEF_ID
try: try:
recId = UNDEF_ID
recId = search_synonym(db.collaborations, recId = search_synonym(db.collaborations,
"collaboration", "collaboration",
record.collaboration()) record.collaboration())
except ToolException as e: except ToolException as e:
logger.debug(str(e))
pass pass
values["PublicationsId_collaborations"] = int(recId) values["PublicationsId_collaborations"] = int(recId)
...@@ -232,15 +234,15 @@ def edit_insert(): ...@@ -232,15 +234,15 @@ def edit_insert():
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# #
# CheckAndFix (article) # fix basic non-conformity (article)
# #
if selector.controller in ("articles", "proceedings"): if selector.controller in ("articles", "proceedings"):
check.paper_reference(record)
check.format_editor(record)
recId = UNDEF_ID
try: try:
record.format_editor()
record.check_paper_reference()
recId = UNDEF_ID
recId = search_synonym(db.publishers, recId = search_synonym(db.publishers,
"abbreviation", "abbreviation",
record.paper_editor()) record.paper_editor())
...@@ -255,19 +257,19 @@ def edit_insert(): ...@@ -255,19 +257,19 @@ def edit_insert():
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# #
# CheckAndFix (conference) # fix basic non-conformity (conference)
# #
if selector.controller in ("proceedings", "talks"): if selector.controller in ("proceedings", "talks"):
try: if isinstance(record, (RecordCdsConfPaper, RecordHepConfPaper)):
check.country(record)
check.conference_date(record)
except CheckException as e: try:
logger.debug(str(e)) record.check_conference_date()
pass
except CheckException as e:
logger.debug(str(e))
pass
if isinstance(record, RecordCdsConfPaper):
values["PublicationsConference_title"] = \ values["PublicationsConference_title"] = \
record.conference_title() record.conference_title()
...@@ -280,8 +282,8 @@ def edit_insert(): ...@@ -280,8 +282,8 @@ def edit_insert():
values["PublicationsConference_town"] = \ values["PublicationsConference_town"] = \
record.conference_town() record.conference_town()
recId = UNDEF_ID
try: try:
recId = UNDEF_ID
recId = search_synonym(db.countries, recId = search_synonym(db.countries,
"country", "country",
record.conference_country()) record.conference_country())
...@@ -297,25 +299,24 @@ def edit_insert(): ...@@ -297,25 +299,24 @@ def edit_insert():
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# #
# CheckAndFix (theses) # fix basic non-conformity (thesis)
# #
if selector.controller == "theses": if selector.controller == "theses":
if isinstance(record, RecordCdsThesis): if isinstance(record, (RecordCdsThesis, RecordHepThesis)):
record.format_universities()
values["PublicationsUniversities"] = \ values["PublicationsUniversities"] = \
record.these_universities() record.these_universities()
values["PublicationsDirectors"] = record.these_directors() values["PublicationsDirectors"] = record.these_directors()
values["PublicationsDefense"] = record.these_defense() values["PublicationsDefense"] = record.these_defense()
# ------------------------------------------------------------------------
#
# submitted date and year # submitted date and year
try: #
check.submitted(record)
except (CheckException, ToolException) as e:
logger.debug(str(e))
pass
values["PublicationsSubmitted"] = record.submitted() values["PublicationsSubmitted"] = record.submitted()
if record.is_published(): if record.is_published():
......
...@@ -13,7 +13,6 @@ from .base import (DRY_RUN, ...@@ -13,7 +13,6 @@ from .base import (DRY_RUN,
from .automaton import Automaton from .automaton import Automaton
from .articles import Articles from .articles import Articles
from .checkandfix import CheckAndFix, MONTHS
from .factory import build_harvester_tool, get_harvester_tool from .factory import build_harvester_tool, get_harvester_tool
from .msg import Msg from .msg import Msg
from .msgcollection import MsgCollection from .msgcollection import MsgCollection
......
...@@ -572,6 +572,7 @@ class RecordCdsPubli(dict, AuthorsMixin, PublicationInfoMixin): ...@@ -572,6 +572,7 @@ class RecordCdsPubli(dict, AuthorsMixin, PublicationInfoMixin):
* standardise name of collaboration * standardise name of collaboration
* format authors according to my format * format authors according to my format
* extract authors form my institute signing the publication * extract authors form my institute signing the publication
* check and fix submitted date
Args: Args:
db (pydal.DAL): db (pydal.DAL):
......
...@@ -302,6 +302,7 @@ class RecordHepPubli(dict, AuthorsMixin, PublicationInfoMixin): ...@@ -302,6 +302,7 @@ class RecordHepPubli(dict, AuthorsMixin, PublicationInfoMixin):
* standardise name of collaboration * standardise name of collaboration
* format authors according to my format * format authors according to my format
* extract authors form my institute signing the publication * extract authors form my institute signing the publication
* check and fix submitted date
Args: Args:
db (pydal.DAL): db (pydal.DAL):
......
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