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

"""
5
# helper function translating a tablename into the grid configuration
6
to_grid = lambda tablename: dbui.to_gridPanel(db[tablename])
7 8 9 10 11

# short cuts
Node = dbui.Node
Panel = dbui.Panel
PanelWithUrlSelector = dbui.to_panelWithUrlSelector
12
Window = dbui.Window
13

14 15
#-------------------------------------------------------------------------------
#
16
# APPLICATION
17
#
18
#-------------------------------------------------------------------------------
19
appNode = Node
20 21
if session.role == ADMIN:

22
    appNode = Node(T('Application'))
23 24 25 26 27 28 29

    prefLeaf = Window(closable=True,
                      items=[cfgPreferences],
                      layout='fit',
                      modal=True,
                      title=T('Preferences'))

30 31 32 33 34 35
    appNode.add_child(T('preferences'), prefLeaf)

    if "auth" in globals():
        appNode.add_child(T('users'), to_grid('auth_user'))
        appNode.add_child(T('groups'), to_grid('auth_group'))
        appNode.add_child(T('relation user / groups'), to_grid('auth_membership'))
36

37
#-------------------------------------------------------------------------------
38
#
39
# CONFIGURE HARVESTERS
40
#
41
#-------------------------------------------------------------------------------
42 43
confHarvesterNode = None
if session.role in (ADMIN, USER):
44

45
    confHarvesterNode = Node(T('Configure harvesters'))
46

47 48
    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
49
    confHarvesterNode.add_child(T("author's rescue list"), to_grid('my_authors'))
50

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

LE GAC Renaud's avatar
LE GAC Renaud committed
59
    confListNode = Node(T('Configure lists'))
60

LE GAC Renaud's avatar
LE GAC Renaud committed
61 62
    # NOTE: hide axes table which contains static data
    # confListNode.add_child('axes', to_grid('axes'))
LE GAC Renaud's avatar
LE GAC Renaud committed
63
    confListNode.add_child(T('renderers'), to_grid('renderers'))
LE GAC Renaud's avatar
LE GAC Renaud committed
64
    confListNode.add_child(T('sections'), to_grid('sections'))
LE GAC Renaud's avatar
LE GAC Renaud committed
65
    confListNode.add_child(T('lists'), to_grid('lists'))
66

LE GAC Renaud's avatar
LE GAC Renaud committed
67 68 69 70 71 72 73
#-------------------------------------------------------------------------------
#
# CONFIGURE METRICs
#
#-------------------------------------------------------------------------------
confMetricNode = None
if session.role == ADMIN:
74

75 76
    confMetricNode = Node(T('Configure graphs and metrics'))
    confMetricNode.add_child(T('graphs'), to_grid('graphs'))
LE GAC Renaud's avatar
LE GAC Renaud committed
77
    confMetricNode.add_child(T('metrics'), to_grid('metrics'))
78

79
#-------------------------------------------------------------------------------
80
#
81
# DATA INSTITUT
82
#
83
#-------------------------------------------------------------------------------
84 85 86
dataInstituteNode = None
if session.role == ADMIN:

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

    dataInstituteNode = Node(T('Data institute'))
    dataInstituteNode.add_children(leaves, func=to_grid)
91

LE GAC Renaud's avatar
LE GAC Renaud committed
92
    dataInstituteNode.add_child(T('Relation team / projects'), to_grid('organisation'))
93

94 95 96 97 98 99
#-------------------------------------------------------------------------------
#
# DATA PUBLICATIONS
#
#-------------------------------------------------------------------------------
dataPublicationeNode = None
100
if session.role in (ADMIN, USER):
101

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

109
    if session.role == USER:
110
        leaves = ('categories',
111
                  'publications')
112

113 114
    dataPublicationeNode = Node(T('Data publications'))
    dataPublicationeNode.add_children(leaves, func=to_grid)
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154

#-------------------------------------------------------------------------------
#
# HARVESTER NODE
#
#-------------------------------------------------------------------------------
harvestNode = None
if session.role in (ADMIN, USER):
    editLeaf = PanelWithUrlSelector(virtdb.edit_insert_selector,
                                    baseUrl=URL('harvest', 'edit_insert'),
                                    selectorTitle='Fill all fields')

    freeLeaf = PanelWithUrlSelector(virtdb.free_harvester_selector,
                                    baseUrl=URL('harvest', 'free_run'),
                                    selectorTitle='Fill all fields',
                                    timeout=ONE_HOUR)

    harvesterLeaf = PanelWithUrlSelector(virtdb.harvester_selector,
                                         baseUrl=URL('harvest', 'run'),
                                         extField='format',
                                         timeout=ONE_HOUR)

    marc12Leaf = PanelWithUrlSelector(virtdb.marc12_selector,
                                      selectorTitle='Fill all fields',
                                      baseUrl=URL('harvest', 'insert_marcxml'))

    runAllLeaf = PanelWithUrlSelector(virtdb.run_all_harvesters_selector,
                                      baseUrl=URL('harvest', 'run_all'),
                                      extField='format',
                                      timeout=ONE_HOUR)

    harvestNode = Node(T('Harvest'))
    harvestNode.add_child(T('edit and insert'), editLeaf)
    harvestNode.add_child(T('insert MARCXML'), marc12Leaf)
    harvestNode.add_child(T('run a free harvester'), freeLeaf)
    harvestNode.add_child(T('run a harvester'), harvesterLeaf)
    harvestNode.add_child(T('run all harvesters'), runAllLeaf)

    harvestNode.sort_children()

155
#-------------------------------------------------------------------------------
156
#
157
# HELP NODE
158
#
159
#-------------------------------------------------------------------------------
160
aboutLeaf = Panel(autoLoad=URL('plugin_dbui', 'about'), autoScroll=True)
161 162 163 164 165 166 167 168

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

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

169 170 171 172 173 174 175
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('default', 'guides'))

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

176 177 178 179 180 181
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('plugin_dbui', 'versions'))

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

183
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
184
helpNode.add_child(T('about'), aboutLeaf)
185
helpNode.add_child(T('guides'), guidesLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
186
helpNode.add_child(T('versions'), versionLeaf)
187

188
if session.role == ADMIN:
189
    helpNode.add_child(T('documentations'), docLeaf)
190

191 192
helpNode.sort_children()

193
#-------------------------------------------------------------------------------
194
#
195
# REPORT NODE
196
#
197
#-------------------------------------------------------------------------------
198 199 200 201 202
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('graphs', 'dashboard'))

203 204
dashBoardLeaf = Panel(loader=loader,
                      plugins=['pPanelLoaderException'],
205 206
                      autoScroll=True)

207
graphLeaf = PanelWithUrlSelector(virtdb.graph_selector,
208
                                  baseUrl=URL('graphs', 'index'))
LE GAC Renaud's avatar
LE GAC Renaud committed
209

210
listLeaf = PanelWithUrlSelector(virtdb.list_selector,
211 212
                                baseUrl=URL('lists', 'index'),
                                extField='format',
213
                                plugins=['pMathJax'])
214

215
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector,
216 217
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
218

219
reportNode = Node(T('Reports'))
220
reportNode.add_child(T('dashboard'), dashBoardLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
221 222
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
223
reportNode.add_child(T('graphs'), graphLeaf)
224

225
#-------------------------------------------------------------------------------
226
#
227
# WIZARD NODE
228
#
229
#-------------------------------------------------------------------------------
230
wizardNode = None
231
if session.role in (ADMIN, USER):
232
    authorLeaf = PanelWithUrlSelector(virtdb.authors_selector,
233
                                      baseUrl=URL('wizards', 'extract_authors'))
234

235
    checkLeaf = PanelWithUrlSelector(virtdb.check_selector,
236
                                     baseUrl=URL('wizards', 'check_validate'),
237 238
                                     extField='format',
                                     timeout=ONE_HOUR)
239

240
    wizardNode = Node(T('Wizards'))
LE GAC Renaud's avatar
LE GAC Renaud committed
241
    wizardNode.add_child(T('extract authors'), authorLeaf)
242

243
    if session.role == ADMIN:
LE GAC Renaud's avatar
LE GAC Renaud committed
244
        wizardNode.add_child(T('check and validate'), checkLeaf)
245 246
    else:
        wizardNode.add_child(T('check'), checkLeaf)
247

248
    wizardNode.sort_children()
249

250
#-------------------------------------------------------------------------------
251
#
252
# VIEWPORT
253
#
254
#-------------------------------------------------------------------------------
255
nodes = [helpNode,
256
         appNode,
257
         wizardNode,
258
         confHarvesterNode,
LE GAC Renaud's avatar
LE GAC Renaud committed
259 260
         confListNode,
         confMetricNode,
261
         dataInstituteNode,
262 263
         dataPublicationeNode,
         harvestNode,
264 265
         reportNode]

266
viewportModifier = dbui.ViewportModifier()
267
viewportModifier.add_node(*nodes)
268

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

271 272
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
273
    viewportModifier.configure(logged=False,
LE GAC Renaud's avatar
LE GAC Renaud committed
274
                               plugins=['pViewportLogin'])
275

276
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
277
    viewportModifier.configure(logged=True)
278
    viewportModifier.default_node(T('Data publications'), T('publications'))
279 280

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