author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 24 Mar 2010 15:08:24 +0100 | |
branch | stable |
changeset 4995 | 1817b87c7f67 |
parent 4932 | dce5ebe5d598 |
child 5001 | 4f6a1295a8d2 |
permissions | -rw-r--r-- |
0 | 1 |
"""Set of HTML base actions |
2 |
||
3 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3689
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1829
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
2121 | 9 |
_ = unicode |
0 | 10 |
|
4932
dce5ebe5d598
add missing warn imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4583
diff
changeset
|
11 |
from warnings import warn |
dce5ebe5d598
add missing warn imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4583
diff
changeset
|
12 |
|
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
13 |
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
|
14 |
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
|
15 |
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
|
16 |
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
|
17 |
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
|
18 |
authenticated_user, match_user_groups, match_search_state, |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
19 |
has_permission, has_add_permission, implements, |
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
|
20 |
) |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
21 |
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
|
22 |
from cubicweb.web.views import linksearch_select_url, vid_from_rset |
0 | 23 |
|
1178 | 24 |
|
25 |
class has_editable_relation(EntitySelector): |
|
26 |
"""accept if some relations for an entity found in the result set is |
|
27 |
editable by the logged user. |
|
28 |
||
29 |
See `EntitySelector` documentation for behaviour when row is not specified. |
|
30 |
""" |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
31 |
|
1178 | 32 |
def score_entity(self, entity): |
33 |
# if user has no update right but it can modify some relation, |
|
34 |
# display action anyway |
|
3504 | 35 |
form = entity._cw.vreg['forms'].select('edition', entity._cw, |
4583 | 36 |
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
|
37 |
for dummy in form.editable_relations(): |
1178 | 38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
'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
|
44 |
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
|
45 |
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
|
46 |
if not rschema.final: |
1178 | 47 |
return 1 |
48 |
return 0 |
|
49 |
||
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
50 |
@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
|
51 |
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
|
52 |
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
|
53 |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
54 |
@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
|
55 |
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
|
56 |
# 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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
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
|
61 |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
62 |
@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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
rset._searched_etype = select.solutions[0].itervalues().next() |
4087 | 71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
|
2470 | 77 |
# generic 'main' actions ####################################################### |
0 | 78 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
79 |
class SelectAction(action.Action): |
0 | 80 |
"""base class for link search actions. By default apply on |
81 |
any size entity result search it the current state is 'linksearch' |
|
82 |
if accept match. |
|
83 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
84 |
__regid__ = 'select' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
85 |
__select__ = (match_search_state('linksearch') & nonempty_rset() |
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
86 |
& match_searched_etype()) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
87 |
|
0 | 88 |
title = _('select') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
89 |
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
|
90 |
order = 0 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
91 |
|
0 | 92 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
93 |
return linksearch_select_url(self._cw, self.cw_rset) |
0 | 94 |
|
95 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
96 |
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
|
97 |
__regid__ = 'cancel' |
707 | 98 |
__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
|
99 |
|
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
|
100 |
title = _('cancel select') |
0 | 101 |
category = 'mainactions' |
102 |
order = 10 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
103 |
|
0 | 104 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
vid='edition', __mode='normal') |
0 | 108 |
|
109 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
110 |
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
|
111 |
__regid__ = 'view' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
112 |
__select__ = (action.Action.__select__ & |
707 | 113 |
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
|
114 |
view_is_not_default_view() & |
707 | 115 |
non_final_entity()) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
116 |
|
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
|
117 |
title = _('view') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
118 |
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
|
119 |
order = 0 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
120 |
|
0 | 121 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
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
|
126 |
**params) |
0 | 127 |
|
128 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
129 |
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
|
130 |
__regid__ = 'edit' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
131 |
__select__ = (action.Action.__select__ & one_line_rset() & |
707 | 132 |
(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
|
133 |
|
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
|
134 |
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
|
135 |
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
|
136 |
order = 10 |
0 | 137 |
|
138 |
def url(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
139 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
0 | 140 |
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
|
141 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
142 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
143 |
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
|
144 |
__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
|
145 |
__select__ = (action.Action.__select__ & multi_lines_rset() & |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
146 |
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
|
147 |
|
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') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
149 |
category = 'mainactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
150 |
order = 10 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
151 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
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 |
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
|
154 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
155 |
|
2470 | 156 |
# generic "more" actions ####################################################### |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
157 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
158 |
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
|
159 |
__regid__ = 'managepermission' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
160 |
__select__ = (action.Action.__select__ & one_line_rset() & |
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
161 |
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
|
162 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
163 |
title = _('manage permissions') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
164 |
category = 'moreactions' |
1551 | 165 |
order = 15 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
166 |
|
707 | 167 |
@classmethod |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4462
diff
changeset
|
168 |
def __registered__(cls, reg): |
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4462
diff
changeset
|
169 |
if 'require_permission' in reg.schema: |
822 | 170 |
cls.__select__ = (one_line_rset() & non_final_entity() & |
171 |
(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
|
172 |
| relation_possible('require_permission', 'subject', 'CWPermission', |
822 | 173 |
action='add'))) |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4462
diff
changeset
|
174 |
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
|
175 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
176 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
177 |
return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).absolute_url(vid='security') |
0 | 178 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
179 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
180 |
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
|
181 |
__regid__ = 'delete' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
182 |
__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
|
183 |
|
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
|
184 |
title = _('delete') |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
185 |
category = 'moreactions' |
0 | 186 |
order = 20 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
187 |
|
0 | 188 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
189 |
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
|
190 |
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
|
191 |
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
|
192 |
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
|
193 |
|
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
194 |
|
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
195 |
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
|
196 |
__regid__ = 'copy' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
197 |
__select__ = (action.Action.__select__ & one_line_rset() |
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
198 |
& has_permission('add')) |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
199 |
|
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
|
200 |
title = _('copy') |
0 | 201 |
category = 'moreactions' |
202 |
order = 30 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
203 |
|
0 | 204 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
205 |
entity = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0) |
0 | 206 |
return entity.absolute_url(vid='copy') |
207 |
||
208 |
||
209 |
class AddNewAction(MultipleEditAction): |
|
210 |
"""when we're seeing more than one entity with the same type, propose to |
|
211 |
add a new one |
|
212 |
""" |
|
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
213 |
__regid__ = 'addentity' |
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
214 |
__select__ = (action.Action.__select__ & |
707 | 215 |
(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
|
216 |
| (multi_lines_rset() & one_etype_rset() & has_add_permission())) |
707 | 217 |
) |
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
|
218 |
|
0 | 219 |
category = 'moreactions' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
220 |
order = 40 |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
221 |
|
0 | 222 |
@property |
223 |
def rsettype(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
224 |
if self.cw_rset: |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
225 |
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
|
226 |
return self.cw_rset._searched_etype |
0 | 227 |
|
228 |
@property |
|
229 |
def title(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
230 |
return self._cw.__('add a %s' % self.rsettype) # generated msgid |
0 | 231 |
|
232 |
def url(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
233 |
return self._cw.build_url('add/%s' % self.rsettype) |
0 | 234 |
|
235 |
||
3484
52e6c8d62ac6
fix some actions selectors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
236 |
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
|
237 |
"""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
|
238 |
__regid__ = 'addrelated' |
3504 | 239 |
__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
|
240 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
241 |
submenu = _('addrelated') |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
242 |
order = 20 |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
243 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
244 |
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
|
245 |
# 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
|
246 |
# 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
|
247 |
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
|
248 |
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
|
249 |
|
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
|
250 |
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
|
251 |
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
|
252 |
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
|
253 |
for rschema, teschema, x in self.add_related_schemas(entity): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
254 |
if x == 'subject': |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
255 |
label = 'add %s %s %s %s' % (eschema, rschema, teschema, x) |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
256 |
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
|
257 |
else: |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
258 |
label = 'add %s %s %s %s' % (teschema, rschema, eschema, x) |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
259 |
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
|
260 |
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
|
261 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
262 |
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
|
263 |
"""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
|
264 |
the schema. |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
265 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
""" |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
('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
|
275 |
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
|
276 |
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
|
277 |
continue |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
role, teschema): |
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
281 |
continue |
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
282 |
rdef = rschema.role_rdef(eschema, teschema, role) |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
283 |
# check the relation can be added |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
284 |
# XXX consider autoform_permissions_overrides? |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
285 |
if role == 'subject'and not rdef.has_perm( |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
286 |
req, 'add', fromeid=entity.eid): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
287 |
continue |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
288 |
if role == 'object'and not rdef.has_perm( |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
289 |
req, 'add', toeid=entity.eid): |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
290 |
continue |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
291 |
# check the target types can be added as well |
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
292 |
if teschema.may_have_permission('add', req): |
4995
1817b87c7f67
[web] move workflow related uicfg stuff to the workflow module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4932
diff
changeset
|
293 |
print 'hop', 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
|
294 |
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
|
295 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
296 |
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
|
297 |
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
|
298 |
__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
|
299 |
__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
|
300 |
__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
|
301 |
|
be8cfc00ae04
edit box refactoring to gain more control by using actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2715
diff
changeset
|
302 |
|
4413 | 303 |
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
|
304 |
"""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
|
305 |
""" |
4413 | 306 |
__regid__ = 'entitiesoftype' |
4412
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
307 |
__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
|
308 |
category = 'mainactions' |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
309 |
order = 40 |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
310 |
|
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
311 |
@property |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
312 |
def etype(self): |
4419
1f777d13a76b
refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4413
diff
changeset
|
313 |
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
|
314 |
|
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
315 |
@property |
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
316 |
def title(self): |
4419
1f777d13a76b
refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4413
diff
changeset
|
317 |
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
|
318 |
|
eaff00ef0a71
add action to list entities of the CWEType currently displayed
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4320
diff
changeset
|
319 |
def url(self): |
4419
1f777d13a76b
refactor to use the 3.6 API
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
4413
diff
changeset
|
320 |
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
|
321 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
322 |
# logged user actions ######################################################### |
0 | 323 |
|
3504 | 324 |
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
|
325 |
__regid__ = 'myprefs' |
707 | 326 |
__select__ = authenticated_user() |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
327 |
|
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
|
328 |
title = _('user preferences') |
0 | 329 |
category = 'useractions' |
330 |
order = 10 |
|
331 |
||
332 |
def url(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
333 |
return self._cw.build_url(self.__regid__) |
0 | 334 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
335 |
|
3504 | 336 |
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
|
337 |
__regid__ = 'myinfos' |
707 | 338 |
__select__ = authenticated_user() |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
339 |
|
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
|
340 |
title = _('personnal informations') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
341 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
342 |
order = 20 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
343 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
344 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
345 |
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
|
346 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
347 |
|
3504 | 348 |
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
|
349 |
__regid__ = 'logout' |
707 | 350 |
__select__ = authenticated_user() |
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
351 |
|
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
|
352 |
title = _('logout') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
353 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
354 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
355 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
356 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
357 |
return self._cw.build_url(self.__regid__) |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
358 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
359 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
360 |
# site actions ################################################################ |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
361 |
|
3504 | 362 |
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
|
363 |
__abstract__ = True |
707 | 364 |
__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
|
365 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
366 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
367 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
368 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
369 |
return self._cw.build_url(self.__regid__) |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
370 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
371 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
372 |
class SiteConfigurationAction(ManagersAction): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
373 |
__regid__ = 'siteconfig' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
374 |
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
|
375 |
order = 10 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
376 |
|
1452
546b9884d92c
delete spaces, use .row .col instead of fixed 0 0
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
377 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
378 |
class ManageAction(ManagersAction): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
379 |
__regid__ = 'manage' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
380 |
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
|
381 |
order = 20 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
382 |
|
2439
77d8dd77acb3
[cleanup] fix tests
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2433
diff
changeset
|
383 |
class SiteInfoAction(ManagersAction): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
384 |
__regid__ = 'siteinfo' |
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
385 |
__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
|
386 |
title = _('info') |
1d46c016a564
#197873: quick access to info for bug report
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2161
diff
changeset
|
387 |
order = 30 |
1d46c016a564
#197873: quick access to info for bug report
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2161
diff
changeset
|
388 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
389 |
|
3504 | 390 |
# footer actions ############################################################### |
391 |
||
392 |
class PoweredByAction(action.Action): |
|
3645
7272b793d7c9
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3504
diff
changeset
|
393 |
__regid__ = 'poweredby' |
3495
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
394 |
__select__ = yes() |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
395 |
|
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
396 |
category = 'footer' |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
397 |
order = 3 |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
398 |
title = _('powered by CubicWeb') |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
399 |
|
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
400 |
def url(self): |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
401 |
return 'http://www.cubicweb.org' |
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
402 |
|
438576c5b1d1
[ui] turn footer items into actions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3272
diff
changeset
|
403 |
|
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
404 |
## default actions ui configuration ########################################### |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
405 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
406 |
addmenu = uicfg.actionbox_appearsin_addmenu |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2470
diff
changeset
|
407 |
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
|
408 |
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
|
409 |
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
|
410 |
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
|
411 |
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
|
412 |
addmenu.tag_object_of(('*', 'bookmarked_by', 'CWUser'), True) |