author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Wed, 09 May 2012 17:15:44 +0200 | |
changeset 8394 | b8b23af60019 |
parent 8349 | fdb796435d7b |
child 8632 | fa044b9157d7 |
permissions | -rw-r--r-- |
8169
f9fb7d903800
[manage/index view] fix sources management view appearing in index view although it should not; closes #2126335
Florent Cayré <florent.cayre@gmail.com>
parents:
7990
diff
changeset
|
1 |
# copyright 2003-2012 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 |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8169
diff
changeset
|
32 |
from cubicweb.predicates 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 |
7990
a673d1d9a738
[diet] drop pre 3.6 API compatibility (but attempt to keep data cmopatibility). Closes #2017916
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7897
diff
changeset
|
34 |
from cubicweb.web import 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', |
8319
f6d455b9346f
[manage / default index views] discard login/logout templates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8169
diff
changeset
|
56 |
'loggedout', 'login', |
8169
f9fb7d903800
[manage/index view] fix sources management view appearing in index view although it should not; closes #2126335
Florent Cayré <florent.cayre@gmail.com>
parents:
7990
diff
changeset
|
57 |
'cw.users-and-groups-management', 'cw.groups-management', |
f9fb7d903800
[manage/index view] fix sources management view appearing in index view although it should not; closes #2126335
Florent Cayré <florent.cayre@gmail.com>
parents:
7990
diff
changeset
|
58 |
'cw.users-management', 'cw.sources-management', |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
59 |
'siteinfo', 'info', 'registry', 'gc', |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
60 |
'tree') ) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
61 |
|
0 | 62 |
def call(self, **kwargs): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2436
diff
changeset
|
63 |
"""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
|
64 |
self._cw.add_css('cubicweb.manageview.css') |
5478
c52124b7a00e
[css] progressively fixing rhythm
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5424
diff
changeset
|
65 |
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
|
66 |
self.entities() |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
67 |
self.manage_actions() |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
68 |
self.startup_views() |
0 | 69 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
70 |
def manage_actions(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
71 |
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
|
72 |
if allactions.get('manage'): |
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2780
diff
changeset
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
|
0 | 81 |
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
|
82 |
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
|
83 |
if v.category == 'startupview' |
6971
33afb8748052
[manage view] fix skipping of startup views
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6966
diff
changeset
|
84 |
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
|
85 |
if not views: |
6ba3587c5cda
[css] start using uiprops in cubicweb.css
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
5478
diff
changeset
|
86 |
return |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
87 |
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
|
88 |
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
|
89 |
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
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
self.w(u'</ul>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
94 |
|
0 | 95 |
def entities(self): |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
self.w(u'</table>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
105 |
|
0 | 106 |
def entity_types_table(self, eschemas): |
107 |
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
|
108 |
key=lambda (l,a,e): unormalize(l)) |
0 | 109 |
q, r = divmod(len(infos), 2) |
110 |
if r: |
|
2996
866a2c135c33
B #345282 xhtml requires to use   instead of
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2780
diff
changeset
|
111 |
infos.append( (None, ' ', ' ') ) |
0 | 112 |
infos = zip(infos[:q+r], infos[q+r:]) |
113 |
for (_, etypelink, addlink), (_, etypelink2, addlink2) in infos: |
|
114 |
self.w(u'<tr>\n') |
|
115 |
self.w(u'<td class="addcol">%s</td><td>%s</td>\n' % (addlink, etypelink)) |
|
116 |
self.w(u'<td class="addcol">%s</td><td>%s</td>\n' % (addlink2, etypelink2)) |
|
117 |
self.w(u'</tr>\n') |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
118 |
|
0 | 119 |
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
|
120 |
"""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
|
121 |
each entity types |
0 | 122 |
""" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
123 |
req = self._cw |
0 | 124 |
for eschema in eschemas: |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
125 |
if eschema.final or not eschema.may_have_permission('read', req): |
0 | 126 |
continue |
127 |
etype = eschema.type |
|
128 |
nb = req.execute('Any COUNT(X) WHERE X is %s' % etype)[0][0] |
|
4144 | 129 |
if nb > 1: |
130 |
label = display_name(req, etype, 'plural') |
|
131 |
else: |
|
132 |
label = display_name(req, etype) |
|
0 | 133 |
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
|
134 |
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
|
135 |
etypelink = u' <a href="%s">%s</a> (%d)' % ( |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2265
diff
changeset
|
136 |
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
|
137 |
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
|
138 |
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
|
139 |
else: |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
140 |
yield (label, etypelink, u'') |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
141 |
|
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
142 |
def create_links(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
self.w(u'</ul>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
151 |
|
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
|
152 |
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
|
153 |
"""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
|
154 |
url = self._cw.vreg["etypes"].etype_class(etype).cw_create_url(self._cw) |
0 | 155 |
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
|
156 |
xml_escape(url), self._cw.__('New %s' % etype)) |
0 | 157 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
158 |
@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
|
159 |
def display_folders(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
160 |
return False |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
161 |
|
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
162 |
@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
|
163 |
def folders(self): |
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
164 |
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
|
165 |
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
|
166 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
167 |
|
0 | 168 |
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
|
169 |
""":__regid__: *index* |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
170 |
|
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
: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
|
174 |
customize this one. |
defac26f4151
[book] startup views: add a note about *manage* view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7681
diff
changeset
|
175 |
""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3023
diff
changeset
|
176 |
__regid__ = 'index' |
2368
b41aef0e63a7
use msgid, update i18n
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2312
diff
changeset
|
177 |
title = _('view_index') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
178 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6931
diff
changeset
|
179 |
@deprecated('[3.11] display_folders method is deprecated, backport it if needed') |
0 | 180 |
def display_folders(self): |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
3890
diff
changeset
|
181 |
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
|
182 |