Commit 4feed9dc authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Merge branch '59-bug-duplicate-conference' into 'master'

59 bug duplicate conference

* Fix a bug in the function `duplicate_conference`
* `COM` and `ACTI` are processed separately
* Close #59

See merge request !56
parents 581a965b 2e2cc99d
......@@ -131,11 +131,11 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
"""
db, T = current.globalenv['db'], current.T
categories = db.categories
id_category = publication['id_categories']
# articles
id_cats = (get_id(db.categories, code='ACL'),
get_id(db.categories, code='ACLN'))
id_cats = (get_id(categories, code='ACL'), get_id(categories, code='ACLN'))
if id_category in id_cats:
ids = duplicate_article(publication)
......@@ -152,12 +152,12 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
return True
# talks and proceedings
id_cats = (get_id(db.categories, code='ACTI'),
get_id(db.categories, code='ACTN'),
get_id(db.categories, code='COM'))
id_cats = (get_id(categories, code='ACTI'),
get_id(categories, code='ACTN'),
get_id(categories, code='COM'))
if id_category in id_cats:
ids = duplicate_conference(publication)
ids = duplicate_conference(publication, id_category != id_cats[2])
if ids:
db.publications[CALLBACK_ERRORS] = [
......@@ -171,7 +171,7 @@ def INHIBIT_DUPLICATE_PUBLICATION(publication):
return True
# reports
id_cats = (get_id(db.categories, code='AP'),)
id_cats = (get_id(categories, code='AP'),)
if id_category in id_cats:
ids = duplicate_report(publication)
......
......@@ -23,7 +23,7 @@ def check_publication(row):
Args:
row (gluon.dal.Row): record defining a publication.
Its contains the publications table as well as its foreign tables.
Its contains the publication table as well as its foreign tables.
Returns:
tuple:
......@@ -33,55 +33,62 @@ def check_publication(row):
"""
T, li, idset = current.T, [], set()
categories = row.categories
category_code = categories.code
category_usual = categories.usual
publication = row.publications
# status code
if row.status.code == '???':
text = T("The status is ???")
li.append(text)
# category
if row.categories.code == UNDEF:
if category_code == UNDEF:
text = T("The category is undefined")
li.append(text)
# team
if row.publications.id_teams == UNDEF_ID:
if publication.id_teams == UNDEF_ID:
text = T("The team is undefined")
li.append(text)
# project
if row.publications.id_projects == UNDEF_ID:
if publication.id_projects == UNDEF_ID:
text = T("The project is undefined")
li.append(text)
# authors list
if 'et al' in row.publications.authors:
if 'et al' in publication.authors:
text = T("'et al.' in authors")
li.append(text)
# CPPM authors (team name, ...)
if row.teams.team in row.publications.authors_institute:
if row.teams.team in publication.authors_institute:
text = T("The institute authors contains the team name?")
li.append(text)
# submitted date
if not row.publications.submitted:
submitted = publication.submitted
if not submitted:
text = T("Submitted date is not defined")
li.append(text)
if row.publications.submitted:
if not REG_SUBMITTED.match(row.publications.submitted):
if submitted:
if not REG_SUBMITTED.match(submitted):
text = T("Submitted date is not valid")
li.append(text)
# publication URL
if row.publications.publication_url:
if 'pdf' not in row.publications.publication_url:
publication_url = publication.publication_url
if publication_url:
if 'pdf' not in publication_url:
text = \
T("Check that the publication URL corresponds to a pdf file.")
li.append(text)
# latex syntax
title = row.publications.title
title = publication.title
rules = "√" in title or \
("^" in title and "$" not in title) or \
("→" in title and "$" not in title) or \
......@@ -94,7 +101,7 @@ def check_publication(row):
li.append(text)
# "Note :" in report number
value = row.publications.report_numbers
value = publication.report_numbers
rules = "Note :" in value or \
"Note:" in value or \
";" in value
......@@ -104,81 +111,82 @@ def check_publication(row):
li.append(text)
# duplicate by origin
ids = duplicate_origin(row.publications)
ids = duplicate_origin(publication)
if len(ids):
idset = idset.union(ids)
text = T("Entries with duplicate origin")
li.append(text)
# specific fields for article
if row.categories.code in ('ACL', 'ACLN'):
if category_code in ('ACL', 'ACLN'):
if row.publications.id_publishers == UNDEF_ID:
if publication.id_publishers == UNDEF_ID:
text = T("Publishers is not defined")
li.append(text)
if not row.publications.volume:
if not publication.volume:
text = T("Volume number is not defined")
li.append(text)
if not row.publications.pages:
if not publication.pages:
text = T("Pages range is not defined")
li.append(text)
if not row.publications.preprint:
if not publication.preprint:
text = T("Preprint number is not defined")
li.append(text)
ids = duplicate_article(row.publications)
ids = duplicate_article(publication)
if ids:
idset = idset.union(ids)
text = T("Possible duplicate entries")
li.append(text)
# specific fields for preprint
if row.categories.code == 'PRE':
if category_code == 'PRE':
if not row.publications.preprint:
if not publication.preprint:
text = T("Preprint number is not defined")
li.append(text)
# specific fields for proceeding and talk
if row.categories.usual in ('proceeding', 'talk'):
if category_usual in ('proceeding', 'talk'):
if not row.publications.conference_title:
if not publication.conference_title:
text = T("Conference title is not defined")
li.append(text)
if not row.publications.conference_dates:
if not publication.conference_dates:
text = T("Conference dates is not defined")
li.append(text)
if not row.publications.conference_town:
if not publication.conference_town:
text = T("Conference town is not defined")
li.append(text)
if not row.publications.id_countries:
if not publication.id_countries:
text = T("Conference country is not defined")
li.append(text)
if not row.publications.conference_speaker:
if not publication.conference_speaker:
text = T("Conference speaker is missing")
li.append(text)
ids = duplicate_conference(row.publications)
ids = duplicate_conference(publication,
category_usual == 'proceeding')
if ids:
idset = idset.union(ids)
text = T("Possible duplicate entries")
li.append(text)
# specific fields for report
if row.categories.usual == 'report':
if category_usual == 'report':
if not row.publications.report_numbers:
if not publication.report_numbers:
text = T("Report number is missing")
li.append(text)
ids = duplicate_report(row.publications)
ids = duplicate_report(publication)
if ids:
idset = idset.union(ids)
text = T("Possible duplicate entries")
......@@ -261,7 +269,7 @@ def duplicate_article(publication):
return ids
def duplicate_conference(publication):
def duplicate_conference(publication, proceeding=False):
"""Look for duplicate talk / proceeding.
The comparison is performed on conference talk/proceeding published
......@@ -274,6 +282,7 @@ def duplicate_conference(publication):
Args:
publication (dict or gluon.storage.Storage): contains the publication
fields and theirs values.
proceeding (bool): tag the publication either as talk or a proceeding.
Returns:
list: list of *ids* corresponding to duplicate entries.
......@@ -285,36 +294,34 @@ def duplicate_conference(publication):
categories = db.categories
publications = db.publications
qcat = (categories.code == 'ACTI') | \
(categories.code == 'ACTN') | \
(categories.code == 'COM')
if proceeding:
qcat = (categories.code == 'ACTI') | (categories.code == 'ACTN')
else:
qcat = categories.code == 'COM'
qmain = get_where_query(publications)
qmain = ((qmain) & (qcat))
qmain = ((qmain) & (publications.id_teams == publication['id_teams']))
qmain = ((qmain) & (publications.title == publication['title']))
qmain &= qcat
qmain &= publications.id_teams == publication['id_teams']
qmain &= publications.title == publication['title']
if 'id' in publication and publication['id']:
qmain = ((qmain) & (publications.id != publication['id']))
qmain &= publications.id != publication['id']
# title, conference title, conference date and conference town
qtitle = publications.conference_title == publication['conference_title']
qdates = publications.conference_dates == publication['conference_dates']
qtown = publications.conference_town == publication['conference_town']
query = ((qmain) & (qtitle))
query = ((query) & (qdates))
query = ((query) & (qtown))
query = ((qmain) & (qtitle) & (qdates) & (qtown))
extend_ids(db, query, ids)
# title, conference date and conference town
query = ((query) & (qdates))
query = ((query) & (qtown))
query = ((qmain) & (qdates) & (qtown))
extend_ids(db, query, ids)
# title, conference title and conference town
query = ((qmain) & (qtitle))
query = ((query) & (qtown))
query = ((qmain) & (qtitle) & (qtown))
extend_ids(db, query, ids)
return ids
......
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