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

Polish new modules.

parent 35799c60
""" Main Controller to run the application with some privileges. """ Main Controller to run the application with some privileges.
""" """
from gluon import current
from auth import ADMIN, USER
@auth.requires(True, requires_login=not request.is_local) @auth.requires(True, requires_login=not request.is_local)
def index(): def index():
......
...@@ -25,6 +25,7 @@ from model_app import App ...@@ -25,6 +25,7 @@ from model_app import App
from model_core import Core from model_core import Core
from model_harvester import Harvester from model_harvester import Harvester
from model_report import Report from model_report import Report
from model_selector import Selector
from plugin_dbui import (configure_forms, from plugin_dbui import (configure_forms,
configure_grids, configure_grids,
...@@ -95,6 +96,7 @@ App.define_tables(db, T) ...@@ -95,6 +96,7 @@ App.define_tables(db, T)
Core.define_tables(db, T) Core.define_tables(db, T)
Harvester.define_tables(db, T) Harvester.define_tables(db, T)
Report.define_tables(db, T) Report.define_tables(db, T)
Selector.define_tables(virtdb, db, T)
# ............................................................................ # ............................................................................
# #
......
...@@ -18,7 +18,7 @@ class AppUI(object): ...@@ -18,7 +18,7 @@ class AppUI(object):
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
""" """
AppUI.preferences(db, T) AppUI.preferences(db, T)
@staticmethod @staticmethod
def preferences(db, T): def preferences(db, T):
......
...@@ -258,6 +258,7 @@ class CoreUI(object): ...@@ -258,6 +258,7 @@ class CoreUI(object):
"pages", "pages",
fieldLabel=T("Volume / pages")) fieldLabel=T("Volume / pages"))
session = current.globalenv["session"]
if session.role == USER: if session.role == USER:
mdf.configure_field("id_status", hidden=True) mdf.configure_field("id_status", hidden=True)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
""" """
from auth import ADMIN from auth import ADMIN
from gluon import current
from harvest_tools import DRY_RUN from harvest_tools import DRY_RUN
from plugin_dbui import (FieldsModifier, from plugin_dbui import (FieldsModifier,
FormModifier) FormModifier)
...@@ -61,6 +62,7 @@ class SelectorUI(object): ...@@ -61,6 +62,7 @@ class SelectorUI(object):
emptyText=tr_select, emptyText=tr_select,
xtype="xcomboboxuserreset") xtype="xcomboboxuserreset")
session = current.globalenv["session"]
if session.role != ADMIN: if session.role != ADMIN:
virtdb.check_selector.mode.default = T(DRY_RUN) virtdb.check_selector.mode.default = T(DRY_RUN)
mdf.configure_field("mode", hidden=True) mdf.configure_field("mode", hidden=True)
......
...@@ -9,7 +9,7 @@ from gluon.html import URL ...@@ -9,7 +9,7 @@ from gluon.html import URL
from plugin_dbui import (Node, from plugin_dbui import (Node,
Panel, Panel,
to_gridPanel, to_gridPanel,
PanelWithUrlSelector, to_panelWithUrlSelector,
ViewportModifier, ViewportModifier,
Window) Window)
...@@ -43,16 +43,18 @@ class ViewportUi(object): ...@@ -43,16 +43,18 @@ class ViewportUi(object):
virtual database with the definition of selectors virtual database with the definition of selectors
""" """
session = current.globalenv["session"]
nodes = [ nodes = [
ViewportUi.help_node(db, T), ViewportUi.help_node(db, T, session),
ViewportUi.app_node(db, T), ViewportUi.app_node(db, T, session),
ViewportUi.wizard_node(db, T, virtdb), ViewportUi.wizard_node(db, T, session, virtdb),
ViewportUi.configure_harvester_node(db, T), ViewportUi.configure_harvester_node(db, T, session),
ViewportUi.configure_list_node(db, T), ViewportUi.configure_list_node(db, T, session),
ViewportUi.configure_metric_node(db, T), ViewportUi.configure_metric_node(db, T, session),
ViewportUi.data_institute_node(db, T), ViewportUi.data_institute_node(db, T, session),
ViewportUi.data_publication_node(db, T), ViewportUi.data_publication_node(db, T, session),
ViewportUi.harvester_node(db, T, virtdb), ViewportUi.harvester_node(db, T, session, virtdb),
ViewportUi.report_node(db, T, virtdb)] ViewportUi.report_node(db, T, virtdb)]
mdf = ViewportModifier() mdf = ViewportModifier()
...@@ -64,6 +66,7 @@ class ViewportUi(object): ...@@ -64,6 +66,7 @@ class ViewportUi(object):
if current.auth is not None: if current.auth is not None:
mdf.configure(logged=False, plugins=["pViewportLogin"]) mdf.configure(logged=False, plugins=["pViewportLogin"])
session = current.globalenv["session"]
if session.role in (ADMIN, USER): if session.role in (ADMIN, USER):
mdf.configure(logged=True) mdf.configure(logged=True)
mdf.default_node(T("Data publications"), T("publications")) mdf.default_node(T("Data publications"), T("publications"))
...@@ -72,12 +75,13 @@ class ViewportUi(object): ...@@ -72,12 +75,13 @@ class ViewportUi(object):
mdf.default_node(T("Reports"), T("dashboard")) mdf.default_node(T("Reports"), T("dashboard"))
@staticmethod @staticmethod
def app_node(db, T): def app_node(db, T, session):
"""To deal with preferences for the application. """To deal with preferences for the application.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -85,6 +89,7 @@ class ViewportUi(object): ...@@ -85,6 +89,7 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role == ADMIN: if session.role == ADMIN:
node = Node(T("Application")) node = Node(T("Application"))
...@@ -110,12 +115,13 @@ class ViewportUi(object): ...@@ -110,12 +115,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def configure_harvester_node(db, T): def configure_harvester_node(db, T, session):
"""To configure harvesters. """To configure harvesters.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -123,6 +129,7 @@ class ViewportUi(object): ...@@ -123,6 +129,7 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role in (ADMIN, USER): if session.role in (ADMIN, USER):
node = Node(T("Configure harvesters")) node = Node(T("Configure harvesters"))
...@@ -139,12 +146,13 @@ class ViewportUi(object): ...@@ -139,12 +146,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def configure_list_node(db, T): def configure_list_node(db, T, session):
"""To configure list. """To configure list.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -152,6 +160,7 @@ class ViewportUi(object): ...@@ -152,6 +160,7 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role == ADMIN: if session.role == ADMIN:
node = Node(T("Configure lists")) node = Node(T("Configure lists"))
...@@ -166,12 +175,13 @@ class ViewportUi(object): ...@@ -166,12 +175,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def configure_metric_node(db, T): def configure_metric_node(db, T, session):
"""To configure metrics. """To configure metrics.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -179,6 +189,7 @@ class ViewportUi(object): ...@@ -179,6 +189,7 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role == ADMIN: if session.role == ADMIN:
node = Node(T("Configure graphs and metrics")) node = Node(T("Configure graphs and metrics"))
...@@ -190,7 +201,7 @@ class ViewportUi(object): ...@@ -190,7 +201,7 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def data_institute_node(db, T): def data_institute_node(db, T, session):
"""To define data for the institute, affiliation_keys, projects """To define data for the institute, affiliation_keys, projects
and teams. and teams.
...@@ -198,6 +209,7 @@ class ViewportUi(object): ...@@ -198,6 +209,7 @@ class ViewportUi(object):
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
configuration of the selector panel. configuration of the selector panel.
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -205,6 +217,7 @@ class ViewportUi(object): ...@@ -205,6 +217,7 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role == ADMIN: if session.role == ADMIN:
node = Node(T("Data institute")) node = Node(T("Data institute"))
...@@ -219,12 +232,13 @@ class ViewportUi(object): ...@@ -219,12 +232,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def data_publication_node(db, T): def data_publication_node(db, T, session):
"""To define data for publications. """To define data for publications.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -232,6 +246,7 @@ class ViewportUi(object): ...@@ -232,6 +246,7 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role in (ADMIN, USER): if session.role in (ADMIN, USER):
node = Node(T("Data publications")) node = Node(T("Data publications"))
...@@ -254,12 +269,13 @@ class ViewportUi(object): ...@@ -254,12 +269,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def harvester_node(db, T, virtdb): def harvester_node(db, T, session, virtdb):
"""To run harvester. """To run harvester.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
virtdb (pyDAL.DAL): virtdb (pyDAL.DAL):
virtual database with the definition of selectors virtual database with the definition of selectors
...@@ -269,23 +285,24 @@ class ViewportUi(object): ...@@ -269,23 +285,24 @@ class ViewportUi(object):
""" """
node = None node = None
if session.role in (ADMIN, USER): if session.role in (ADMIN, USER):
node = Node(T("Harvest")) node = Node(T("Harvest"))
free_panel = PanelWithUrlSelector( free_panel = to_panelWithUrlSelector(
virtdb.free_harvester_selector, virtdb.free_harvester_selector,
baseUrl=URL("harvest", "free_run"), baseUrl=URL("harvest", "free_run"),
selectorTitle="Fill all fields", selectorTitle="Fill all fields",
timeout=ONE_HOUR) timeout=ONE_HOUR)
harvester_panel = PanelWithUrlSelector( harvester_panel = to_panelWithUrlSelector(
virtdb.harvester_selector, virtdb.harvester_selector,
baseUrl=URL("harvest", "run"), baseUrl=URL("harvest", "run"),
extField="format", extField="format",
timeout=ONE_HOUR) timeout=ONE_HOUR)
run_all_panel = PanelWithUrlSelector( run_all_panel = to_panelWithUrlSelector(
virtdb.run_all_harvesters_selector, virtdb.run_all_harvesters_selector,
baseUrl=URL("harvest", "run_all"), baseUrl=URL("harvest", "run_all"),
extField="format", extField="format",
...@@ -301,12 +318,13 @@ class ViewportUi(object): ...@@ -301,12 +318,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def help_node(db, T): def help_node(db, T, session):
"""To deal with documentation and version. """To deal with documentation and version.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
Returns: Returns:
dbui.Node: dbui.Node:
...@@ -394,18 +412,18 @@ class ViewportUi(object): ...@@ -394,18 +412,18 @@ class ViewportUi(object):
plugins=["pPanelLoaderException"], plugins=["pPanelLoaderException"],
autoScroll=True) autoScroll=True)
graph_panel = PanelWithUrlSelector( graph_panel = to_panelWithUrlSelector(
virtdb.graph_selector, virtdb.graph_selector,
baseUrl=URL("graphs", "index"), baseUrl=URL("graphs", "index"),
extField="format") extField="format")
list_panel = PanelWithUrlSelector( list_panel = to_panelWithUrlSelector(
virtdb.list_selector, virtdb.list_selector,
baseUrl=URL("lists", "index"), baseUrl=URL("lists", "index"),
extField="format", extField="format",
plugins=["pMathJax"]) plugins=["pMathJax"])
metric_panel = PanelWithUrlSelector( metric_panel = to_panelWithUrlSelector(
virtdb.metric_selector, virtdb.metric_selector,
baseUrl=URL("metrics", "index"), baseUrl=URL("metrics", "index"),
extField="format") extField="format")
...@@ -419,12 +437,13 @@ class ViewportUi(object): ...@@ -419,12 +437,13 @@ class ViewportUi(object):
return node return node
@staticmethod @staticmethod
def wizard_node(db, T, virtdb): def wizard_node(db, T, session, virtdb):
"""To run wizards. """To run wizards.
Args: Args:
db (pyDAL.DAL): database connection db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator T (gluon.languages.translator): language translator
session (gluon.storage.Storage):
virtdb (pyDAL.DAL): virtdb (pyDAL.DAL):
virtual database with the definition of selectors virtual database with the definition of selectors
...@@ -434,26 +453,27 @@ class ViewportUi(object): ...@@ -434,26 +453,27 @@ class ViewportUi(object):
""" """
node = None node = None
session = current.globalenv["session"]
if session.role in (ADMIN, USER): if session.role in (ADMIN, USER):
node = Node(T("Wizards")) node = Node(T("Wizards"))
author_panel = PanelWithUrlSelector( author_panel = to_panelWithUrlSelector(
virtdb.authors_selector, virtdb.authors_selector,
baseUrl=URL("wizards", "extract_authors")) baseUrl=URL("wizards", "extract_authors"))
check_panel = PanelWithUrlSelector( check_panel = to_panelWithUrlSelector(
virtdb.check_selector, virtdb.check_selector,
baseUrl=URL("wizards", "check_validate"), baseUrl=URL("wizards", "check_validate"),
extField="format", extField="format",
timeout=ONE_HOUR) timeout=ONE_HOUR)
edit_panel = PanelWithUrlSelector( edit_panel = to_panelWithUrlSelector(
virtdb.edit_insert_selector, virtdb.edit_insert_selector,
baseUrl=URL("harvest", "edit_insert"), baseUrl=URL("harvest", "edit_insert"),
selectorTitle="Fill all fields") selectorTitle="Fill all fields")
marc12_panel = PanelWithUrlSelector( marc12_panel = to_panelWithUrlSelector(
virtdb.marc12_selector, virtdb.marc12_selector,
selectorTitle="Fill all fields", selectorTitle="Fill all fields",
baseUrl=URL("harvest", "insert_marcxml")) baseUrl=URL("harvest", "insert_marcxml"))
......
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