widgets_viewport.py 6.94 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
    
    leaves = ('auth_user', 'auth_group', 'auth_membership')
22

23 24
    casNode = Node(T('CAS'))
    casNode.add_children(leaves, func=to_grid) 
25

26
#-------------------------------------------------------------------------------
27
#
28
# CONFIGURE HARVESTERS
29
#
30
#-------------------------------------------------------------------------------
31 32
confHarvesterNode = None
if session.role in (ADMIN, USER):
33
    
34
    leaves = ('controllers', 'cppm_authors', 'harvesters')
35

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

42
#-------------------------------------------------------------------------------
43
#
44
# CONFIGURE RAPPORTS
45
#
46
#-------------------------------------------------------------------------------
47
confRapportNode = None
48
if session.role == ADMIN:
49

50
    leaves = ('axes', 'lists', 'metrics', 'renderers', 'sections')
51

52 53 54
    confRapportNode = Node(T('Configure rapports'))
    confRapportNode.add_children(leaves, func=to_grid)
     
55
#-------------------------------------------------------------------------------
56
#
57
# DATA INSTITUT
58
#
59
#-------------------------------------------------------------------------------
60 61 62
dataInstituteNode = None
if session.role == ADMIN:

LE GAC Renaud's avatar
LE GAC Renaud committed
63
    leaves = ('projects', 'teams')
64 65 66

    dataInstituteNode = Node(T('Data institute'))
    dataInstituteNode.add_children(leaves, func=to_grid)
LE GAC Renaud's avatar
LE GAC Renaud committed
67 68
    
    dataInstituteNode.add_child(T('Relation team / projects'), to_grid('organisation'))
69 70 71 72 73 74 75
     
#-------------------------------------------------------------------------------
#
# DATA PUBLICATIONS
#
#-------------------------------------------------------------------------------
dataPublicationeNode = None
76
if session.role in (ADMIN, USER):
77

78 79 80 81 82 83
    leaves = ('categories', 
              'collaborations', 
              'countries',
              'publications', 
              'publishers',
              'status')
84

85 86 87 88 89 90
    if session.role == USER:
        leaves = ('publications')
        
    dataPublicationeNode = Node(T('Data publications'))
    dataPublicationeNode.add_children(leaves, func=to_grid)
    
91
#-------------------------------------------------------------------------------
92
#
93
# HELP NODE
94
#
95
#-------------------------------------------------------------------------------
96 97 98 99
aboutLeaf = Panel(autoLoad=URL('default', 'about'), autoScroll=True)
documentationsLeaf = Panel(autoLoad=URL('default', 'documentations'), autoScroll=True)
schemaLeaf = Panel(autoLoad=URL('default', 'schema'), autoScroll=True)
versionLeaf = Panel(autoLoad=URL('default', 'versions'))
100

101
helpNode = Node(T('Help'))
LE GAC Renaud's avatar
LE GAC Renaud committed
102 103
helpNode.add_child(T('about'), aboutLeaf)
helpNode.add_child(T('versions'), versionLeaf)
104

105
if session.role == ADMIN:
106
    helpNode.add_child(T('documentations'), documentationsLeaf)
107 108 109
    
helpNode.sort_children()

110
#-------------------------------------------------------------------------------
111
#
112
# REPORT NODE
113
#
114
#-------------------------------------------------------------------------------
115 116 117
listLeaf = PanelWithUrlSelector(virtdb.list_selector, 
                                baseUrl=URL('lists', 'index'),
                                extField='format',
118
                                plugins=['pMathJax'])
119

120 121 122
metricLeaf = PanelWithUrlSelector(virtdb.metric_selector, 
                                  baseUrl=URL('metrics', 'index'),
                                  extField='format')
123

124
reportNode = Node(T('Reports'))
LE GAC Renaud's avatar
LE GAC Renaud committed
125 126
reportNode.add_child(T('lists'), listLeaf)
reportNode.add_child(T('metrics'), metricLeaf)
127 128 129

reportNode.sort_children()

130
#-------------------------------------------------------------------------------
131
#
132
# WIZARD NODE
133
#
134
#-------------------------------------------------------------------------------
135
wizardNode = None
136
if session.role in (ADMIN, USER):
137 138
    authorLeaf = PanelWithUrlSelector(virtdb.authors_selector, 
                                      baseUrl=URL('wizards', 'extract_authors'))
139
    
140 141 142 143
    freeLeaf = PanelWithUrlSelector(virtdb.free_harvester_selector, 
                                    baseUrl=URL('harvest', 'free_run'),
                                    selectorTitle='Fill all fields',
                                    timeout=ONE_HOUR)
144
    
145 146 147
    checkLeaf = PanelWithUrlSelector(virtdb.check_selector, 
                                     baseUrl=URL('wizards', 'check_validate'),
                                     extField='format')
148
    
149 150 151 152
    harvesterLeaf = PanelWithUrlSelector(virtdb.harvester_selector, 
                                         baseUrl=URL('harvest', 'run'),
                                         extField='format',
                                         timeout=ONE_HOUR)
153
    
154 155 156
    marc12Leaf = PanelWithUrlSelector(virtdb.marc12_selector, 
                                      selectorTitle='Fill all fields',
                                      baseUrl=URL('harvest', 'insert_marcxml')) 
157
    
158 159 160 161
    runAllLeaf = PanelWithUrlSelector(virtdb.run_all_harvesters_selector, 
                                      baseUrl=URL('harvest', 'run_all'),
                                      extField='format',
                                      timeout=ONE_HOUR)
162
    
163
    wizardNode = Node(T('Wizards'))
LE GAC Renaud's avatar
LE GAC Renaud committed
164 165
    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
166 167 168
    wizardNode.add_child(T('extract authors'), authorLeaf)
    wizardNode.add_child(T('run a harvester'), harvesterLeaf)
    wizardNode.add_child(T('run all harvesters'), runAllLeaf)
169
    
170
    if session.role == ADMIN:
LE GAC Renaud's avatar
LE GAC Renaud committed
171
        wizardNode.add_child(T('check and validate'), checkLeaf)
172 173 174
    else:
        wizardNode.add_child(T('check'), checkLeaf)
    
175
    wizardNode.sort_children()
176

177
#-------------------------------------------------------------------------------
178
#
179
# VIEWPORT
180
#
181
#-------------------------------------------------------------------------------
182 183 184 185 186 187 188 189 190
nodes = [helpNode, 
         casNode, 
         wizardNode, 
         confHarvesterNode, 
         confRapportNode,
         dataInstituteNode,
         dataPublicationeNode, 
         reportNode]

191
viewportModifier = dbui.ViewportModifier()
192
viewportModifier.add_node(*nodes)
193

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

196 197
# NOTE the session.auth only exit when the user is logged
if "auth" in globals():
LE GAC Renaud's avatar
LE GAC Renaud committed
198 199
    viewportModifier.configure(logged=False, 
                               plugins=['pViewportLogin'])
200
 
201
if session.role in (ADMIN, USER):
LE GAC Renaud's avatar
LE GAC Renaud committed
202
    viewportModifier.configure(logged=True)
203
    viewportModifier.default_node(T('Data publications'), T('publications'))