widgets_viewport.py 5.13 KB
Newer Older
1 2 3 4 5
# -*- coding: utf-8 -*-
""" widgets viewport

"""
#
6 7 8
# list of useful tables 
# To be used to build the list of hidden tables which depend on
# the role and the node
9
#
10 11 12 13 14 15 16 17 18
auth_tables = ['auth_cas',
               'auth_event',
               'auth_group',
               'auth_membership',
               'auth_permission',
               'auth_user']

configuration_tools_tables = ['cppm_authors', 
                              'harvesters', 
19 20
                              'lists',
                              'metrics',
21 22
                              'sections',
                              'renderers']
23 24 25 26 27 28 29 30 31 32 33 34 35

main_tables = ['diplomas', 'publications']


#
# The configuration tools node
#
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) 
36 37

#
38
# Hidden tables for the remaining nodes
39
#
40 41 42 43 44 45 46

if session.role == 'admin':
    hidden_tables = list(auth_tables)
    hidden_tables.extend(configuration_tools_tables)
    
else:
    hidden_tables = set(db.tables).difference(main_tables)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

#
# The grid node of the navigation tree
#
gridNode = dbui.Node(T('Tables'))
configurator = lambda tablename: dbui.to_gridPanel(db[tablename]) 
gridNode.add_children(db.tables, func=configurator, hidden=hidden_tables) 

#
# The tool node of the navigation tree
# The tools accessible depend on the user role
#
fields = dbui.to_fields(virtdb.authors_selector)
selector = dbui.FieldSet(items=fields, plugins=['pFormToolTip'], 
                                       title=T('Fill'))
authorNode = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/helpers/extract_authors',
                                       isMathJax=False,
                                       panelCfg=dbui.Panel(),
                                       selectorCfg=selector,
                                       selectorCollapsible=False)

fields = dbui.to_fields(virtdb.harvester_selector)
selector = dbui.FieldSet(items=fields, plugins=['pFormToolTip'], 
                                       title=T('Select'))
harvesterNode = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/harvest',
                                          ctrlField='Harvester_selectorController',
                                          isMathJax=False,
                                          panelCfg=dbui.Panel(),
                                          selectorCfg=selector,
                                          selectorCollapsible=False,
                                          timeout=3600)

79
fields = dbui.to_fields(virtdb.list_selector)
80 81
selector = dbui.FieldSet(items=fields, plugins=['pFormToolTip'], 
                                       title=T('Select'))
82 83 84 85 86
listNode = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/lists',
                                     isMathJax=dbui.is_mathjax(),
                                     panelCfg=dbui.Panel(),
                                     selectorCfg=selector,
                                     selectorCollapsible=False)
87

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
fields = dbui.to_fields(virtdb.marc12_selector)
selector = dbui.FieldSet(items=fields, plugins=['pFormToolTip'], 
                                       title=T('Select'))
marc12Node = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/harvest',
                                       ctrlField='Marc12_selectorController',
                                       isMathJax=False,
                                       panelCfg=dbui.Panel(),
                                       selectorCfg=selector,
                                       selectorCollapsible=False)

fields = dbui.to_fields(virtdb.metric_selector)
selector = dbui.FieldSet(items=fields, title=T('Select'))
metricNode = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/metrics',
                                       isMathJax=False,
                                       panelCfg=dbui.Panel(),
                                       selectorCfg=selector,
                                       selectorCollapsible=False)

schemaNode = dbui.Panel(autoLoad='/'+request.application+'/default/schema')
versionNode = dbui.Panel(autoLoad='/'+request.application+'/default/versions')

toolNode = dbui.Node(T('Tools'))
110
toolNode.add_child(T('get lists'), listNode)
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
toolNode.add_child(T('get metrics'), metricNode)
toolNode.add_child(T('insert MARCXML'), marc12Node)
toolNode.add_child(T('versions'), versionNode)

if session.role == 'admin':
    toolNode.add_child(T('extract authors'), authorNode)
    toolNode.add_child(T('database schema'), schemaNode)
    toolNode.add_child(T('run harvesters'), harvesterNode)
    
toolNode.sort_children()

#
# The viewport with its navigation tree
# the list of node depends on the user role
#
viewportModifier = dbui.ViewportModifier()
viewportModifier.append_plugins('pViewportLogin')

if session.role == 'admin':
130
    viewportModifier.add_node(confNode, gridNode, toolNode)
131 132 133 134 135 136
    viewportModifier.configure(logged=True)

else:
    viewportModifier.add_node(gridNode, toolNode)
    viewportModifier.configure(logged=False)