widgets_viewport.py 7.51 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 26
    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'))
    
27
#-------------------------------------------------------------------------------
28
#
29
# CONFIGURE HARVESTERS
30
#
31
#-------------------------------------------------------------------------------
32 33
confHarvesterNode = None
if session.role in (ADMIN, USER):
34
    
35
    leaves = ('controllers', 'cppm_authors', 'harvesters')
36

37 38 39 40 41
    if session.role == USER:
        leaves = ('cppm_authors', 'harvesters')
        
    confHarvesterNode = Node(T('Configure harvesters'))
    confHarvesterNode.add_children(leaves, func=to_grid)
42

43
#-------------------------------------------------------------------------------
44
#
LE GAC Renaud's avatar
LE GAC Renaud committed
45
# CONFIGURE LISTS
46
#
47
#-------------------------------------------------------------------------------
LE GAC Renaud's avatar
LE GAC Renaud committed
48
confListNode = None
49
if session.role == ADMIN:
50

LE GAC Renaud's avatar
LE GAC Renaud committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
    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:
66

LE GAC Renaud's avatar
LE GAC Renaud committed
67 68
    confMetricNode = Node(T('Configure metrics'))
    confMetricNode.add_child(T('metrics'), to_grid('metrics'))
69
     
70
#-------------------------------------------------------------------------------
71
#
72
# DATA INSTITUT
73
#
74
#-------------------------------------------------------------------------------
75 76 77
dataInstituteNode = None
if session.role == ADMIN:

LE GAC Renaud's avatar
LE GAC Renaud committed
78
    leaves = ('projects', 'teams')
79 80 81

    dataInstituteNode = Node(T('Data institute'))
    dataInstituteNode.add_children(leaves, func=to_grid)
LE GAC Renaud's avatar
LE GAC Renaud committed
82 83
    
    dataInstituteNode.add_child(T('Relation team / projects'), to_grid('organisation'))
84 85 86 87 88 89 90
     
#-------------------------------------------------------------------------------
#
# DATA PUBLICATIONS
#
#-------------------------------------------------------------------------------
dataPublicationeNode = None
91
if session.role in (ADMIN, USER):
92

93 94 95 96 97 98
    leaves = ('categories', 
              'collaborations', 
              'countries',
              'publications', 
              'publishers',
              'status')
99

100
    if session.role == USER:
LE GAC Renaud's avatar
LE GAC Renaud committed
101
        leaves = ('publications',)
102 103 104 105
        
    dataPublicationeNode = Node(T('Data publications'))
    dataPublicationeNode.add_children(leaves, func=to_grid)
    
106
#-------------------------------------------------------------------------------
107
#
108
# HELP NODE
109
#
110
#-------------------------------------------------------------------------------
111 112 113
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'))
114

115
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
116 117
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
118

119
if session.role == ADMIN:
120
    helpNode.add_child(T('documentations'), documentationsLeaf)
121 122 123
    
helpNode.sort_children()

124
#-------------------------------------------------------------------------------
125
#
126
# REPORT NODE
127
#
128
#-------------------------------------------------------------------------------
129 130 131
listLeaf = PanelWithUrlSelector(virtdb.list_selector, 
                                baseUrl=URL('lists', 'index'),
                                extField='format',
132
                                plugins=['pMathJax'])
133

134 135 136
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector, 
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
137

138
reportNode = Node(T('Reports'))
LE GAC Renaud's avatar
LE GAC Renaud committed
139 140
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
141 142 143

reportNode.sort_children()

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

191
#-------------------------------------------------------------------------------
192
#
193
# VIEWPORT
194
#
195
#-------------------------------------------------------------------------------
196 197 198 199
nodes = [helpNode, 
         casNode, 
         wizardNode, 
         confHarvesterNode, 
LE GAC Renaud's avatar
LE GAC Renaud committed
200 201
         confListNode,
         confMetricNode,
202 203 204 205
         dataInstituteNode,
         dataPublicationeNode, 
         reportNode]

206
viewportModifier = dbui.ViewportModifier()
207
viewportModifier.add_node(*nodes)
208

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

211 212
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
LE GAC Renaud's avatar
LE GAC Renaud committed
213 214
    viewportModifier.configure(logged=False, 
                               plugins=['pViewportLogin'])
215
 
216
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
217
    viewportModifier.configure(logged=True)
218
    viewportModifier.default_node(T('Data publications'), T('publications'))