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

Check entries with the same origin field value.

parent 857be877
......@@ -86,6 +86,12 @@ def check_publication(row):
text = T('Report numbers contains "Note :" or ";"')
li.append(text)
# duplicate by origin
ids = duplicate_origin(row.publications)
if len(ids) > 1:
text = T("Entries with duplicate origin [%s]") % ', '.join(ids)
li.append(text)
# specific fields for article
if row.categories.usual == 'article':
......@@ -153,7 +159,7 @@ def check_publication(row):
return (li, ids)
def _extend_ids(db, query, ids):
def extend_ids(db, query, ids):
"""helper functions
@type db: gluon.dal.DAL
......@@ -210,16 +216,16 @@ def duplicate_article(publication):
query = ((qmain) & (db.publications.title == publication['title']))
query = ((query) & (db.publications.volume == publication['volume']))
query = ((query) & (db.publications.pages == publication['pages']))
_extend_ids(db, query, ids)
extend_ids(db, query, ids)
# publisher, volume and pages
query = ((qmain) & (db.publications.volume == publication['volume']))
query = ((query) & (db.publications.pages == publication['pages']))
_extend_ids(db, query, ids)
extend_ids(db, query, ids)
# publisher and title
query = ((qmain) & (db.publications.title == publication['title']))
_extend_ids(db, query, ids)
extend_ids(db, query, ids)
return ids
......@@ -259,17 +265,44 @@ def duplicate_conference(publication):
query = ((qmain) & (db.publications.conference_title == publication['conference_title']))
query = ((query) & (db.publications.conference_dates == publication['conference_dates']))
query = ((query) & (db.publications.conference_town == publication['conference_town']))
_extend_ids(db, query, ids)
extend_ids(db, query, ids)
# title, conference date and conference town
query = ((query) & (db.publications.conference_dates == publication['conference_dates']))
query = ((query) & (db.publications.conference_town == publication['conference_town']))
_extend_ids(db, query, ids)
extend_ids(db, query, ids)
# title, conference title and conference town
query = ((qmain) & (db.publications.conference_title == publication['conference_title']))
query = ((query) & (db.publications.conference_town == publication['conference_town']))
_extend_ids(db, query, ids)
extend_ids(db, query, ids)
return ids
def duplicate_origin(publication):
"""Look for publications with the same value in the origin field.
@type publication: dict or gluon.storage.Storage
@param publication: contains the publication fields and theirs values
@rtype: list
@return: list of ids corresponding to duplicate entries
"""
ids = []
db = current.globalenv['db']
# protection against empty origin field
if not publication['origin']:
return ids
# look for publication with the same origin field
query = db.publications.origin == publication['origin']
set = db(query)
if set.count():
for row in set.select():
ids.append(str(row.id))
return ids
......@@ -301,7 +334,7 @@ def duplicate_report(publication):
if 'id' in publication:
qmain = ((qmain) & (db.publications.id != publication['id']))
_extend_ids(db, qmain, ids)
extend_ids(db, qmain, ids)
return ids
\ No newline at end of file
......@@ -4,6 +4,7 @@ HEAD
- Bugs fixed.
- Add and deploy the methods Record.host, oai and oai_url.
- Add the application property reg_institute.
- Check entries with the same value in the origin field.
0.8.5 (May 2014)
- Migrate to plugin_dbui 0.6.1.1 and web2py 2.9.5
......
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