widgets_viewport.py 5.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# -*- coding: utf-8 -*-
""" widgets viewport

"""
#
# Hide authentication tables
# Hide other tables depending on the user role
#
hidden_tables = ['auth_cas',
                 'auth_event',
                 'auth_group',
                 'auth_membership',
                 'auth_permission',
                 'auth_user']

if session.role != 'admin':
    hidden_tables.extend(['authors_roles',
                          'categories',
                          'collaborations',
                          'countries',
                          'cppm_authors',
                          'harvesters',
                          'levels',
24 25
                          'lists',
                          'lists_have_sections',
26 27 28
                          'projects',
                          'publishers',
                          'reports',
29
                          'sections',
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 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 79 80
                          'status',
                          'teams'])

#
# The form node of the navigation tree
#
formNode = dbui.Node(T('Forms'))
configurator = lambda tablename: dbui.to_formPanel(db[tablename])
formNode.add_children(db.tables, func=configurator, hidden=hidden_tables)

#
# 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)

fields = dbui.to_fields(virtdb.list_selector)
selector = dbui.FieldSet(items=fields, plugins=['pFormToolTip'], 
                                       title=T('Select'))
listNode = dbui.PanelWithUrlSelector(baseUrl='/'+request.application+'/lists',
                                     ctrlField='List_selectorList',
                                     isMathJax=dbui.is_mathjax(),
                                     panelCfg=dbui.Panel(),
                                     selectorCfg=selector,
                                     selectorCollapsible=False)

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

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
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',
                                       ctrlField='Metric_selectorMetric',
                                       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'))
toolNode.add_child(T('get lists'), listNode)
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)
122
    toolNode.add_child(T('zzz'), listNode2)
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    
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':
    viewportModifier.add_node(formNode, gridNode, toolNode)
    viewportModifier.configure(logged=True)

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