4 :organization: Logilab |
4 :organization: Logilab |
5 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
|
9 _ = unicode |
9 |
10 |
10 from logilab.common.textutils import unormalize |
11 from logilab.common.textutils import unormalize |
11 from logilab.mtconverter import html_escape |
12 from logilab.mtconverter import html_escape |
12 |
13 |
13 from cubicweb.common.uilib import ureport_as_html, ajax_replace_url |
|
14 from cubicweb.view import StartupView |
14 from cubicweb.view import StartupView |
15 from cubicweb.selectors import match_user_groups |
15 from cubicweb.selectors import match_user_groups |
16 from cubicweb.web.httpcache import EtagHTTPCacheManager |
16 from cubicweb.common.uilib import ureport_as_html, ajax_replace_url |
|
17 from cubicweb.web import uicfg, httpcache |
17 from cubicweb.web.views.management import SecurityViewMixIn |
18 from cubicweb.web.views.management import SecurityViewMixIn |
18 from copy import deepcopy |
|
19 _ = unicode |
|
20 |
19 |
21 |
20 |
22 class ManageView(StartupView): |
21 class ManageView(StartupView): |
23 id = 'manage' |
22 id = 'manage' |
24 title = _('manage') |
23 title = _('manage') |
25 http_cache_manager = EtagHTTPCacheManager |
24 http_cache_manager = httpcache.EtagHTTPCacheManager |
|
25 |
|
26 @classmethod |
|
27 def vreg_initialization_completed(cls): |
|
28 for eschema in cls.schema.entities(): |
|
29 if eschema.schema_entity(): |
|
30 uicfg.etypecat.setdefault(eschema, 'schema') |
|
31 elif eschema.is_subobject(strict=True): |
|
32 uicfg.etypecat.setdefault(eschema, 'subobject') |
|
33 elif eschema.meta: |
|
34 uicfg.etypecat.setdefault(eschema, 'system') |
|
35 else: |
|
36 uicfg.etypecat.setdefault(eschema, 'application') |
26 |
37 |
27 def display_folders(self): |
38 def display_folders(self): |
28 return False |
39 return False |
29 |
40 |
30 def call(self, **kwargs): |
41 def call(self, **kwargs): |
87 manager = self.req.user.matching_groups('managers') |
98 manager = self.req.user.matching_groups('managers') |
88 self.w(u'<table class="startup">') |
99 self.w(u'<table class="startup">') |
89 if manager: |
100 if manager: |
90 self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('application entities')) |
101 self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('application entities')) |
91 self.entity_types_table(eschema for eschema in schema.entities() |
102 self.entity_types_table(eschema for eschema in schema.entities() |
92 if not eschema.meta and not eschema.is_subobject(strict=True)) |
103 if uicfg.etypecat.get(eschema) == 'application') |
93 if manager: |
104 if manager: |
94 self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('system entities')) |
105 self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('system entities')) |
95 self.entity_types_table(eschema for eschema in schema.entities() |
106 self.entity_types_table(eschema for eschema in schema.entities() |
96 if eschema.meta and not eschema.schema_entity()) |
107 if uicfg.etypecat.get(eschema) == 'system') |
97 if 'CWAttribute' in schema: # check schema support |
108 if 'CWAttribute' in schema: # check schema support |
98 self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('schema entities')) |
109 self.w(u'<tr><th colspan="4">%s</th></tr>\n' % self.req._('schema entities')) |
99 self.entity_types_table(schema.eschema(etype) |
110 self.entity_types_table(eschema for eschema in schema.entities() |
100 for etype in schema.schema_entity_types()) |
111 if uicfg.etypecat.get(eschema) == 'schema') |
101 self.w(u'</table>') |
112 self.w(u'</table>') |
102 |
113 |
103 def entity_types_table(self, eschemas): |
114 def entity_types_table(self, eschemas): |
104 newline = 0 |
115 newline = 0 |
105 infos = sorted(self.entity_types(eschemas), |
116 infos = sorted(self.entity_types(eschemas), |