author | sylvain.thenault@logilab.fr |
Wed, 18 Feb 2009 01:42:07 +0100 | |
branch | tls-sprint |
changeset 750 | 89e997bc2bf1 |
parent 728 | a95b284150d1 |
child 753 | 17d38f000bea |
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 |
||
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
9 |
from cubicweb.vregistry import objectify_selector |
692
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
660
diff
changeset
|
10 |
from cubicweb.selectors import ( |
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
|
11 |
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
|
12 |
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
|
13 |
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
|
14 |
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
|
15 |
) |
0 | 16 |
|
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
|
17 |
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
|
18 |
from cubicweb.web.views import linksearch_select_url |
0 | 19 |
from cubicweb.web.views.baseviews import vid_from_rset |
20 |
||
21 |
_ = unicode |
|
22 |
||
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
23 |
@objectify_selector |
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
|
24 |
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
|
25 |
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
|
26 |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
27 |
@objectify_selector |
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
|
28 |
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
|
29 |
# 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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
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
|
34 |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
35 |
@objectify_selector |
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
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
50 |
# generic primary actions ##################################################### |
0 | 51 |
|
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 |
class SelectAction(Action): |
0 | 53 |
"""base class for link search actions. By default apply on |
54 |
any size entity result search it the current state is 'linksearch' |
|
55 |
if accept match. |
|
56 |
""" |
|
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
|
57 |
id = 'select' |
707 | 58 |
__select__ = match_search_state('linksearch') & match_searched_etype() |
0 | 59 |
|
60 |
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
|
61 |
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
|
62 |
order = 0 |
0 | 63 |
|
64 |
def url(self): |
|
65 |
return linksearch_select_url(self.req, self.rset) |
|
66 |
||
67 |
||
68 |
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
|
69 |
id = 'cancel' |
707 | 70 |
__select__ = match_search_state('linksearch') |
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
|
71 |
|
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
|
72 |
title = _('cancel select') |
0 | 73 |
category = 'mainactions' |
74 |
order = 10 |
|
75 |
||
76 |
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
|
77 |
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
|
78 |
return self.build_url(str(eid), |
0 | 79 |
vid='edition', __mode='normal') |
80 |
||
81 |
||
82 |
class ViewAction(Action): |
|
83 |
id = 'view' |
|
707 | 84 |
__select__ = (match_search_state('normal') & |
85 |
match_user_groups('users', 'managers') & |
|
86 |
view_is_not_default_view() & |
|
87 |
non_final_entity()) |
|
0 | 88 |
|
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
|
89 |
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
|
90 |
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
|
91 |
order = 0 |
0 | 92 |
|
93 |
def url(self): |
|
94 |
params = self.req.form.copy() |
|
95 |
params.pop('vid', None) |
|
96 |
params.pop('__message', None) |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
97 |
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
|
98 |
**params) |
0 | 99 |
|
100 |
||
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
|
101 |
class ModifyAction(Action): |
0 | 102 |
id = 'edit' |
707 | 103 |
__select__ = (match_search_state('normal') & |
104 |
one_line_rset() & |
|
105 |
(has_permission('update') | has_editable_relation('add'))) |
|
0 | 106 |
|
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
|
107 |
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
|
108 |
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
|
109 |
order = 10 |
0 | 110 |
|
111 |
def url(self): |
|
112 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
|
113 |
return entity.absolute_url(vid='edition') |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
114 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
115 |
|
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
|
116 |
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
|
117 |
id = 'muledit' # XXX get strange conflicts if id='edit' |
707 | 118 |
__select__ = (match_search_state('normal') & |
119 |
two_lines_rset(), one_etype_rset() & |
|
120 |
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
|
121 |
|
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
|
122 |
title = _('modify') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
123 |
category = 'mainactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
124 |
order = 10 |
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 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
127 |
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
|
128 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
129 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
130 |
# generic secondary actions ################################################### |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
131 |
|
690
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
132 |
class ManagePermissionsAction(Action): |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
133 |
id = 'addpermission' |
707 | 134 |
__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
|
135 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
136 |
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
|
137 |
category = 'moreactions' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
138 |
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
|
139 |
|
707 | 140 |
@classmethod |
690
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
141 |
def registered(cls, vreg): |
710
766c881e101f
overridden `registered()` methods must call the base implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
696
diff
changeset
|
142 |
super(ManagePermissionsAction, cls).registered(vreg) |
690
ea613e8a5e4f
should add relation_possible selector only if require_permission is in the schema
sylvain.thenault@logilab.fr
parents:
660
diff
changeset
|
143 |
if 'require_permission' in vreg.schema: |
707 | 144 |
cls.__select__ |= relation_possible('require_permission', 'subject', 'EPermission', |
145 |
action='add') |
|
146 |
return super(ManagePermissionsAction, cls).registered(vreg) |
|
147 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
148 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
149 |
return self.rset.get_entity(0, 0).absolute_url(vid='security') |
0 | 150 |
|
151 |
||
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
|
152 |
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
|
153 |
id = 'delete' |
707 | 154 |
__select__ = 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
|
155 |
|
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
|
156 |
title = _('delete') |
0 | 157 |
category = 'moreactions' |
158 |
order = 20 |
|
159 |
||
160 |
def url(self): |
|
161 |
if len(self.rset) == 1: |
|
162 |
entity = self.rset.get_entity(0, 0) |
|
163 |
return self.build_url(entity.rest_path(), vid='deleteconf') |
|
164 |
return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf') |
|
165 |
||
166 |
||
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
|
167 |
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
|
168 |
id = 'copy' |
707 | 169 |
__select__ = 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
|
170 |
|
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
|
171 |
title = _('copy') |
0 | 172 |
category = 'moreactions' |
173 |
order = 30 |
|
174 |
||
175 |
def url(self): |
|
176 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
|
177 |
return entity.absolute_url(vid='copy') |
|
178 |
||
179 |
||
180 |
class AddNewAction(MultipleEditAction): |
|
181 |
"""when we're seeing more than one entity with the same type, propose to |
|
182 |
add a new one |
|
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 |
id = 'addentity' |
707 | 185 |
__select__ = (match_search_state('normal') & |
186 |
(addable_etype_empty_rset() |
|
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
714
diff
changeset
|
187 |
| (two_lines_rset() & one_etype_rset & has_add_permission())) |
707 | 188 |
) |
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
|
189 |
|
0 | 190 |
category = 'moreactions' |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
191 |
order = 40 |
0 | 192 |
|
193 |
@property |
|
194 |
def rsettype(self): |
|
195 |
if self.rset: |
|
196 |
return self.rset.description[0][0] |
|
197 |
return self.rset._searched_etype |
|
198 |
||
199 |
@property |
|
200 |
def title(self): |
|
201 |
return self.req.__('add a %s' % self.rsettype) # generated msgid |
|
202 |
||
203 |
def url(self): |
|
204 |
return self.build_url('add/%s' % self.rsettype) |
|
205 |
||
206 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
207 |
# logged user actions ######################################################### |
0 | 208 |
|
209 |
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
|
210 |
id = 'myprefs' |
707 | 211 |
__select__ = authenticated_user() |
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
|
212 |
|
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
|
213 |
title = _('user preferences') |
0 | 214 |
category = 'useractions' |
215 |
order = 10 |
|
216 |
||
217 |
def url(self): |
|
218 |
return self.build_url(self.id) |
|
219 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
220 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
221 |
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
|
222 |
id = 'myinfos' |
707 | 223 |
__select__ = authenticated_user() |
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
|
224 |
|
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
|
225 |
title = _('personnal informations') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
226 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
227 |
order = 20 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
228 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
229 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
230 |
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
|
231 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
232 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
233 |
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
|
234 |
id = 'logout' |
707 | 235 |
__select__ = authenticated_user() |
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
|
236 |
|
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
|
237 |
title = _('logout') |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
238 |
category = 'useractions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
239 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
240 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
241 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
242 |
return self.build_url(self.id) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
243 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
244 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
245 |
# site actions ################################################################ |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
246 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
247 |
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
|
248 |
__abstract__ = True |
707 | 249 |
__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
|
250 |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
251 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
252 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
253 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
254 |
return self.build_url(self.id) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
255 |
|
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 |
class SiteConfigurationAction(ManagersAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
258 |
id = 'siteconfig' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
259 |
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
|
260 |
order = 10 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
261 |
|
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 |
class ManageAction(ManagersAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
264 |
id = 'manage' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
265 |
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
|
266 |
order = 20 |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
267 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
268 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
269 |
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
|
270 |
id = 'schema' |
707 | 271 |
__select__ = yes() |
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
|
272 |
|
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
|
273 |
title = _("site schema") |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
274 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
275 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
276 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
277 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
278 |
return self.build_url(self.id) |