author | sylvain.thenault@logilab.fr |
Tue, 17 Feb 2009 20:47:22 +0100 | |
branch | tls-sprint |
changeset 690 | ea613e8a5e4f |
parent 660 | 5233a9457f6b |
child 696 | 2a5a19185288 |
permissions | -rw-r--r-- |
0 | 1 |
"""Set of HTML base actions |
2 |
||
3 |
:organization: Logilab |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 |
""" |
|
7 |
__docformat__ = "restructuredtext en" |
|
8 |
||
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
|
9 |
from cubicweb.common.selectors import ( |
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
|
10 |
yes, one_line_rset, two_lines_rset, one_etype_rset, relation_possible, |
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
|
11 |
non_final_entity, |
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
|
12 |
authenticated_user, match_user_groups, match_search_state, |
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
|
13 |
has_editable_relation, has_permission, has_add_permission, |
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
|
14 |
) |
0 | 15 |
|
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
|
16 |
from cubicweb.web.action import Action |
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
|
17 |
from cubicweb.web.views import linksearch_select_url |
0 | 18 |
from cubicweb.web.views.baseviews import vid_from_rset |
19 |
||
20 |
_ = unicode |
|
21 |
||
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
|
22 |
def match_searched_etype(cls, req, rset, row=None, col=None, **kwargs): |
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
|
23 |
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
|
24 |
|
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
|
25 |
def view_is_not_default_view(cls, req, rset, row, col, **kwargs): |
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
|
26 |
# 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
|
27 |
vid = req.form.get('vid') |
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
|
28 |
if vid and vid != vid_from_rset(req, rset, cls.schema): |
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
|
29 |
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
|
30 |
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
|
31 |
|
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 |
def addable_etype_empty_rset(cls, req, rset, **kwargs): |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
rset._searched_etype = select.solutions[0].itervalues().next() |
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
|
40 |
eschema = cls.schema.eschema(rset._searched_etype) |
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
|
41 |
if not (eschema.is_final() or eschema.is_subobject(strict=True)) \ |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
46 |
# generic primary actions ##################################################### |
0 | 47 |
|
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
|
48 |
class SelectAction(Action): |
0 | 49 |
"""base class for link search actions. By default apply on |
50 |
any size entity result search it the current state is 'linksearch' |
|
51 |
if accept match. |
|
52 |
""" |
|
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
|
53 |
id = 'select' |
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
|
54 |
__selectors__ = (match_search_state('linksearch'), |
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
|
55 |
match_searched_etype) |
0 | 56 |
|
57 |
title = _('select') |
|
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
|
58 |
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
|
59 |
order = 0 |
0 | 60 |
|
61 |
def url(self): |
|
62 |
return linksearch_select_url(self.req, self.rset) |
|
63 |
||
64 |
||
65 |
class CancelSelectAction(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
|
66 |
id = 'cancel' |
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 |
__selectors__ = (match_search_state('linksearch'),) |
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 |
|
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 |
title = _('cancel select') |
0 | 70 |
category = 'mainactions' |
71 |
order = 10 |
|
72 |
||
73 |
def url(self): |
|
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
|
74 |
target, eid, r_type, searched_type = self.req.search_state[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 self.build_url(str(eid), |
0 | 76 |
vid='edition', __mode='normal') |
77 |
||
78 |
||
79 |
class ViewAction(Action): |
|
80 |
id = 'view' |
|
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
|
81 |
__selectors__ = (match_search_state('normal'), |
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 |
match_user_groups('users', 'managers'), |
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 |
view_is_not_default_view, |
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 |
non_final_entity()) |
0 | 85 |
|
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
|
86 |
title = _('view') |
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 |
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
|
88 |
order = 0 |
0 | 89 |
|
90 |
def url(self): |
|
91 |
params = self.req.form.copy() |
|
92 |
params.pop('vid', None) |
|
93 |
params.pop('__message', None) |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
94 |
return self.build_url(self.req.relative_path(includeparams=False), |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
95 |
**params) |
0 | 96 |
|
97 |
||
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
|
98 |
class ModifyAction(Action): |
0 | 99 |
id = 'edit' |
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 |
__selectors__ = (match_search_state('normal'), |
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
|
101 |
one_line_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
|
102 |
has_permission('update') | has_editable_relation('add')) |
0 | 103 |
|
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 |
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
|
105 |
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
|
106 |
order = 10 |
0 | 107 |
|
108 |
def url(self): |
|
109 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
|
110 |
return entity.absolute_url(vid='edition') |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
111 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
112 |
|
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
|
113 |
class MultipleEditAction(Action): |
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 |
id = 'muledit' # XXX get strange conflicts if id='edit' |
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
|
115 |
__selectors__ = (match_search_state('normal'), |
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
|
116 |
two_lines_rset, one_etype_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
|
117 |
has_permission('update')) |
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
|
118 |
|
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 |
title = _('modify') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
120 |
category = 'mainactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
121 |
order = 10 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
122 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
123 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
124 |
return self.build_url('view', rql=self.rset.rql, vid='muledit') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
125 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
126 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
127 |
# generic secondary actions ################################################### |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
128 |
|
690
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
129 |
class ManagePermissionsAction(Action): |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
130 |
id = 'addpermission' |
690
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
131 |
__selectors__ = 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
|
132 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
133 |
title = _('manage permissions') |
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 |
category = 'moreactions' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
135 |
order = 100 |
690
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
136 |
|
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
137 |
def registered(cls, vreg): |
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
138 |
if 'require_permission' in vreg.schema: |
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
139 |
cls.__selectors__ |= relation_possible('require_permission', 'subject', 'EPermission', |
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
140 |
action='add') |
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
141 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
142 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
143 |
return self.rset.get_entity(0, 0).absolute_url(vid='security') |
0 | 144 |
|
145 |
||
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
|
146 |
class DeleteAction(Action): |
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 |
id = 'delete' |
660
5233a9457f6b
work in progress, draft for manual registration
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
631
diff
changeset
|
148 |
__selectors__ = (one_line_rset, has_permission('delete')) |
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
|
149 |
|
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 |
title = _('delete') |
0 | 151 |
category = 'moreactions' |
152 |
order = 20 |
|
153 |
||
154 |
def url(self): |
|
155 |
if len(self.rset) == 1: |
|
156 |
entity = self.rset.get_entity(0, 0) |
|
157 |
return self.build_url(entity.rest_path(), vid='deleteconf') |
|
158 |
return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf') |
|
159 |
||
160 |
||
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 |
class CopyAction(Action): |
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 |
id = 'copy' |
660
5233a9457f6b
work in progress, draft for manual registration
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
631
diff
changeset
|
163 |
__selectors__ = (one_line_rset, has_permission('add')) |
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
|
164 |
|
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
|
165 |
title = _('copy') |
0 | 166 |
category = 'moreactions' |
167 |
order = 30 |
|
168 |
||
169 |
def url(self): |
|
170 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
|
171 |
return entity.absolute_url(vid='copy') |
|
172 |
||
173 |
||
174 |
class AddNewAction(MultipleEditAction): |
|
175 |
"""when we're seeing more than one entity with the same type, propose to |
|
176 |
add a new one |
|
177 |
""" |
|
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
|
178 |
id = 'addentity' |
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
|
179 |
__selectors__ = (match_search_state('normal'), |
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
|
180 |
(addable_etype_empty_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
|
181 |
# XXX has_add_permission in the middle so '&' is available |
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
|
182 |
| (two_lines_rset & has_add_permission() & one_etype_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
|
183 |
) |
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 |
|
0 | 185 |
category = 'moreactions' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
186 |
order = 40 |
0 | 187 |
|
188 |
@property |
|
189 |
def rsettype(self): |
|
190 |
if self.rset: |
|
191 |
return self.rset.description[0][0] |
|
192 |
return self.rset._searched_etype |
|
193 |
||
194 |
@property |
|
195 |
def title(self): |
|
196 |
return self.req.__('add a %s' % self.rsettype) # generated msgid |
|
197 |
||
198 |
def url(self): |
|
199 |
return self.build_url('add/%s' % self.rsettype) |
|
200 |
||
201 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
202 |
# logged user actions ######################################################### |
0 | 203 |
|
204 |
class UserPreferencesAction(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
|
205 |
id = 'myprefs' |
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
|
206 |
__selectors__ = (authenticated_user,) |
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
|
207 |
|
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
|
208 |
title = _('user preferences') |
0 | 209 |
category = 'useractions' |
210 |
order = 10 |
|
211 |
||
212 |
def url(self): |
|
213 |
return self.build_url(self.id) |
|
214 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
215 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
216 |
class UserInfoAction(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
|
217 |
id = 'myinfos' |
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 |
__selectors__ = (authenticated_user,) |
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
|
219 |
|
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
|
220 |
title = _('personnal informations') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
221 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
222 |
order = 20 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
223 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
224 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
225 |
return self.build_url('euser/%s'%self.req.user.login, vid='edition') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
226 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
227 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
228 |
class LogoutAction(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
|
229 |
id = 'logout' |
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
|
230 |
__selectors__ = (authenticated_user,) |
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
|
231 |
|
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 |
title = _('logout') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
233 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
234 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
235 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
236 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
237 |
return self.build_url(self.id) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
238 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
239 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
240 |
# site actions ################################################################ |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
241 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
242 |
class ManagersAction(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
|
243 |
__abstract__ = True |
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
|
244 |
__selectors__ = (match_user_groups('managers'),) |
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
|
245 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
246 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
247 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
248 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
249 |
return self.build_url(self.id) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
250 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
251 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
252 |
class SiteConfigurationAction(ManagersAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
253 |
id = 'siteconfig' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
254 |
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
|
255 |
order = 10 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
256 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
257 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
258 |
class ManageAction(ManagersAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
259 |
id = 'manage' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
260 |
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
|
261 |
order = 20 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
262 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
263 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
264 |
class ViewSchemaAction(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
|
265 |
id = 'schema' |
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
|
266 |
__selectors__ = (yes,) |
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
|
267 |
|
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
|
268 |
title = _("site schema") |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
269 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
270 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
271 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
272 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
273 |
return self.build_url(self.id) |