Commit 36837e50 authored by tux091's avatar tux091
Browse files

Add the list of phds in the basic list.

Improve the list tool by adding two classes Publications and Diplomas.
parent fd4cdbf5
""" Controllers for buildind list
"""
import plugin_dbui
from list import ListTool
from harvest import get_id
from list import Diplomas, Publications
def index():
......@@ -17,7 +17,7 @@ def basic():
The parameter for the selection are setup via the list_selector interface.
"""
tool = ListTool(db)
tool = Publications(db)
tool.decode_request()
# download the list as a file with a given format
......@@ -25,7 +25,7 @@ def basic():
if iframe:
return iframe
# build the list
# query to build the list of publications
query = tool.query()
# preprint ordered by preprint number
......@@ -77,7 +77,25 @@ def basic():
db.publications.report_numbers,
orderby=(~db.publications.year, db.publications.report_numbers))
return dict(articles=articles,
# Phd thesis
diplomas = Diplomas(db)
diplomas.decode_request()
query = diplomas.query()
id_phd = get_id(db, 'degrees', degree='PhD')
if id_phd:
q_phds = (query) & (db.diplomas.id_degrees == id_phd)
phds = db(q_phds).select(db.diplomas.year,
db.diplomas.title,
db.diplomas.author,
db.diplomas.defense,
orderby=(~db.diplomas.year, db.diplomas.author))
else:
phds = []
# go to the view
return dict(articles=articles,
phds=phds,
preprints=preprints,
proceedings=proceedings,
reports=reports)
......@@ -88,6 +88,51 @@ class ListTool(object):
return None
def query(self):
"""Build the database query for a given table
resolving foreign keys and taking into account request constraints.
Return the query.
To implement for each inherited class.
"""
return None
class Diplomas(ListTool):
def query(self):
"""Build the database query for the diploma table
resolving foreign keys and taking into account request constraints.
"""
db = self.db
# publication list query resolving foreign key
query = db.diplomas.id_degrees == db.degrees.id
# add list selector constraints
if self.id_project and int(self.id_project) != 1:
query = (query) & (db.diplomas.id_projects == self.id_project)
if self.id_team and int(self.id_team) != 1:
query = (query) & (db.diplomas.id_teams == self.id_team)
if self.author:
query = (query) & (db.diplomas.authors_cppm.contains(self.author))
if self.y1 and not self.y2:
query = (query) & (db.diplomas.year == self.y1)
elif self.y1 and self.y2:
cnd = (db.diplomas.year >= self.y1) & (db.diplomas.year <= self.y2)
query = (query) & (cnd)
return query
class Publications(ListTool):
def query(self):
"""Build the database query for the publication table
resolving foreign keys and taking into account request constraints.
......@@ -118,4 +163,5 @@ class ListTool(object):
cnd = (db.publications.year >= self.y1) & (db.publications.year <= self.y2)
query = (query) & (cnd)
return query
\ No newline at end of file
return query
\ No newline at end of file
......@@ -56,5 +56,16 @@
</li>
{{pass}}
</ol>
<h2 class="my-h2">PhDs</h2>
<ol class="my-ol">
{{year = 0
for el in phds:
if year != el.year:
year = el.year}}</ol><p class="my-p">{{=el.year}}</p><ol class="my-ol">{{pass}}
<li class="my-li">
{{=el.title}}, {{=el.author}}, {{=el.defense}}
</li>
{{pass}}
</ol>
<br>
<br>
\ No newline at end of file
......@@ -51,5 +51,17 @@
\begin{enumerate}{{pass}}
\item {{=XML(el.publications.title)}}, {{=el.publications.first_author}} et al., {{=el.collaborations.collaboration}}, {{=el.publications.report_numbers}}{{pass}}
\end{enumerate}
\section*{PhDs}
\begin{enumerate}
{{year = 0
for el in phds:
if year != el.year:
year = el.year}}
\end{enumerate}
{{=el.year}}
\begin{enumerate}{{pass}}
\item {{=XML(el.title)}}, {{=el.author}}, {{=el.defense}}{{pass}}
\end{enumerate}
\end{document}
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