widgets_viewport.py 8.25 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 50
    
    confHarvesterNode.add_child(T('harvesters'), to_grid('harvesters'))
    confHarvesterNode.add_child(T('relation harvesters / categories'), to_grid('controllers'))
    confHarvesterNode.add_child(T("author's rescue list"), to_grid('cppm_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 64 65 66 67 68 69 70 71 72 73 74
    confListNode = Node(T('Configure lists'))
    
    # NOTE: hide axes table which contains static data
    # confListNode.add_child('axes', to_grid('axes'))
    confListNode.add_child(T('lists'), to_grid('lists'))
    confListNode.add_child(T('render sections'), to_grid('renderers'))
    confListNode.add_child(T('sections'), to_grid('sections'))
     
#-------------------------------------------------------------------------------
#
# CONFIGURE METRICs
#
#-------------------------------------------------------------------------------
confMetricNode = None
if session.role == ADMIN:
75

LE GAC Renaud's avatar
LE GAC Renaud committed
76 77
    confMetricNode = Node(T('Configure metrics'))
    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)
LE GAC Renaud's avatar
LE GAC Renaud committed
91 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 104 105 106 107
    leaves = ('categories', 
              'collaborations', 
              'countries',
              'publications', 
              'publishers',
              'status')
108

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

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

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

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

145
#-------------------------------------------------------------------------------
146
#
147
# REPORT NODE
148
#
149
#-------------------------------------------------------------------------------
150 151 152
listLeaf = PanelWithUrlSelector(virtdb.list_selector, 
                                baseUrl=URL('lists', 'index'),
                                extField='format',
153
                                plugins=['pMathJax'])
154

155 156 157
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector, 
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
158

159
reportNode = Node(T('Reports'))
LE GAC Renaud's avatar
LE GAC Renaud committed
160 161
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
162 163 164

reportNode.sort_children()

165
#-------------------------------------------------------------------------------
166
#
167
# WIZARD NODE
168
#
169
#-------------------------------------------------------------------------------
170
wizardNode = None
171
if session.role in (ADMIN, USER):
172 173
    authorLeaf = PanelWithUrlSelector(virtdb.authors_selector, 
                                      baseUrl=URL('wizards', 'extract_authors'))
174
    
175 176 177 178
    freeLeaf = PanelWithUrlSelector(virtdb.free_harvester_selector, 
                                    baseUrl=URL('harvest', 'free_run'),
                                    selectorTitle='Fill all fields',
                                    timeout=ONE_HOUR)
179
    
180 181
    checkLeaf = PanelWithUrlSelector(virtdb.check_selector, 
                                     baseUrl=URL('wizards', 'check_validate'),
182 183
                                     extField='format',
                                     timeout=ONE_HOUR)
184
    
185 186 187 188
    harvesterLeaf = PanelWithUrlSelector(virtdb.harvester_selector, 
                                         baseUrl=URL('harvest', 'run'),
                                         extField='format',
                                         timeout=ONE_HOUR)
189
    
190 191 192
    marc12Leaf = PanelWithUrlSelector(virtdb.marc12_selector, 
                                      selectorTitle='Fill all fields',
                                      baseUrl=URL('harvest', 'insert_marcxml')) 
193
    
194 195 196 197
    runAllLeaf = PanelWithUrlSelector(virtdb.run_all_harvesters_selector, 
                                      baseUrl=URL('harvest', 'run_all'),
                                      extField='format',
                                      timeout=ONE_HOUR)
198
    
199
    wizardNode = Node(T('Wizards'))
LE GAC Renaud's avatar
LE GAC Renaud committed
200 201
    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
202 203 204
    wizardNode.add_child(T('extract authors'), authorLeaf)
    wizardNode.add_child(T('run a harvester'), harvesterLeaf)
    wizardNode.add_child(T('run all harvesters'), runAllLeaf)
205
    
206
    if session.role == ADMIN:
LE GAC Renaud's avatar
LE GAC Renaud committed
207
        wizardNode.add_child(T('check and validate'), checkLeaf)
208 209 210
    else:
        wizardNode.add_child(T('check'), checkLeaf)
    
211
    wizardNode.sort_children()
212

213
#-------------------------------------------------------------------------------
214
#
215
# VIEWPORT
216
#
217
#-------------------------------------------------------------------------------
218 219
nodes = [helpNode, 
         casNode, 
220 221
         wizardNode,
         confAppNode,
222
         confHarvesterNode, 
LE GAC Renaud's avatar
LE GAC Renaud committed
223 224
         confListNode,
         confMetricNode,
225 226 227 228
         dataInstituteNode,
         dataPublicationeNode, 
         reportNode]

229
viewportModifier = dbui.ViewportModifier()
230
viewportModifier.add_node(*nodes)
231

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

234 235
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
LE GAC Renaud's avatar
LE GAC Renaud committed
236 237
    viewportModifier.configure(logged=False, 
                               plugins=['pViewportLogin'])
238
 
239
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
240
    viewportModifier.configure(logged=True)
241
    viewportModifier.default_node(T('Data publications'), T('publications'))