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

"""
5 6 7 8 9 10 11 12
# 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

13 14
#-------------------------------------------------------------------------------
#
15
# CAS
16
#
17
#-------------------------------------------------------------------------------
18
casNode = None
LE GAC Renaud's avatar
LE GAC Renaud committed
19
if "auth" in globals() and session.role == ADMIN:
20 21
    
    casNode = Node(T('CAS'))
22

LE GAC Renaud's avatar
LE GAC Renaud committed
23 24 25
    casNode.add_child(T('users'), to_grid('auth_user'))
    casNode.add_child(T('groups'), to_grid('auth_group'))
    casNode.add_child(T('relation user / groups'), to_grid('auth_membership'))
26 27 28 29 30 31 32 33 34 35 36 37

#-------------------------------------------------------------------------------
#
# CONFIGURE APPLICATION
#
#-------------------------------------------------------------------------------
confAppNode = None
if session.role == ADMIN:

    confAppNode = Node(T('Configure the application'))
    confAppNode.add_child(T('properties'), to_grid('application'))

38
#-------------------------------------------------------------------------------
39
#
40
# CONFIGURE HARVESTERS
41
#
42
#-------------------------------------------------------------------------------
43 44
confHarvesterNode = None
if session.role in (ADMIN, USER):
45
    
46
    confHarvesterNode = Node(T('Configure harvesters'))
47 48 49
    
    confHarvesterNode.add_child(T('harvesters'), to_grid('harvesters'))
    confHarvesterNode.add_child(T('relation harvesters / categories'), to_grid('controllers'))
LE GAC Renaud's avatar
LE GAC Renaud committed
50
    confHarvesterNode.add_child(T("author's rescue list"), to_grid('my_authors'))
51

52
#-------------------------------------------------------------------------------
53
#
LE GAC Renaud's avatar
LE GAC Renaud committed
54
# CONFIGURE LISTS
55
#
56
#-------------------------------------------------------------------------------
LE GAC Renaud's avatar
LE GAC Renaud committed
57
confListNode = None
58
if session.role == ADMIN:
59

LE GAC Renaud's avatar
LE GAC Renaud committed
60 61 62 63
    confListNode = Node(T('Configure lists'))
    
    # NOTE: hide axes table which contains static data
    # confListNode.add_child('axes', to_grid('axes'))
LE GAC Renaud's avatar
LE GAC Renaud committed
64
    confListNode.add_child(T('renderers'), to_grid('renderers'))
LE GAC Renaud's avatar
LE GAC Renaud committed
65
    confListNode.add_child(T('sections'), to_grid('sections'))
LE GAC Renaud's avatar
LE GAC Renaud committed
66
    confListNode.add_child(T('lists'), to_grid('lists'))
LE GAC Renaud's avatar
LE GAC Renaud committed
67 68 69 70 71 72 73 74
     
#-------------------------------------------------------------------------------
#
# CONFIGURE METRICs
#
#-------------------------------------------------------------------------------
confMetricNode = None
if session.role == ADMIN:
75

76 77
    confMetricNode = Node(T('Configure graphs and metrics'))
    confMetricNode.add_child(T('graphs'), to_grid('graphs'))
LE GAC Renaud's avatar
LE GAC Renaud committed
78
    confMetricNode.add_child(T('metrics'), to_grid('metrics'))
79
     
80
#-------------------------------------------------------------------------------
81
#
82
# DATA INSTITUT
83
#
84
#-------------------------------------------------------------------------------
85 86 87
dataInstituteNode = None
if session.role == ADMIN:

LE GAC Renaud's avatar
LE GAC Renaud committed
88
    leaves = ('projects', 'teams')
89 90 91

    dataInstituteNode = Node(T('Data institute'))
    dataInstituteNode.add_children(leaves, func=to_grid)
LE GAC Renaud's avatar
LE GAC Renaud committed
92 93
    
    dataInstituteNode.add_child(T('Relation team / projects'), to_grid('organisation'))
94 95 96 97 98 99 100
     
#-------------------------------------------------------------------------------
#
# DATA PUBLICATIONS
#
#-------------------------------------------------------------------------------
dataPublicationeNode = None
101
if session.role in (ADMIN, USER):
102

103 104 105 106 107 108
    leaves = ('categories', 
              'collaborations', 
              'countries',
              'publications', 
              'publishers',
              'status')
109

110
    if session.role == USER:
111 112
        leaves = ('categories', 
                  'publications')
113 114 115 116
        
    dataPublicationeNode = Node(T('Data publications'))
    dataPublicationeNode.add_children(leaves, func=to_grid)
    
117
#-------------------------------------------------------------------------------
118
#
119
# HELP NODE
120
#
121
#-------------------------------------------------------------------------------
122
aboutLeaf = Panel(autoLoad=URL('plugin_dbui', 'about'), autoScroll=True)
123 124 125 126 127 128 129 130 131 132 133 134 135 136

loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('plugin_dbui', 'documentations'))

docLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'], autoScroll=True)

loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('plugin_dbui', 'versions'))

versionLeaf = Panel(loader=loader, plugins=['pPanelLoaderException'])
137

138
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
139 140
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
141

142
if session.role == ADMIN:
143
    helpNode.add_child(T('documentations'), docLeaf)
144 145 146
    
helpNode.sort_children()

147
#-------------------------------------------------------------------------------
148
#
149
# REPORT NODE
150
#
151
#-------------------------------------------------------------------------------
152 153 154 155 156 157 158 159 160
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('graphs', 'dashboard'))

dashBoardLeaf = Panel(loader=loader, 
                      plugins=['pPanelLoaderException'], 
                      autoScroll=True)

161 162
graphLeaf = PanelWithUrlSelector(virtdb.graph_selector, 
                                  baseUrl=URL('graphs', 'index'))
LE GAC Renaud's avatar
LE GAC Renaud committed
163

164 165 166
listLeaf = PanelWithUrlSelector(virtdb.list_selector, 
                                baseUrl=URL('lists', 'index'),
                                extField='format',
167
                                plugins=['pMathJax'])
168

169 170 171
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector, 
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
172

173
reportNode = Node(T('Reports'))
174
reportNode.add_child(T('dashboard'), dashBoardLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
175 176
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
177
reportNode.add_child(T('graphs'), graphLeaf)
178

179
#-------------------------------------------------------------------------------
180
#
181
# WIZARD NODE
182
#
183
#-------------------------------------------------------------------------------
184
wizardNode = None
185
if session.role in (ADMIN, USER):
186 187
    authorLeaf = PanelWithUrlSelector(virtdb.authors_selector, 
                                      baseUrl=URL('wizards', 'extract_authors'))
188
    
189 190 191 192
    editLeaf = PanelWithUrlSelector(virtdb.edit_insert_selector,
                                    baseUrl=URL('harvest', 'edit_insert'),
                                    selectorTitle='Fill all fields') 

193 194 195 196
    freeLeaf = PanelWithUrlSelector(virtdb.free_harvester_selector, 
                                    baseUrl=URL('harvest', 'free_run'),
                                    selectorTitle='Fill all fields',
                                    timeout=ONE_HOUR)
197
    
198 199
    checkLeaf = PanelWithUrlSelector(virtdb.check_selector, 
                                     baseUrl=URL('wizards', 'check_validate'),
200 201
                                     extField='format',
                                     timeout=ONE_HOUR)
202
    
203 204 205 206
    harvesterLeaf = PanelWithUrlSelector(virtdb.harvester_selector, 
                                         baseUrl=URL('harvest', 'run'),
                                         extField='format',
                                         timeout=ONE_HOUR)
207
    
208 209 210
    marc12Leaf = PanelWithUrlSelector(virtdb.marc12_selector, 
                                      selectorTitle='Fill all fields',
                                      baseUrl=URL('harvest', 'insert_marcxml')) 
211
    
212 213 214 215
    runAllLeaf = PanelWithUrlSelector(virtdb.run_all_harvesters_selector, 
                                      baseUrl=URL('harvest', 'run_all'),
                                      extField='format',
                                      timeout=ONE_HOUR)
216
    
217
    wizardNode = Node(T('Wizards'))
218
    wizardNode.add_child(T('edit and insert'), editLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
219 220
    wizardNode.add_child(T('insert MARCXML'), marc12Leaf)
    wizardNode.add_child(T('run a free harvester'), freeLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
221 222 223
    wizardNode.add_child(T('extract authors'), authorLeaf)
    wizardNode.add_child(T('run a harvester'), harvesterLeaf)
    wizardNode.add_child(T('run all harvesters'), runAllLeaf)
224
    
225
    if session.role == ADMIN:
LE GAC Renaud's avatar
LE GAC Renaud committed
226
        wizardNode.add_child(T('check and validate'), checkLeaf)
227 228 229
    else:
        wizardNode.add_child(T('check'), checkLeaf)
    
230
    wizardNode.sort_children()
231

232
#-------------------------------------------------------------------------------
233
#
234
# VIEWPORT
235
#
236
#-------------------------------------------------------------------------------
237 238
nodes = [helpNode, 
         casNode, 
239 240
         wizardNode,
         confAppNode,
241
         confHarvesterNode, 
LE GAC Renaud's avatar
LE GAC Renaud committed
242 243
         confListNode,
         confMetricNode,
244 245 246 247
         dataInstituteNode,
         dataPublicationeNode, 
         reportNode]

248
viewportModifier = dbui.ViewportModifier()
249
viewportModifier.add_node(*nodes)
250

LE GAC Renaud's avatar
LE GAC Renaud committed
251 252
viewportModifier.configure(tabTitleTpl="{1}")

253 254
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
LE GAC Renaud's avatar
LE GAC Renaud committed
255 256
    viewportModifier.configure(logged=False, 
                               plugins=['pViewportLogin'])
257
 
258
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
259
    viewportModifier.configure(logged=True)
260
    viewportModifier.default_node(T('Data publications'), T('publications'))
261 262 263

else:
    viewportModifier.default_node(T('Reports'), T('dashboard'))