16 from cubicweb.selectors import match_user_groups, implements |
16 from cubicweb.selectors import match_user_groups, implements |
17 from cubicweb.schema import display_name |
17 from cubicweb.schema import display_name |
18 from cubicweb.web import ajax_replace_url, uicfg, httpcache |
18 from cubicweb.web import ajax_replace_url, uicfg, httpcache |
19 |
19 |
20 class ManageView(StartupView): |
20 class ManageView(StartupView): |
21 id = 'manage' |
21 __regid__ = 'manage' |
22 title = _('manage') |
22 title = _('manage') |
23 http_cache_manager = httpcache.EtagHTTPCacheManager |
23 http_cache_manager = httpcache.EtagHTTPCacheManager |
24 |
24 |
25 def display_folders(self): |
25 def display_folders(self): |
26 return False |
26 return False |
138 xml_escape(self.create_url(eschema.type)), |
138 xml_escape(self.create_url(eschema.type)), |
139 self.req.__('add a %s' % eschema)) |
139 self.req.__('add a %s' % eschema)) |
140 |
140 |
141 |
141 |
142 class IndexView(ManageView): |
142 class IndexView(ManageView): |
143 id = 'index' |
143 __regid__ = 'index' |
144 title = _('view_index') |
144 title = _('view_index') |
145 |
145 |
146 def display_folders(self): |
146 def display_folders(self): |
147 return 'Folder' in self.schema and self.req.execute('Any COUNT(X) WHERE X is Folder')[0][0] |
147 return 'Folder' in self.schema and self.req.execute('Any COUNT(X) WHERE X is Folder')[0][0] |
148 |
148 |
149 |
|
150 class RegistryView(StartupView): |
|
151 id = 'registry' |
|
152 title = _('registry') |
|
153 __select__ = StartupView.__select__ & match_user_groups('managers') |
|
154 |
|
155 def call(self, **kwargs): |
|
156 """The default view representing the instance's management""" |
|
157 self.w(u'<h1>%s</h1>' % _("Registry's content")) |
|
158 keys = sorted(self.vreg) |
|
159 self.w(u'<p>%s</p>\n' % ' - '.join('<a href="/_registry#%s">%s</a>' % (key, key) for key in keys)) |
|
160 for key in keys: |
|
161 self.w(u'<h2><a name="%s">%s</a></h2>' % (key,key)) |
|
162 items = self.vreg[key].items() |
|
163 if items: |
|
164 self.w(u'<table><tbody>') |
|
165 for key, value in sorted(items): |
|
166 self.w(u'<tr><td>%s</td><td>%s</td></tr>' % (key, xml_escape(repr(value)))) |
|
167 self.w(u'</tbody></table>\n') |
|
168 else: |
|
169 self.w(u'<p>Empty</p>\n') |
|
170 |
|