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

Add the possibility to run all harvesters for a team, a project.

parent a27c0e3a
......@@ -7,6 +7,7 @@ from gluon.storage import Storage
from harvest_tools import get_harvester_tool, ToolException
from plugin_dbui import Selector
MSG_NO_HARVESTER = T("No harvesters for your selection !!!")
def free_run():
"""Run a free harvester.
......@@ -128,9 +129,21 @@ def run_all():
try:
selector = Selector(virtdb.run_all_harvesters_selector,
exclude_fields=('mode', 'year_start', 'year_end'))
query = None
for fieldname in ('id_teams', 'id_projects'):
if selector[fieldname]:
q = db.harvesters[fieldname] == selector[fieldname]
if query:
query = (query) & (q)
else:
query = q
rows = db(query).select(db.harvesters.ALL)
if not len(rows):
return MSG_NO_HARVESTER
for row in db().select(db.harvesters.ALL):
for row in rows:
selector.controller = row.controller
selector.id_projects = row.id_projects
selector.id_teams = row.id_teams
......
......@@ -213,6 +213,7 @@
'Niveau 2': 'Niveau 2',
'Niveau 3': 'Niveau 3',
'Niveau 4': 'Niveau 4',
'No harvesters for your selection !!!': 'Pas de moisonneurs pour votre sélection !!!',
'Nom': 'Nom',
'Note': 'Note',
'Notes and reports to committees': 'Notes et Rapports à des Comités',
......
......@@ -191,7 +191,15 @@ virtdb.metric_selector.format.requires = IS_IN_SET(['html', 'csv'])
virtdb.define_table('run_all_harvesters_selector',
Field('year_start', 'integer', default=year),
Field('year_end', 'integer'),
Field('id_teams', db.teams, label='Team'),
Field('id_projects', db.projects, label='Project'),
Field("mode", "string", default=MODE_LOAD_IN_DB))
virtdb.run_all_harvesters_selector.mode.requires = \
IS_IN_SET([MODE_DRY_RUN, MODE_LOAD_IN_DB])
virtdb.run_all_harvesters_selector.id_projects.requires = \
IS_IN_DB(db, 'projects.id', 'projects.project')
virtdb.run_all_harvesters_selector.id_teams.requires = \
IS_IN_DB(db, 'teams.id', 'teams.team')
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