Commit 176b4d53 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Improve design of the Nodes embedded in the ViewPort.

parent 8dcdef32
......@@ -102,6 +102,8 @@
'Conference town is not defined': "La ville de la conférence n'est pas défine",
'Conference_Url': 'URL de la Conférence',
'Configuration': 'Configuration',
'Configure harvesters': 'Configurer les moissonneurs',
'Configure rapports': 'Configurer les rapports',
'contains': 'contiens',
'Controller': 'Controller',
'controllers': 'controllers',
......@@ -115,7 +117,8 @@
'cppm_authors': 'autheurs du cppm',
'Created By': 'Created By',
'Created On': 'Created On',
'Data organisation': 'Data organisation',
'Data institute': 'Les données du laboratoire',
'Data publications': 'Les données des publications',
'database': 'database',
'database %s select': 'database %s select',
'database schema': 'schéma de la base de donnée',
......@@ -265,6 +268,8 @@
'or import from csv file': 'or import from csv file',
'organisation': 'organisation',
'Organisation': 'Organisation',
'organisations': 'organisations',
'organizations': 'organizations',
'Origin': 'Origin',
'Pages': 'Pages',
'Pages range is not defined': 'Les Pages ne sont pas définies',
......
......@@ -16,17 +16,17 @@ ID_USER, USER, DEF_USER = 2, 'user', 'liaisons, team leaders,...'
# MYSQL database
#
#-------------------------------------------------------------------------------
try:
db = DAL(DB_MYSQL, migrate_enabled=MIGRATE, pool_size=10)
except:
raise HTTP(500, T("Can't access the MySQL database !!!"))
# try:
# db = DAL(DB_MYSQL, migrate_enabled=MIGRATE, pool_size=10)
# except:
# raise HTTP(500, T("Can't access the MySQL database !!!"))
#-------------------------------------------------------------------------------
#
# SQLITE database (test)
#
#-------------------------------------------------------------------------------
# db = DAL('sqlite://storage.sqlite', migrate_enabled=MIGRATE)
db = DAL('sqlite://storage.sqlite', migrate_enabled=MIGRATE)
#-------------------------------------------------------------------------------
#
......
......@@ -2,90 +2,101 @@
""" widgets viewport
"""
# helper function translating a tablename into the grid configuration
to_grid = lambda tablename: dbui.to_gridPanel(db[tablename])
# short cuts
Node = dbui.Node
Panel = dbui.Panel
PanelWithUrlSelector = dbui.to_panelWithUrlSelector
#-------------------------------------------------------------------------------
#
# LISTS OF TABLES
# CAS
#
#-------------------------------------------------------------------------------
# use to build the list of hidden tables which depend on the role and the node
#
auth_tables = ['auth_cas',
'auth_event',
'auth_group',
'auth_membership',
'auth_permission',
'auth_user']
configuration_tools_tables = ['axes',
'controllers',
'harvesters',
'lists',
'organisation',
'metrics',
'renderers',
'sections']
casNode = None
if session.auth and session.role == ADMIN:
leaves = ('auth_user', 'auth_group', 'auth_membership')
main_tables = ['publications']
casNode = Node(T('CAS'))
casNode.add_children(leaves, func=to_grid)
#-------------------------------------------------------------------------------
#
# CAS NODE
# CONFIGURE HARVESTERS
#
#-------------------------------------------------------------------------------
casNode = None
if session.auth and session.role == ADMIN:
confHarvesterNode = None
if session.role in (ADMIN, USER):
hidden_tables = list(db.tables)
for el in ('auth_user', 'auth_group', 'auth_membership'):
hidden_tables.remove(el)
leaves = ('controllers', 'cppm_authors', 'harvesters')
casNode = dbui.Node(T('CAS'))
configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
casNode.add_children(db.tables, func=configurator, hidden=hidden_tables)
if session.role == USER:
leaves = ('cppm_authors', 'harvesters')
confHarvesterNode = Node(T('Configure harvesters'))
confHarvesterNode.add_children(leaves, func=to_grid)
#-------------------------------------------------------------------------------
#
# CONFIGURATION NODE
# CONFIGURE RAPPORTS
#
#-------------------------------------------------------------------------------
confNode = None
confRapportNode = None
if session.role == ADMIN:
hidden_tables = set(db.tables).difference(configuration_tools_tables)
confNode = dbui.Node(T('Configuration'))
configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
confNode.add_children(db.tables, func=configurator, hidden=hidden_tables)
leaves = ('axes', 'lists', 'metrics', 'renderers', 'sections')
confRapportNode = Node(T('Configure rapports'))
confRapportNode.add_children(leaves, func=to_grid)
#-------------------------------------------------------------------------------
#
# TABLE NODE
# DATA INSTITUT
#
#-------------------------------------------------------------------------------
gridNode = None
dataInstituteNode = None
if session.role == ADMIN:
leaves = ('authors_roles', 'organisation', 'projects', 'teams')
dataInstituteNode = Node(T('Data institute'))
dataInstituteNode.add_children(leaves, func=to_grid)
#-------------------------------------------------------------------------------
#
# DATA PUBLICATIONS
#
#-------------------------------------------------------------------------------
dataPublicationeNode = None
if session.role in (ADMIN, USER):
if session.role == ADMIN:
hidden_tables = list(auth_tables)
hidden_tables.extend(configuration_tools_tables)
elif session.role == USER:
hidden_tables = set(db.tables).difference(main_tables)
gridNode = dbui.Node(T('Tables'))
configurator = lambda tablename: dbui.to_gridPanel(db[tablename])
gridNode.add_children(db.tables, func=configurator, hidden=hidden_tables)
leaves = ('categories',
'collaborations',
'countries',
'publications',
'publishers',
'status')
if session.role == USER:
leaves = ('publications')
dataPublicationeNode = Node(T('Data publications'))
dataPublicationeNode.add_children(leaves, func=to_grid)
#-------------------------------------------------------------------------------
#
# HELP NODE
#
#-------------------------------------------------------------------------------
aboutLeaf = dbui.Panel(autoLoad=URL('default', 'about'), autoScroll=True)
documentationsLeaf = dbui.Panel(autoLoad=URL('default', 'documentations'), autoScroll=True)
schemaLeaf = dbui.Panel(autoLoad=URL('default', 'schema'), autoScroll=True)
versionLeaf = dbui.Panel(autoLoad=URL('default', 'versions'))
aboutLeaf = Panel(autoLoad=URL('default', 'about'), autoScroll=True)
documentationsLeaf = Panel(autoLoad=URL('default', 'documentations'), autoScroll=True)
schemaLeaf = Panel(autoLoad=URL('default', 'schema'), autoScroll=True)
versionLeaf = Panel(autoLoad=URL('default', 'versions'))
helpNode = dbui.Node(T('Help'))
helpNode = Node(T('Help'))
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
......@@ -99,16 +110,16 @@ helpNode.sort_children()
# REPORT NODE
#
#-------------------------------------------------------------------------------
listLeaf = dbui.to_panelWithUrlSelector(virtdb.list_selector,
baseUrl=URL('lists', 'index'),
extField='format',
isMathJax=dbui.is_mathjax())
listLeaf = PanelWithUrlSelector(virtdb.list_selector,
baseUrl=URL('lists', 'index'),
extField='format',
isMathJax=dbui.is_mathjax())
metricLeaf = dbui.to_panelWithUrlSelector(virtdb.metric_selector,
baseUrl=URL('metrics', 'index'),
extField='format')
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector,
baseUrl=URL('metrics', 'index'),
extField='format')
reportNode = dbui.Node(T('Reports'))
reportNode = Node(T('Reports'))
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
......@@ -121,34 +132,33 @@ reportNode.sort_children()
#-------------------------------------------------------------------------------
wizardNode = None
if session.role in (ADMIN, USER):
authorLeaf = dbui.to_panelWithUrlSelector(virtdb.authors_selector,
baseUrl=URL('wizards', 'extract_authors'))
freeLeaf = dbui.to_panelWithUrlSelector(virtdb.free_harvester_selector,
baseUrl=URL('harvest', 'free_run'),
selectorTitle='Fill all fields',
timeout=ONE_HOUR)
authorLeaf = PanelWithUrlSelector(virtdb.authors_selector,
baseUrl=URL('wizards', 'extract_authors'))
checkLeaf = dbui.to_panelWithUrlSelector(virtdb.check_selector,
baseUrl=URL('wizards', 'check_validate'),
extField='format')
freeLeaf = PanelWithUrlSelector(virtdb.free_harvester_selector,
baseUrl=URL('harvest', 'free_run'),
selectorTitle='Fill all fields',
timeout=ONE_HOUR)
harvesterLeaf = dbui.to_panelWithUrlSelector(virtdb.harvester_selector,
baseUrl=URL('harvest', 'run'),
extField='format',
timeout=ONE_HOUR)
checkLeaf = PanelWithUrlSelector(virtdb.check_selector,
baseUrl=URL('wizards', 'check_validate'),
extField='format')
marc12Leaf = dbui.to_panelWithUrlSelector(virtdb.marc12_selector,
selectorTitle='Fill all fields',
baseUrl=URL('harvest', 'insert_marcxml'))
harvesterLeaf = PanelWithUrlSelector(virtdb.harvester_selector,
baseUrl=URL('harvest', 'run'),
extField='format',
timeout=ONE_HOUR)
runAllLeaf = dbui.to_panelWithUrlSelector(virtdb.run_all_harvesters_selector,
baseUrl=URL('harvest', 'run_all'),
extField='format',
timeout=ONE_HOUR)
marc12Leaf = PanelWithUrlSelector(virtdb.marc12_selector,
selectorTitle='Fill all fields',
baseUrl=URL('harvest', 'insert_marcxml'))
wizardNode = dbui.Node(T('Wizards'))
runAllLeaf = PanelWithUrlSelector(virtdb.run_all_harvesters_selector,
baseUrl=URL('harvest', 'run_all'),
extField='format',
timeout=ONE_HOUR)
wizardNode = Node(T('Wizards'))
wizardNode.add_child(T('insert MARCXML'), marc12Leaf)
wizardNode.add_child(T('run a free harvester'), freeLeaf)
wizardNode.add_child(T('extract authors'), authorLeaf)
......@@ -167,8 +177,17 @@ if session.role in (ADMIN, USER):
# VIEWPORT
#
#-------------------------------------------------------------------------------
nodes = [helpNode,
casNode,
wizardNode,
confHarvesterNode,
confRapportNode,
dataInstituteNode,
dataPublicationeNode,
reportNode]
viewportModifier = dbui.ViewportModifier()
viewportModifier.add_node(helpNode, casNode, wizardNode, confNode, gridNode, reportNode)
viewportModifier.add_node(*nodes)
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
......@@ -177,4 +196,4 @@ if "auth" in globals():
if session.role in (ADMIN, USER):
viewportModifier.configure(logged=True)
viewportModifier.default_node(T('Tables'), T('publications'))
viewportModifier.default_node(T('Data publications'), T('publications'))
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