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