widgets_viewport.py 9.72 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 = None
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:

87
    leaves = ('affiliation_keys', '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

#-------------------------------------------------------------------------------
#
# HARVESTER NODE
#
#-------------------------------------------------------------------------------
harvestNode = None
if session.role in (ADMIN, USER):

    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)

    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('run a free harvester'), freeLeaf)
    harvestNode.add_child(T('run a harvester'), harvesterLeaf)
    harvestNode.add_child(T('run all harvesters'), runAllLeaf)

    harvestNode.sort_children()

146
#-------------------------------------------------------------------------------
147
#
148
# HELP NODE
149
#
150
#-------------------------------------------------------------------------------
151 152 153 154 155 156
loader = dict(autoLoad=True,
              renderer='html',
              scripts=False,
              url=URL('plugin_dbui', 'about'))

aboutLeaf = Panel(loader=loader, autoScroll=True)
157 158 159 160

loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
161
              url=URL('plugin_dbui', 'documentations_table'))
162 163 164

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

165 166 167 168 169 170 171
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('default', 'guides'))

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

172 173 174 175 176 177
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('plugin_dbui', 'versions'))

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

179
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
180
helpNode.add_child(T('about'), aboutLeaf)
181
helpNode.add_child(T('guides'), guidesLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
182
helpNode.add_child(T('versions'), versionLeaf)
183

184
if session.role == ADMIN:
185
    helpNode.add_child(T('documentations'), docLeaf)
186

187 188
helpNode.sort_children()

189
#-------------------------------------------------------------------------------
190
#
191
# REPORT NODE
192
#
193
#-------------------------------------------------------------------------------
194 195 196 197 198
loader = dict(autoLoad=True,
              renderer='html',
              scripts=True,
              url=URL('graphs', 'dashboard'))

199 200
dashBoardLeaf = Panel(loader=loader,
                      plugins=['pPanelLoaderException'],
201 202
                      autoScroll=True)

203
graphLeaf = PanelWithUrlSelector(virtdb.graph_selector,
204 205
                                 baseUrl=URL('graphs', 'index'),
                                 extField='format')
LE GAC Renaud's avatar
LE GAC Renaud committed
206

207
listLeaf = PanelWithUrlSelector(virtdb.list_selector,
208 209
                                baseUrl=URL('lists', 'index'),
                                extField='format',
210
                                plugins=['pMathJax'])
211

212
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector,
213 214
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
215

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

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

232
    checkLeaf = PanelWithUrlSelector(virtdb.check_selector,
233
                                     baseUrl=URL('wizards', 'check_validate'),
234 235
                                     extField='format',
                                     timeout=ONE_HOUR)
236

237 238 239 240 241 242 243 244 245
    editLeaf = PanelWithUrlSelector(virtdb.edit_insert_selector,
                                    baseUrl=URL('harvest', 'edit_insert'),
                                    selectorTitle='Fill all fields')

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


246
    wizardNode = Node(T('Wizards'))
LE GAC Renaud's avatar
LE GAC Renaud committed
247
    wizardNode.add_child(T('extract authors'), authorLeaf)
248

249
    if session.role == ADMIN:
LE GAC Renaud's avatar
LE GAC Renaud committed
250
        wizardNode.add_child(T('check and validate'), checkLeaf)
251 252
    else:
        wizardNode.add_child(T('check'), checkLeaf)
253

254 255 256
    wizardNode.add_child(T('edit and insert'), editLeaf)
    wizardNode.add_child(T('insert MARCXML'), marc12Leaf)

257
    wizardNode.sort_children()
258

259
#-------------------------------------------------------------------------------
260
#
261
# VIEWPORT
262
#
263
#-------------------------------------------------------------------------------
264
nodes = [helpNode,
265
         appNode,
266
         wizardNode,
267
         confHarvesterNode,
LE GAC Renaud's avatar
LE GAC Renaud committed
268 269
         confListNode,
         confMetricNode,
270
         dataInstituteNode,
271 272
         dataPublicationeNode,
         harvestNode,
273 274
         reportNode]

275
viewportModifier = dbui.ViewportModifier()
276
viewportModifier.add_node(*nodes)
277

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

280 281
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
282
    viewportModifier.configure(logged=False,
LE GAC Renaud's avatar
LE GAC Renaud committed
283
                               plugins=['pViewportLogin'])
284

285
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
286
    viewportModifier.configure(logged=True)
287
    viewportModifier.default_node(T('Data publications'), T('publications'))
288 289

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