author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 02 Jun 2010 15:29:18 +0200 | |
changeset 5633 | 879590c52679 |
parent 5527 | 01a7228ab5a0 |
child 5752 | b0bb553e3be4 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5001
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
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:
5001
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5483
1a30c5a56256
merge good/bad versions of imported patches...
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
18 |
"""Set of HTML base actions""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
2121 | 21 |
_ = unicode |
0 | 22 |
|
4932
dce5ebe5d598
add missing warn imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4583
diff
changeset
|
23 |
from warnings import warn |
dce5ebe5d598
add missing warn imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4583
diff
changeset
|
24 |
|
5483
1a30c5a56256
merge good/bad versions of imported patches...
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
25 |
from logilab.mtconverter import xml_escape |
1a30c5a56256
merge good/bad versions of imported patches...
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
26 |
|
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
27 |
from cubicweb.schema import display_name |
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2652
diff
changeset
|
28 |
from cubicweb.appobject import objectify_selector |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
29 |
from cubicweb.selectors import (EntitySelector, yes, |
4320
4efd4c306746
closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
30 |
one_line_rset, multi_lines_rset, one_etype_rset, relation_possible, |
1829
f54710fcdd62
avoid SelectAction selection to crash on startup views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1551
diff
changeset
|
31 |
nonempty_rset, non_final_entity, |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
32 |
authenticated_user, match_user_groups, match_search_state, |
5480
2d5c46e78ae9
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
33 |
has_permission, has_add_permission, implements, debug_mode, |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
34 |
) |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
35 |
from cubicweb.web import uicfg, controller, action |
824
a5e6acffde30
merge, split baseviews (new csvexport, xmlrss and editviews modules)
sylvain.thenault@logilab.fr
parents:
822
diff
changeset
|
36 |
from cubicweb.web.views import linksearch_select_url, vid_from_rset |
0 | 37 |
|
1178 | 38 |
|
39 |
class has_editable_relation(EntitySelector): |
|
40 |
"""accept if some relations for an entity found in the result set is |
|
41 |
editable by the logged user. |
|
42 |
||
43 |
See `EntitySelector` documentation for behaviour when row is not specified. |
|
44 |
""" |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
45 |
|
1178 | 46 |
def score_entity(self, entity): |
47 |
# if user has no update right but it can modify some relation, |
|
48 |
# display action anyway |
|
3504 | 49 |
form = entity._cw.vreg['forms'].select('edition', entity._cw, |
4583 | 50 |
entity=entity) |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
51 |
for dummy in form.editable_relations(): |
1178 | 52 |
return 1 |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
53 |
try: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
54 |
editableattrs = form.editable_attributes(strict=True) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
55 |
except TypeError: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
56 |
warn('[3.6] %s: editable_attributes now take strict=False as ' |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
57 |
'optional argument', DeprecationWarning) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3451
diff
changeset
|
58 |
editableattrs = form.editable_attributes() |
3730
d6f95bd1032d
editable-attributes return a list of 2-uple
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3720
diff
changeset
|
59 |
for rschema, role in editableattrs: |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3495
diff
changeset
|
60 |
if not rschema.final: |
1178 | 61 |
return 1 |
62 |
return 0 |
|
63 |
||
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
64 |
@objectify_selector |
2161
200481e7b156
prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2121
diff
changeset
|
65 |
def match_searched_etype(cls, req, rset=None, **kwargs): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
66 |
return req.match_search_state(rset) |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
67 |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
68 |
@objectify_selector |
2161
200481e7b156
prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2121
diff
changeset
|
69 |
def view_is_not_default_view(cls, req, rset=None, **kwargs): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
70 |
# interesting if it propose another view than the current one |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
71 |
vid = req.form.get('vid') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
72 |
if vid and vid != vid_from_rset(req, rset, req.vreg.schema): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
73 |
return 1 |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
74 |
return 0 |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
75 |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
76 |
@objectify_selector |
2161
200481e7b156
prepare time where it won't be mandatory to give rset to select()
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2121
diff
changeset
|
77 |
def addable_etype_empty_rset(cls, req, rset=None, **kwargs): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
78 |
if rset is not None and not rset.rowcount: |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
79 |
rqlst = rset.syntax_tree() |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
80 |
if len(rqlst.children) > 1: |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
81 |
return 0 |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
82 |
select = rqlst.children[0] |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
83 |
if len(select.defined_vars) == 1 and len(select.solutions) == 1: |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
84 |
rset._searched_etype = select.solutions[0].itervalues().next() |
4087 | 85 |
eschema = req.vreg.schema.eschema(rset._searched_etype) |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3495
diff
changeset
|
86 |
if not (eschema.final or eschema.is_subobject(strict=True)) \ |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
87 |
and eschema.has_perm(req, 'add'): |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
88 |
return 1 |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
89 |
return 0 |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
90 |
|
2470 | 91 |
# generic 'main' actions ####################################################### |
0 | 92 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
93 |
class SelectAction(action.Action): |
0 | 94 |
"""base class for link search actions. By default apply on |
95 |
any size entity result search it the current state is 'linksearch' |
|
96 |
if accept match. |
|
97 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
98 |
__regid__ = 'select' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
99 |
__select__ = (match_search_state('linksearch') & nonempty_rset() |
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
100 |
& match_searched_etype()) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
101 |
|
0 | 102 |
title = _('select') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
103 |
category = 'mainactions' |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
104 |
order = 0 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
105 |
|
0 | 106 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
107 |
return linksearch_select_url(self._cw, self.cw_rset) |
0 | 108 |
|
109 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
110 |
class CancelSelectAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
111 |
__regid__ = 'cancel' |
707 | 112 |
__select__ = match_search_state('linksearch') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
113 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
114 |
title = _('cancel select') |
0 | 115 |
category = 'mainactions' |
116 |
order = 10 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
117 |
|
0 | 118 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
119 |
target, eid, r_type, searched_type = self._cw.search_state[1] |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
120 |
return self._cw.build_url(str(eid), |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
121 |
vid='edition', __mode='normal') |
0 | 122 |
|
123 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
124 |
class ViewAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
125 |
__regid__ = 'view' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
126 |
__select__ = (action.Action.__select__ & |
707 | 127 |
match_user_groups('users', 'managers') & |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
128 |
view_is_not_default_view() & |
707 | 129 |
non_final_entity()) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
130 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
131 |
title = _('view') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
132 |
category = 'mainactions' |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
133 |
order = 0 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
134 |
|
0 | 135 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
136 |
params = self._cw.form.copy() |
2701
afcc19c92072
fix #344895: view action should skip navigation parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2161
diff
changeset
|
137 |
for param in ('vid', '__message') + controller.NAV_FORM_PARAMETERS: |
afcc19c92072
fix #344895: view action should skip navigation parameters
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2161
diff
changeset
|
138 |
params.pop(param, None) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
139 |
return self._cw.build_url(self._cw.relative_path(includeparams=False), |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
140 |
**params) |
0 | 141 |
|
142 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
143 |
class ModifyAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
144 |
__regid__ = 'edit' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
145 |
__select__ = (action.Action.__select__ & one_line_rset() & |
707 | 146 |
(has_permission('update') | has_editable_relation('add'))) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
147 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
148 |
title = _('modify') |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
149 |
category = 'mainactions' |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
150 |
order = 10 |
0 | 151 |
|
152 |
def url(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
153 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
0 | 154 |
return entity.absolute_url(vid='edition') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
155 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
156 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
157 |
class MultipleEditAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
158 |
__regid__ = 'muledit' # XXX get strange conflicts if id='edit' |
4320
4efd4c306746
closes #345410: two_lines_rset, two_cols_rset, two_etypes_rset are badly named
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
159 |
__select__ = (action.Action.__select__ & multi_lines_rset() & |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
160 |
one_etype_rset() & has_permission('update')) |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
161 |
|
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
162 |
title = _('modify') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
163 |
category = 'mainactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
164 |
order = 10 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
165 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
166 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
167 |
return self._cw.build_url('view', rql=self.cw_rset.rql, vid='muledit') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
168 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
169 |
|
2470 | 170 |
# generic "more" actions ####################################################### |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
171 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
172 |
class ManagePermissionsAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
173 |
__regid__ = 'managepermission' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
174 |
__select__ = (action.Action.__select__ & one_line_rset() & |
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
175 |
non_final_entity() & match_user_groups('managers')) |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
176 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
177 |
title = _('manage permissions') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
178 |
category = 'moreactions' |
1551 | 179 |
order = 15 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
180 |
|
707 | 181 |
@classmethod |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4462
diff
changeset
|
182 |
def __registered__(cls, reg): |
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4462
diff
changeset
|
183 |
if 'require_permission' in reg.schema: |
822 | 184 |
cls.__select__ = (one_line_rset() & non_final_entity() & |
185 |
(match_user_groups('managers') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
186 |
| relation_possible('require_permission', 'subject', 'CWPermission', |
822 | 187 |
action='add'))) |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4462
diff
changeset
|
188 |
return super(ManagePermissionsAction, cls).__registered__(reg) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
189 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
190 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
191 |
return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).absolute_url(vid='security') |
0 | 192 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
193 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
194 |
class DeleteAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
195 |
__regid__ = 'delete' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
196 |
__select__ = action.Action.__select__ & has_permission('delete') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
197 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
198 |
title = _('delete') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
199 |
category = 'moreactions' |
0 | 200 |
order = 20 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
201 |
|
0 | 202 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
203 |
if len(self.cw_rset) == 1: |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
204 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
205 |
return self._cw.build_url(entity.rest_path(), vid='deleteconf') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
206 |
return self._cw.build_url(rql=self.cw_rset.printable_rql(), vid='deleteconf') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
207 |
|
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
208 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
209 |
class CopyAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
210 |
__regid__ = 'copy' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
211 |
__select__ = (action.Action.__select__ & one_line_rset() |
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
212 |
& has_permission('add')) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
213 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
214 |
title = _('copy') |
0 | 215 |
category = 'moreactions' |
216 |
order = 30 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
217 |
|
0 | 218 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
219 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
0 | 220 |
return entity.absolute_url(vid='copy') |
221 |
||
222 |
||
223 |
class AddNewAction(MultipleEditAction): |
|
224 |
"""when we're seeing more than one entity with the same type, propose to |
|
225 |
add a new one |
|
226 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
227 |
__regid__ = 'addentity' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
228 |
__select__ = (action.Action.__select__ & |
707 | 229 |
(addable_etype_empty_rset() |
4462
c57c8176b8c2
reorganize, cleanup and properly document base selectors. Kill the may_add_relation selector.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4419
diff
changeset
|
230 |
| (multi_lines_rset() & one_etype_rset() & has_add_permission())) |
707 | 231 |
) |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
232 |
|
0 | 233 |
category = 'moreactions' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
234 |
order = 40 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
235 |
|
0 | 236 |
@property |
237 |
def rsettype(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
238 |
if self.cw_rset: |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
239 |
return self.cw_rset.description[0][0] |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
240 |
return self.cw_rset._searched_etype |
0 | 241 |
|
242 |
@property |
|
243 |
def title(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
244 |
return self._cw.__('add a %s' % self.rsettype) # generated msgid |
0 | 245 |
|
246 |
def url(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
247 |
return self._cw.build_url('add/%s' % self.rsettype) |
0 | 248 |
|
249 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
250 |
class AddRelatedActions(action.Action): |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
251 |
"""fill 'addrelated' sub-menu of the actions box""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
252 |
__regid__ = 'addrelated' |
3504 | 253 |
__select__ = action.Action.__select__ & one_line_rset() & non_final_entity() |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
254 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
255 |
submenu = _('addrelated') |
5241
1460d69672bc
[test] fix unittest_viewselector
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5001
diff
changeset
|
256 |
order = 17 |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
257 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
258 |
def fill_menu(self, box, menu): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
259 |
# when there is only one item in the sub-menu, replace the sub-menu by |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
260 |
# item's title prefixed by 'add' |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
261 |
menu.label_prefix = self._cw._('add') |
3228
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
262 |
super(AddRelatedActions, self).fill_menu(box, menu) |
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
263 |
|
7b05b2709439
[actions] refactor: extract actual_actions from fill_menu to work with table filter form
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3219
diff
changeset
|
264 |
def actual_actions(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
265 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
266 |
eschema = entity.e_schema |
5521
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
267 |
for rschema, teschema, role in self.add_related_schemas(entity): |
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
268 |
if rschema.role_rdef(eschema, teschema, role).role_cardinality(role) in '1?': |
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
269 |
if entity.related(rschema, role): |
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
270 |
continue |
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
271 |
if role == 'subject': |
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
272 |
label = 'add %s %s %s %s' % (eschema, rschema, teschema, role) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
273 |
url = self.linkto_url(entity, rschema, teschema, 'object') |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
274 |
else: |
5521
4c53a0cb186c
[actions box] enhance add related menu generation: don't propose to add relation of single cardinality where entity already have the relation set
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
275 |
label = 'add %s %s %s %s' % (teschema, rschema, eschema, role) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
276 |
url = self.linkto_url(entity, rschema, teschema, 'subject') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
277 |
yield self.build_action(self._cw._(label), url) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
278 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
279 |
def add_related_schemas(self, entity): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
280 |
"""this is actually used ui method to generate 'addrelated' actions from |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
281 |
the schema. |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
282 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
283 |
If you don't want any auto-generated actions, you should overrides this |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
284 |
method to return an empty list. If you only want some, you can configure |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
285 |
them by using uicfg.actionbox_appearsin_addmenu |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
286 |
""" |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
287 |
appearsin_addmenu = uicfg.actionbox_appearsin_addmenu |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
288 |
req = self._cw |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
289 |
eschema = entity.e_schema |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
290 |
for role, rschemas in (('subject', eschema.subject_relations()), |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
291 |
('object', eschema.object_relations())): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
292 |
for rschema in rschemas: |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3495
diff
changeset
|
293 |
if rschema.final: |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
294 |
continue |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
295 |
for teschema in rschema.targets(eschema, role): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
296 |
if not appearsin_addmenu.etype_get(eschema, rschema, |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
297 |
role, teschema): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
298 |
continue |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
299 |
rdef = rschema.role_rdef(eschema, teschema, role) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
300 |
# check the relation can be added |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
301 |
# XXX consider autoform_permissions_overrides? |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
302 |
if role == 'subject'and not rdef.has_perm( |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
303 |
req, 'add', fromeid=entity.eid): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
304 |
continue |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
305 |
if role == 'object'and not rdef.has_perm( |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
306 |
req, 'add', toeid=entity.eid): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
307 |
continue |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
308 |
# check the target types can be added as well |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
309 |
if teschema.may_have_permission('add', req): |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
310 |
yield rschema, teschema, role |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
311 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
312 |
def linkto_url(self, entity, rtype, etype, target): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
313 |
return self._cw.build_url('add/%s' % etype, |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
314 |
__linkto='%s:%s:%s' % (rtype, entity.eid, target), |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
315 |
__redirectpath=entity.rest_path(), # should not be url quoted! |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
316 |
__redirectvid=self._cw.form.get('vid', '')) |
3219
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
317 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
318 |
|
4413 | 319 |
class ViewSameCWEType(action.Action): |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
320 |
"""when displaying the schema of a CWEType, offer to list entities of that type |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
321 |
""" |
4413 | 322 |
__regid__ = 'entitiesoftype' |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
323 |
__select__ = one_line_rset() & implements('CWEType') |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
324 |
category = 'mainactions' |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
325 |
order = 40 |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
326 |
|
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
327 |
@property |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
328 |
def etype(self): |
4419
1f777d13a76b
refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4413
diff
changeset
|
329 |
return self.cw_rset.get_entity(0,0).name |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
330 |
|
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
331 |
@property |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
332 |
def title(self): |
4419
1f777d13a76b
refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4413
diff
changeset
|
333 |
return self._cw.__('view all %s') % display_name(self._cw, self.etype, 'plural').lower() |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
334 |
|
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
335 |
def url(self): |
4419
1f777d13a76b
refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4413
diff
changeset
|
336 |
return self._cw.build_url(self.etype) |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
337 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
338 |
# logged user actions ######################################################### |
0 | 339 |
|
3504 | 340 |
class UserPreferencesAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
341 |
__regid__ = 'myprefs' |
707 | 342 |
__select__ = authenticated_user() |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
343 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
344 |
title = _('user preferences') |
0 | 345 |
category = 'useractions' |
346 |
order = 10 |
|
347 |
||
348 |
def url(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
349 |
return self._cw.build_url(self.__regid__) |
0 | 350 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
351 |
|
3504 | 352 |
class UserInfoAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
353 |
__regid__ = 'myinfos' |
707 | 354 |
__select__ = authenticated_user() |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
355 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
356 |
title = _('personnal informations') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
357 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
358 |
order = 20 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
359 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
360 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
361 |
return self._cw.build_url('cwuser/%s'%self._cw.user.login, vid='edition') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
362 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
363 |
|
3504 | 364 |
class LogoutAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
365 |
__regid__ = 'logout' |
707 | 366 |
__select__ = authenticated_user() |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
367 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
368 |
title = _('logout') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
369 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
370 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
371 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
372 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
373 |
return self._cw.build_url(self.__regid__) |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
374 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
375 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
376 |
# site actions ################################################################ |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
377 |
|
3504 | 378 |
class ManagersAction(action.Action): |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
379 |
__abstract__ = True |
707 | 380 |
__select__ = match_user_groups('managers') |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
381 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
382 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
383 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
384 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
385 |
return self._cw.build_url(self.__regid__) |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
386 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
387 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
388 |
class SiteConfigurationAction(ManagersAction): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
389 |
__regid__ = 'siteconfig' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
390 |
title = _('site configuration') |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
391 |
order = 10 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
392 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
393 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
394 |
class ManageAction(ManagersAction): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
395 |
__regid__ = 'manage' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
396 |
title = _('manage') |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
554
diff
changeset
|
397 |
order = 20 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
398 |
|
2439
77d8dd77acb3
[cleanup] fix tests
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2433
diff
changeset
|
399 |
class SiteInfoAction(ManagersAction): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
400 |
__regid__ = 'siteinfo' |
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
401 |
__select__ = match_user_groups('users','managers') |
2433
1d46c016a564
#197873: quick access to info for bug report
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2161
diff
changeset
|
402 |
title = _('info') |
1d46c016a564
#197873: quick access to info for bug report
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2161
diff
changeset
|
403 |
order = 30 |
1d46c016a564
#197873: quick access to info for bug report
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2161
diff
changeset
|
404 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
405 |
|
3504 | 406 |
# footer actions ############################################################### |
407 |
||
408 |
class PoweredByAction(action.Action): |
|
3645
7272b793d7c9
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3504
diff
changeset
|
409 |
__regid__ = 'poweredby' |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
410 |
__select__ = yes() |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
411 |
|
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
412 |
category = 'footer' |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
413 |
order = 3 |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
414 |
title = _('powered by CubicWeb') |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
415 |
|
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
416 |
def url(self): |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
417 |
return 'http://www.cubicweb.org' |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
418 |
|
5477
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
419 |
class GotRhythmAction(action.Action): |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
420 |
__regid__ = 'rhythm' |
5480
2d5c46e78ae9
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
421 |
__select__ = debug_mode() |
5477
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
422 |
|
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
423 |
category = 'footer' |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
424 |
order = 3 |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
425 |
title = _('Got rhythm?') |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
426 |
|
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
427 |
def url(self): |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
428 |
return xml_escape(self._cw.url()+'#') |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
429 |
|
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
430 |
def html_class(self): |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
431 |
self._cw.add_js('cubicweb.rhythm.js') |
f79c39be0b9b
[css] introducing scale and rhythm composition
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
432 |
return 'rhythm' |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
433 |
|
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
434 |
## default actions ui configuration ########################################### |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
435 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
436 |
addmenu = uicfg.actionbox_appearsin_addmenu |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
437 |
addmenu.tag_subject_of(('*', 'require_permission', '*'), False) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
438 |
addmenu.tag_object_of(('*', 'relation_type', 'CWRType'), True) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
439 |
addmenu.tag_object_of(('*', 'from_entity', 'CWEType'), False) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
440 |
addmenu.tag_object_of(('*', 'to_entity', 'CWEType'), False) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
441 |
addmenu.tag_object_of(('*', 'in_group', 'CWGroup'), True) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
442 |
addmenu.tag_object_of(('*', 'bookmarked_by', 'CWUser'), True) |