widgets_viewport.py 7.95 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
    leaves = ('cppm_authors', 'harvesters')
47

48 49 50 51 52
    if session.role == USER:
        leaves = ('cppm_authors', 'harvesters')
        
    confHarvesterNode = Node(T('Configure harvesters'))
    confHarvesterNode.add_children(leaves, func=to_grid)
53

54 55
    confHarvesterNode.add_child(T('Relation controller / categories'), to_grid('controllers'))

56
#-------------------------------------------------------------------------------
57
#
LE GAC Renaud's avatar
LE GAC Renaud committed
58
# CONFIGURE LISTS
59
#
60
#-------------------------------------------------------------------------------
LE GAC Renaud's avatar
LE GAC Renaud committed
61
confListNode = None
62
if session.role == ADMIN:
63

LE GAC Renaud's avatar
LE GAC Renaud committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
    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:
79

LE GAC Renaud's avatar
LE GAC Renaud committed
80 81
    confMetricNode = Node(T('Configure metrics'))
    confMetricNode.add_child(T('metrics'), to_grid('metrics'))
82
     
83
#-------------------------------------------------------------------------------
84
#
85
# DATA INSTITUT
86
#
87
#-------------------------------------------------------------------------------
88 89 90
dataInstituteNode = None
if session.role == ADMIN:

LE GAC Renaud's avatar
LE GAC Renaud committed
91
    leaves = ('projects', 'teams')
92 93 94

    dataInstituteNode = Node(T('Data institute'))
    dataInstituteNode.add_children(leaves, func=to_grid)
LE GAC Renaud's avatar
LE GAC Renaud committed
95 96
    
    dataInstituteNode.add_child(T('Relation team / projects'), to_grid('organisation'))
97 98 99 100 101 102 103
     
#-------------------------------------------------------------------------------
#
# DATA PUBLICATIONS
#
#-------------------------------------------------------------------------------
dataPublicationeNode = None
104
if session.role in (ADMIN, USER):
105

106 107 108 109 110 111
    leaves = ('categories', 
              'collaborations', 
              'countries',
              'publications', 
              'publishers',
              'status')
112

113
    if session.role == USER:
LE GAC Renaud's avatar
LE GAC Renaud committed
114
        leaves = ('publications',)
115 116 117 118
        
    dataPublicationeNode = Node(T('Data publications'))
    dataPublicationeNode.add_children(leaves, func=to_grid)
    
119
#-------------------------------------------------------------------------------
120
#
121
# HELP NODE
122
#
123
#-------------------------------------------------------------------------------
124 125 126
aboutLeaf = Panel(autoLoad=URL('plugin_dbui', 'about'), autoScroll=True)
documentationsLeaf = Panel(autoLoad=URL('plugin_dbui', 'documentations'), autoScroll=True)
versionLeaf = Panel(autoLoad=URL('plugin_dbui', 'versions'))
127

128
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
129 130
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
131

132
if session.role == ADMIN:
133
    helpNode.add_child(T('documentations'), documentationsLeaf)
134 135 136
    
helpNode.sort_children()

137
#-------------------------------------------------------------------------------
138
#
139
# REPORT NODE
140
#
141
#-------------------------------------------------------------------------------
142 143 144
listLeaf = PanelWithUrlSelector(virtdb.list_selector, 
                                baseUrl=URL('lists', 'index'),
                                extField='format',
145
                                plugins=['pMathJax'])
146

147 148 149
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector, 
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
150

151
reportNode = Node(T('Reports'))
LE GAC Renaud's avatar
LE GAC Renaud committed
152 153
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
154 155 156

reportNode.sort_children()

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

204
#-------------------------------------------------------------------------------
205
#
206
# VIEWPORT
207
#
208
#-------------------------------------------------------------------------------
209 210
nodes = [helpNode, 
         casNode, 
211 212
         wizardNode,
         confAppNode,
213
         confHarvesterNode, 
LE GAC Renaud's avatar
LE GAC Renaud committed
214 215
         confListNode,
         confMetricNode,
216 217 218 219
         dataInstituteNode,
         dataPublicationeNode, 
         reportNode]

220
viewportModifier = dbui.ViewportModifier()
221
viewportModifier.add_node(*nodes)
222

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

225 226
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
LE GAC Renaud's avatar
LE GAC Renaud committed
227 228
    viewportModifier.configure(logged=False, 
                               plugins=['pViewportLogin'])
229
 
230
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
231
    viewportModifier.configure(logged=True)
232
    viewportModifier.default_node(T('Data publications'), T('publications'))