widgets_viewport.py 9.35 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 170 171 172 173 174 175

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'])
176

177
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
178 179
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
180

181
if session.role == ADMIN:
182
    helpNode.add_child(T('documentations'), docLeaf)
183

184 185
helpNode.sort_children()

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

196 197
dashBoardLeaf = Panel(loader=loader,
                      plugins=['pPanelLoaderException'],
198 199
                      autoScroll=True)

200
graphLeaf = PanelWithUrlSelector(virtdb.graph_selector,
201
                                  baseUrl=URL('graphs', 'index'))
LE GAC Renaud's avatar
LE GAC Renaud committed
202

203
listLeaf = PanelWithUrlSelector(virtdb.list_selector,
204 205
                                baseUrl=URL('lists', 'index'),
                                extField='format',
206
                                plugins=['pMathJax'])
207

208
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector,
209 210
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
211

212
reportNode = Node(T('Reports'))
213
reportNode.add_child(T('dashboard'), dashBoardLeaf)
LE GAC Renaud's avatar
LE GAC Renaud committed
214 215
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
216
reportNode.add_child(T('graphs'), graphLeaf)
217

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

228
    checkLeaf = PanelWithUrlSelector(virtdb.check_selector,
229
                                     baseUrl=URL('wizards', 'check_validate'),
230 231
                                     extField='format',
                                     timeout=ONE_HOUR)
232

233
    wizardNode = Node(T('Wizards'))
LE GAC Renaud's avatar
LE GAC Renaud committed
234
    wizardNode.add_child(T('extract authors'), authorLeaf)
235

236
    if session.role == ADMIN:
LE GAC Renaud's avatar
LE GAC Renaud committed
237
        wizardNode.add_child(T('check and validate'), checkLeaf)
238 239
    else:
        wizardNode.add_child(T('check'), checkLeaf)
240

241
    wizardNode.sort_children()
242

243
#-------------------------------------------------------------------------------
244
#
245
# VIEWPORT
246
#
247
#-------------------------------------------------------------------------------
248 249
nodes = [helpNode,
         casNode,
250 251
         wizardNode,
         confAppNode,
252
         confHarvesterNode,
LE GAC Renaud's avatar
LE GAC Renaud committed
253 254
         confListNode,
         confMetricNode,
255
         dataInstituteNode,
256 257
         dataPublicationeNode,
         harvestNode,
258 259
         reportNode]

260
viewportModifier = dbui.ViewportModifier()
261
viewportModifier.add_node(*nodes)
262

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

265 266
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
267
    viewportModifier.configure(logged=False,
LE GAC Renaud's avatar
LE GAC Renaud committed
268
                               plugins=['pViewportLogin'])
269

270
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
271
    viewportModifier.configure(logged=True)
272
    viewportModifier.default_node(T('Data publications'), T('publications'))
273 274

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