author | Alexandre Fayolle <alexandre.fayolle@logilab.fr> |
Fri, 30 Sep 2011 18:08:00 +0200 | |
branch | stable |
changeset 7900 | e9b79f5c3571 |
parent 7897 | defac26f4151 |
child 7990 | a673d1d9a738 |
permissions | -rw-r--r-- |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
1 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
7897
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
18 |
"""This module contains the default index page and management view. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
19 |
|
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
20 |
.. autoclass:: IndexView |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
21 |
.. autoclass:: ManageView |
5839 | 22 |
""" |
0 | 23 |
|
24 |
__docformat__ = "restructuredtext en" |
|
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1544
diff
changeset
|
25 |
_ = unicode |
0 | 26 |
|
1132 | 27 |
from logilab.common.textutils import unormalize |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
28 |
from logilab.common.deprecation import deprecated |
2387
ea1defea9636
[views] fix some crashers (schema still does not render properly, might be yams side)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
29 |
from logilab.mtconverter import xml_escape |
0 | 30 |
|
1532
111c52e0022f
duh? remaining __selectors__, probably a wrong merge
sylvain.thenault@logilab.fr
parents:
1523
diff
changeset
|
31 |
from cubicweb.view import StartupView |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5849
diff
changeset
|
32 |
from cubicweb.selectors import match_user_groups, is_instance |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
33 |
from cubicweb.schema import display_name |
1635
866563e2d0fc
don't depends on simplejson outside web/
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
34 |
from cubicweb.web import ajax_replace_url, uicfg, httpcache |
0 | 35 |
|
36 |
class ManageView(StartupView): |
|
7897
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
37 |
""":__regid__: *manage* |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
38 |
|
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
39 |
The manage view, display some information about what's contained by your |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
40 |
site and provides access to administration stuff such as user and groups |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
41 |
management. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
42 |
|
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
43 |
Regarding the section displaying link to entity type, notice by default it |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
44 |
won't display entity types which are related to another one using a |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
45 |
mandatory (cardinality == 1) composite relation. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
46 |
|
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
47 |
You can still configure that behaviour manually using the |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
48 |
`indexview_etype_section` as explained in :mod:`cubicweb.web.uicfg`. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
49 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3023
diff
changeset
|
50 |
__regid__ = 'manage' |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
51 |
title = _('manage') |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1544
diff
changeset
|
52 |
http_cache_manager = httpcache.EtagHTTPCacheManager |
3500
ab10d1cb53ff
[ui api] backport create_links from forge so it may be reused
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
53 |
add_etype_links = () |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
54 |
skip_startup_views = set( ('index', 'manage', 'schema', 'owl', 'changelog', |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
55 |
'systempropertiesform', 'propertiesform', |
6962
220e32f058be
[management ui] add views to manage sources similarly to users
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
56 |
'cw.user-management', 'cw.source-management', |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
57 |
'siteinfo', 'info', 'registry', 'gc', |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
58 |
'tree') ) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
59 |
|
0 | 60 |
def call(self, **kwargs): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2436
diff
changeset
|
61 |
"""The default view representing the instance's management""" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
62 |
self._cw.add_css('cubicweb.manageview.css') |
5478
c52124b7a00e
[css] progressively fixing rhythm
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
63 |
self.w(u'<h1>%s</h1>' % self._cw.property_value('ui.site-title')) |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
64 |
self.entities() |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
65 |
self.manage_actions() |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
66 |
self.startup_views() |
0 | 67 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
68 |
def manage_actions(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
69 |
allactions = self._cw.vreg['actions'].possible_actions(self._cw) |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
70 |
if allactions.get('manage'): |
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2780
diff
changeset
|
71 |
self.w(u'<div class="hr"> </div>') |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
72 |
self.w(u'<h2>%s</h2>\n' % self._cw._('Manage')) |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
73 |
self.w(u'<ul class="manageActions">') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
74 |
for action in allactions['manage']: |
3500
ab10d1cb53ff
[ui api] backport create_links from forge so it may be reused
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
75 |
self.w(u'<li><a href="%s">%s</a></li>' % ( |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
76 |
action.url(), self._cw._(action.title))) |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
77 |
self.w(u'</ul>') |
3500
ab10d1cb53ff
[ui api] backport create_links from forge so it may be reused
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2996
diff
changeset
|
78 |
|
0 | 79 |
def startup_views(self): |
6966
0f45b1dad08d
[manage view] filter before displaying anything avoid xhtml errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6962
diff
changeset
|
80 |
views = [v for v in self._cw.vreg['views'].possible_views(self._cw, None) |
0f45b1dad08d
[manage view] filter before displaying anything avoid xhtml errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6962
diff
changeset
|
81 |
if v.category == 'startupview' |
6971
33afb8748052
[manage view] fix skipping of startup views
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6966
diff
changeset
|
82 |
and v.__regid__ not in self.skip_startup_views] |
5479
6ba3587c5cda
[css] start using uiprops in cubicweb.css
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
5478
diff
changeset
|
83 |
if not views: |
6ba3587c5cda
[css] start using uiprops in cubicweb.css
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
5478
diff
changeset
|
84 |
return |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
85 |
self.w(u'<div class="hr"> </div>') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
86 |
self.w(u'<h2>%s</h2>\n' % self._cw._('Startup views')) |
5819
1017163825c7
[css] more css rework, need visual test in compat/new modes
katia
parents:
5718
diff
changeset
|
87 |
self.w(u'<ul class="startup">') |
5530
da21e3fbe240
[startup view] sort startup views by alphabetical order
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
88 |
for v in sorted(views, key=lambda x: self._cw._(x.title)): |
5479
6ba3587c5cda
[css] start using uiprops in cubicweb.css
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
5478
diff
changeset
|
89 |
self.w('<li><a href="%s">%s</a></li>' % ( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
90 |
xml_escape(v.url()), xml_escape(self._cw._(v.title).capitalize()))) |
5479
6ba3587c5cda
[css] start using uiprops in cubicweb.css
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
5478
diff
changeset
|
91 |
self.w(u'</ul>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
92 |
|
0 | 93 |
def entities(self): |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
94 |
schema = self._cw.vreg.schema |
6973
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
95 |
eschemas = [eschema for eschema in schema.entities() |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
96 |
if uicfg.indexview_etype_section.get(eschema) == 'application'] |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
97 |
if eschemas: |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
98 |
self.w(u'<div class="hr"> </div>') |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
99 |
self.w(u'<h2>%s</h2>\n' % self._cw._('Browse by entity type')) |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
100 |
self.w(u'<table class="startup">') |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
101 |
self.entity_types_table(eschemas) |
d2cd38749c17
[manage view] get etypes first to avoid xhtml validation error if no one found
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6971
diff
changeset
|
102 |
self.w(u'</table>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
103 |
|
0 | 104 |
def entity_types_table(self, eschemas): |
105 |
infos = sorted(self.entity_types(eschemas), |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
106 |
key=lambda (l,a,e): unormalize(l)) |
0 | 107 |
q, r = divmod(len(infos), 2) |
108 |
if r: |
|
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2780
diff
changeset
|
109 |
infos.append( (None, ' ', ' ') ) |
0 | 110 |
infos = zip(infos[:q+r], infos[q+r:]) |
111 |
for (_, etypelink, addlink), (_, etypelink2, addlink2) in infos: |
|
112 |
self.w(u'<tr>\n') |
|
113 |
self.w(u'<td class="addcol">%s</td><td>%s</td>\n' % (addlink, etypelink)) |
|
114 |
self.w(u'<td class="addcol">%s</td><td>%s</td>\n' % (addlink2, etypelink2)) |
|
115 |
self.w(u'</tr>\n') |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
116 |
|
0 | 117 |
def entity_types(self, eschemas): |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
118 |
"""return an iterator on formatted links to get a list of entities of |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
119 |
each entity types |
0 | 120 |
""" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
121 |
req = self._cw |
0 | 122 |
for eschema in eschemas: |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
123 |
if eschema.final or not eschema.may_have_permission('read', req): |
0 | 124 |
continue |
125 |
etype = eschema.type |
|
126 |
nb = req.execute('Any COUNT(X) WHERE X is %s' % etype)[0][0] |
|
4144 | 127 |
if nb > 1: |
128 |
label = display_name(req, etype, 'plural') |
|
129 |
else: |
|
130 |
label = display_name(req, etype) |
|
0 | 131 |
nb = req.execute('Any COUNT(X) WHERE X is %s' % etype)[0][0] |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
132 |
url = self._cw.build_url(etype) |
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2780
diff
changeset
|
133 |
etypelink = u' <a href="%s">%s</a> (%d)' % ( |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2265
diff
changeset
|
134 |
xml_escape(url), label, nb) |
6041
31776723c0c5
[index page] refactor add_entity_link: no need to give request, nicer to check perm before calling the method, and use the new create url factory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5877
diff
changeset
|
135 |
if eschema.has_perm(req, 'add'): |
31776723c0c5
[index page] refactor add_entity_link: no need to give request, nicer to check perm before calling the method, and use the new create url factory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5877
diff
changeset
|
136 |
yield (label, etypelink, self.add_entity_link(etype)) |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
137 |
else: |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
138 |
yield (label, etypelink, u'') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
139 |
|
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
140 |
def create_links(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
141 |
self.w(u'<ul class="createLink">') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
142 |
for etype in self.add_etype_links: |
7265
8eedf71f280e
[deprecation] kill a remaining 3.6 warning
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6973
diff
changeset
|
143 |
eschema = self._cw.vreg.schema.eschema(etype) |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
144 |
if eschema.has_perm(self._cw, 'add'): |
7681
32c4c9bab046
[index page] use 'New xxx' generated labels, 'add a xxx' labels are only generated according to inlined form configuration and with an associated context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7265
diff
changeset
|
145 |
url = self._cw.vreg["etypes"].etype_class(etype).cw_create_url(self._cw) |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
146 |
self.w(u'<li><a href="%s">%s</a></li>' % ( |
7681
32c4c9bab046
[index page] use 'New xxx' generated labels, 'add a xxx' labels are only generated according to inlined form configuration and with an associated context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7265
diff
changeset
|
147 |
url, self._cw.__('New %s' % eschema).capitalize())) |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
148 |
self.w(u'</ul>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
149 |
|
6041
31776723c0c5
[index page] refactor add_entity_link: no need to give request, nicer to check perm before calling the method, and use the new create url factory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5877
diff
changeset
|
150 |
def add_entity_link(self, etype): |
31776723c0c5
[index page] refactor add_entity_link: no need to give request, nicer to check perm before calling the method, and use the new create url factory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5877
diff
changeset
|
151 |
"""creates a [+] link for adding an entity""" |
31776723c0c5
[index page] refactor add_entity_link: no need to give request, nicer to check perm before calling the method, and use the new create url factory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5877
diff
changeset
|
152 |
url = self._cw.vreg["etypes"].etype_class(etype).cw_create_url(self._cw) |
0 | 153 |
return u'[<a href="%s" title="%s">+</a>]' % ( |
7681
32c4c9bab046
[index page] use 'New xxx' generated labels, 'add a xxx' labels are only generated according to inlined form configuration and with an associated context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7265
diff
changeset
|
154 |
xml_escape(url), self._cw.__('New %s' % etype)) |
0 | 155 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
156 |
@deprecated('[3.11] display_folders method is deprecated, backport it if needed') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
157 |
def display_folders(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
158 |
return False |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
159 |
|
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
160 |
@deprecated('[3.11] folders method is deprecated, backport it if needed') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
161 |
def folders(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
162 |
self.w(u'<h2>%s</h2>\n' % self._cw._('Browse by category')) |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
163 |
self._cw.vreg['views'].select('tree', self._cw).render(w=self.w, maxlevel=1) |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
164 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
165 |
|
0 | 166 |
class IndexView(ManageView): |
7897
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
167 |
""":__regid__: *index* |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
168 |
|
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
169 |
The default index view, that you'll get when accessing your site's root url. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
170 |
It's by default indentical to the |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
171 |
:class:`~cubicweb.web.views.startup.ManageView`, but you'll usually want to |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
172 |
customize this one. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
173 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3023
diff
changeset
|
174 |
__regid__ = 'index' |
2368
b41aef0e63a7
use msgid, update i18n
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
175 |
title = _('view_index') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
176 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
177 |
@deprecated('[3.11] display_folders method is deprecated, backport it if needed') |
0 | 178 |
def display_folders(self): |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
179 |
return 'Folder' in self._cw.vreg.schema and self._cw.execute('Any COUNT(X) WHERE X is Folder')[0][0] |
2748
d2fcf19bfb34
F [registry views] add _registry startup view
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2687
diff
changeset
|
180 |