Commit 3254fa10 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Modify the method Msg.reject.

Add the record argument.
Add the synonym attribute and fill it when a record is rejected.
parent 2902fd6e
......@@ -4,9 +4,13 @@
"""
import json
from gluon import current
from gluon.storage import Storage
from invenio_tools import OAI_URL
from invenio_tools import (MSG_NO_COUNTRY,
MSG_NO_PUBLISHER,
MSG_WELL_FORMED_COLLABORATION,
OAI_URL)
class Msg(Storage):
......@@ -44,6 +48,7 @@ class Msg(Storage):
self.harvester = json.dumps(harvester.as_dict())
self.record_id = record_id
self.synonym = None
self.title = title
self.txt = None
self.url = OAI_URL % (harvester.host, record_id)
......@@ -88,17 +93,42 @@ class Msg(Storage):
self.action = 'modify'
self._set(txt, year, translate)
def reject(self, txt, year=None, translate=True):
"""Set the action as *reject* set the explanation as ``txt``.
def reject(self, txt, year=None, record=None, translate=True):
"""Set the action as *reject* and the explanation as ``txt``.
Args:
txt (unicode): message associated to the action.
year (unicode): year of the publication
record (RecordPubli): the record on which the action is applied.
It is used to determine the synonym value when the
*collaboration*, *country* or *publisher* data is not
understood.
Note:
The *year* argument is not needed when
the *record* is specified.
translate (bool): translate the message according to the
current language.
"""
self.action = 'reject'
if record is not None:
if txt == MSG_NO_COUNTRY:
self.synonym = record.country()
elif txt == MSG_WELL_FORMED_COLLABORATION:
self.synonym = record.collaboration()
elif txt == MSG_NO_PUBLISHER:
self.synonym = record.publisher()
if year is None and record is not None:
year = record.year()
self._set(txt, year, translate)
def _set(self, txt, year, translate):
......
......@@ -8,6 +8,9 @@ from base import (ARXIV,
is_conference,
is_institute,
is_thesis,
MSG_NO_COUNTRY,
MSG_NO_PUBLISHER,
MSG_WELL_FORMED_COLLABORATION,
OAI_URL,
REG_ARXIV_NUMBER,
REG_AUTHOR,
......
......@@ -8,7 +8,10 @@ ARXIV = "arXiv"
ARXIV_PDF = "http://arxiv.org/pdf/"
MSG_NO_CONF = "Reject no conference information"
MSG_NO_COUNTRY = "Reject invalid country"
MSG_NO_PUBLISHER = "Reject invalid publisher"
MSG_NO_THESIS = "Reject no thesis information"
MSG_WELL_FORMED_COLLABORATION = "Reject collaboration is not well formed"
OAI_URL = "http://%s/record/%s"
......
......@@ -6,6 +6,9 @@ import re
import regex
from base import (MSG_NO_CONF,
MSG_NO_COUNTRY,
MSG_NO_PUBLISHER,
MSG_WELL_FORMED_COLLABORATION,
MSG_NO_THESIS,
OAI_URL,
REG_AUTHOR,
......@@ -54,11 +57,9 @@ MONTHS = {u'Jan': '01',
MSG_INVALID_HOST = "Invalid host"
MSG_NO_AUTHOR = "Reject no author(s)"
MSG_NO_COUNTRY = "Reject invalid country"
MSG_NO_CONF_DATE = "Reject no conference date"
MSG_NO_DATE = "Reject no submission date"
MSG_NO_MY_AUTHOR = "Reject no authors of my institute"
MSG_NO_PUBLISHER = "Reject invalid publisher"
MSG_NO_REF = "Reject incomplete paper reference"
MSG_NO_YEAR = "Reject no publication year"
......@@ -68,7 +69,6 @@ MSG_TO_MANY_DATE = "Reject to many submit date"
MSG_TO_MANY_FAUTHOR = "Reject to many first author"
MSG_TO_MANY_YEAR = "Reject to many year"
MSG_WELL_FORMED_COLLABORATION = "Reject collaboration is not well formed"
MSG_WELL_FORMED_CONF_DATES = "Reject conference dates is not well formed"
MSG_WELL_FORMED_DATE = "Reject submission date is not well formed"
......
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