Commit 2cdf3e75 authored by legac's avatar legac
Browse files

Introduce 4 helper function category_article, category_preprint,

category_proceeding, category_report and category_talk and used them in
controllers building list and metric.
parent 6305b770
......@@ -2,7 +2,13 @@
"""
from harvest import get_id
from list import Diplomas, Publications
from list import (category_article,
category_preprint,
category_proceeding,
category_report,
category_talk,
Diplomas,
Publications)
def index():
......@@ -30,7 +36,7 @@ def basic():
# preprint ordered by preprint number
# preprint number is a nice time marker following chronological order
q_preprints = (query) & (db.categories.code == 'PRE')
q_preprints = (query) & (category_preprint(db))
preprints = db(q_preprints).select(db.publications.year,
db.publications.title,
db.publications.first_author,
......@@ -41,8 +47,7 @@ def basic():
# articles ordered by preprint number
# preprint number is a nice time marker following chronological order
cnd = (db.categories.code == 'ACL') | (db.categories.code == 'ACLN')
q_articles = (query) & (cnd)
q_articles = (query) & (category_article(db))
articles = db(q_articles).select(db.publications.year,
db.publications.title,
db.publications.first_author,
......@@ -56,8 +61,7 @@ def basic():
# proceeding ordered by report number
# report number is a nice time marker following chronological order
cnd = (db.categories.code == 'ACTI') | (db.categories.code == 'ACTN')
q_proceedings = (query) & (cnd)
q_proceedings = (query) & (category_proceeding(db))
proceedings = db(q_proceedings).select(db.publications.year,
db.publications.title,
db.publications.authors,
......@@ -68,8 +72,7 @@ def basic():
orderby=(~db.publications.year, db.publications.report_numbers))
# talks
cnd = (db.categories.code == 'COM')
q_talks = (query) & (cnd)
q_talks = (query) & (category_talk(db))
talks = db(q_talks).select(db.publications.year,
db.publications.title,
db.publications.authors,
......@@ -80,7 +83,7 @@ def basic():
orderby=~db.publications.year)
# reports
q_reports = (query) & (db.categories.code == 'AP')
q_reports = (query) & (category_report(db))
reports = db(q_reports).select(db.publications.year,
db.publications.title,
db.publications.first_author,
......
""" Controllers for building metrics
"""
from list import Diplomas, Publications
from list import (category_article,
category_preprint,
category_proceeding,
category_report,
category_talk,
Diplomas,
Publications)
def index():
"""Main Controller handling metrics.
......@@ -49,21 +56,19 @@ def basic():
# list of queries
di = {}
q_preprints = (query) & (db.categories.code == 'PRE')
q_preprints = (query) & (category_preprint(db))
di[q_preprints] = 'preprints'
cnd = (db.categories.code == 'ACL') | (db.categories.code == 'ACLN')
q_articles = (query) & (cnd)
q_articles = (query) & (category_article(db))
di[q_articles] = 'articles'
cnd = (db.categories.code == 'ACTI') | (db.categories.code == 'ACTN')
q_proceedings = (query) & (cnd)
q_proceedings = (query) & (category_proceeding(db))
di[q_proceedings] = 'proceedings'
q_talks = (query) & (db.categories.code == 'COM')
q_talks = (query) & (category_talk(db))
di[q_talks] = 'talks'
q_reports = (query) & (db.categories.code == 'AP')
q_reports = (query) & (category_report(db))
di[q_reports] = 'reports'
# fill the table
......
......@@ -8,6 +8,48 @@ from gluon import current
from gluon.html import IFRAME, URL
from plugin_dbui import decode_field
def category_article(db):
"""Helper function defining publication categories
associated to article. The return value can be used as is in a query.
"""
return (db.categories.code == 'ACL') | (db.categories.code == 'ACLN')
def category_preprint(db):
"""Helper function defining publication categories
associated to preprint. The return value can be used as is in a query.
"""
return db.categories.code == 'PRE'
def category_proceeding(db):
"""Helper function defining publication categories
associated to proceeding. The return value can be used as is in a query.
"""
return (db.categories.code == 'ACTI') | (db.categories.code == 'ACTN')
def category_report(db):
"""Helper function defining publication categories
associated to report. The return value can be used as is in a query.
"""
return db.categories.code == 'AP'
def category_talk(db):
"""Helper function defining publication categories
associated to conference talk. The return value can be used as is
in a query.
"""
return db.categories.code == 'COM'
class ListTool(object):
"""Basic tool to build a publication list.
......
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