widgets_viewport.py 9.61 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 12

# 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
    confListNode = Node(T('Configure lists'))
61

LE GAC Renaud's avatar
LE GAC Renaud committed
62 63
    # 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'))
67

LE GAC Renaud's avatar
LE GAC Renaud committed
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)
92

LE GAC Renaud's avatar
LE GAC Renaud committed
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
    leaves = ('categories',
              'collaborations',
105
              'countries',
106
              'publications',
107 108
              'publishers',
              'status')
109

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

114 115
    dataPublicationeNode = Node(T('Data publications'))
    dataPublicationeNode.add_children(leaves, func=to_grid)
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 155

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

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

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

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

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

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

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

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

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

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

192 193
helpNode.sort_children()

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

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

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

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

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

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

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

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

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

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

249
    wizardNode.sort_children()
250

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

268
viewportModifier = dbui.ViewportModifier()
269
viewportModifier.add_node(*nodes)
270

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

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

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

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