author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Mon, 16 Feb 2009 16:24:24 +0100 | |
branch | tls-sprint |
changeset 630 | 66ff0b2f7d03 |
parent 554 | f412343c89ad |
child 631 | 99f5852f8604 |
child 1213 | 06789a89f91f |
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 |
||
554
f412343c89ad
[actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
9 |
from cubicweb.common.selectors import (searchstate_accept, match_user_group, yes, |
f412343c89ad
[actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
10 |
one_line_rset, two_lines_rset, one_etype_rset, |
f412343c89ad
[actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
11 |
authenticated_user, |
f412343c89ad
[actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
12 |
match_search_state, chainfirst, chainall) |
0 | 13 |
|
554
f412343c89ad
[actions] import * : just say no
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
431
diff
changeset
|
14 |
from cubicweb.web.action import Action, EntityAction, LinkToEntityAction |
0 | 15 |
from cubicweb.web.views import linksearch_select_url, linksearch_match |
16 |
from cubicweb.web.views.baseviews import vid_from_rset |
|
17 |
||
18 |
_ = unicode |
|
19 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
20 |
# generic primary actions ##################################################### |
0 | 21 |
|
22 |
class SelectAction(EntityAction): |
|
23 |
"""base class for link search actions. By default apply on |
|
24 |
any size entity result search it the current state is 'linksearch' |
|
25 |
if accept match. |
|
26 |
""" |
|
27 |
category = 'mainactions' |
|
254
b1eda3dd844a
more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
28 |
__selectors__ = (searchstate_accept,) |
0 | 29 |
search_states = ('linksearch',) |
30 |
order = 0 |
|
31 |
||
32 |
id = 'select' |
|
33 |
title = _('select') |
|
34 |
||
35 |
@classmethod |
|
36 |
def accept_rset(cls, req, rset, row, col): |
|
37 |
return linksearch_match(req, rset) |
|
38 |
||
39 |
def url(self): |
|
40 |
return linksearch_select_url(self.req, self.rset) |
|
41 |
||
42 |
||
43 |
class CancelSelectAction(Action): |
|
44 |
category = 'mainactions' |
|
45 |
search_states = ('linksearch',) |
|
46 |
order = 10 |
|
47 |
||
48 |
id = 'cancel' |
|
49 |
title = _('cancel select') |
|
50 |
||
51 |
def url(self): |
|
52 |
target, link_eid, r_type, searched_type = self.req.search_state[1] |
|
53 |
return self.build_url(rql="Any X WHERE X eid %s" % link_eid, |
|
54 |
vid='edition', __mode='normal') |
|
55 |
||
56 |
||
57 |
class ViewAction(Action): |
|
58 |
category = 'mainactions' |
|
431 | 59 |
__selectors__ = (match_user_group, searchstate_accept) |
0 | 60 |
require_groups = ('users', 'managers') |
61 |
order = 0 |
|
62 |
||
63 |
id = 'view' |
|
64 |
title = _('view') |
|
65 |
||
66 |
@classmethod |
|
67 |
def accept_rset(cls, req, rset, row, col): |
|
68 |
# interesting if it propose another view than the current one |
|
69 |
vid = req.form.get('vid') |
|
70 |
if vid and vid != vid_from_rset(req, rset, cls.schema): |
|
71 |
return 1 |
|
72 |
return 0 |
|
73 |
||
74 |
def url(self): |
|
75 |
params = self.req.form.copy() |
|
76 |
params.pop('vid', None) |
|
77 |
params.pop('__message', None) |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
78 |
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
|
79 |
**params) |
0 | 80 |
|
81 |
||
82 |
class ModifyAction(EntityAction): |
|
83 |
category = 'mainactions' |
|
254
b1eda3dd844a
more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
84 |
__selectors__ = (one_line_rset, searchstate_accept) |
b1eda3dd844a
more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
85 |
#__selectors__ = searchstate_accept, |
0 | 86 |
schema_action = 'update' |
87 |
order = 10 |
|
88 |
||
89 |
id = 'edit' |
|
90 |
title = _('modify') |
|
91 |
||
92 |
@classmethod |
|
93 |
def has_permission(cls, entity, action): |
|
94 |
if entity.has_perm(action): |
|
95 |
return True |
|
96 |
# if user has no update right but it can modify some relation, |
|
97 |
# display action anyway |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
98 |
for dummy in entity.srelations_by_category(('generic', 'metadata'), |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
99 |
'add'): |
0 | 100 |
return True |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
101 |
for rschema, targetschemas, role in entity.relations_by_category( |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
102 |
('primary', 'secondary'), 'add'): |
0 | 103 |
if not rschema.is_final(): |
104 |
return True |
|
105 |
return False |
|
106 |
||
107 |
def url(self): |
|
108 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
|
109 |
return entity.absolute_url(vid='edition') |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
110 |
|
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 |
class MultipleEditAction(EntityAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
113 |
category = 'mainactions' |
431 | 114 |
__selectors__ = (two_lines_rset, one_etype_rset, |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
115 |
searchstate_accept) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
116 |
schema_action = 'update' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
117 |
order = 10 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
118 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
119 |
id = 'muledit' # XXX get strange conflicts if id='edit' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
120 |
title = _('modify') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
121 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
122 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
123 |
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
|
124 |
|
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 |
# generic secondary actions ################################################### |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
127 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
128 |
class ManagePermissions(LinkToEntityAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
129 |
accepts = ('Any',) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
130 |
category = 'moreactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
131 |
id = 'addpermission' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
132 |
title = _('manage permissions') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
133 |
order = 100 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
134 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
135 |
etype = 'EPermission' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
136 |
rtype = 'require_permission' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
137 |
target = 'object' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
138 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
139 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
140 |
return self.rset.get_entity(0, 0).absolute_url(vid='security') |
0 | 141 |
|
142 |
||
143 |
class DeleteAction(EntityAction): |
|
144 |
category = 'moreactions' |
|
254
b1eda3dd844a
more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
145 |
__selectors__ = (searchstate_accept,) |
0 | 146 |
schema_action = 'delete' |
147 |
order = 20 |
|
148 |
||
149 |
id = 'delete' |
|
150 |
title = _('delete') |
|
151 |
||
152 |
def url(self): |
|
153 |
if len(self.rset) == 1: |
|
154 |
entity = self.rset.get_entity(0, 0) |
|
155 |
return self.build_url(entity.rest_path(), vid='deleteconf') |
|
156 |
return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf') |
|
157 |
||
158 |
||
159 |
class CopyAction(EntityAction): |
|
160 |
category = 'moreactions' |
|
161 |
schema_action = 'add' |
|
162 |
order = 30 |
|
163 |
||
164 |
id = 'copy' |
|
165 |
title = _('copy') |
|
166 |
||
167 |
def url(self): |
|
168 |
entity = self.rset.get_entity(self.row or 0, self.col or 0) |
|
169 |
return entity.absolute_url(vid='copy') |
|
170 |
||
171 |
||
172 |
class AddNewAction(MultipleEditAction): |
|
173 |
"""when we're seeing more than one entity with the same type, propose to |
|
174 |
add a new one |
|
175 |
""" |
|
176 |
category = 'moreactions' |
|
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
177 |
id = 'addentity' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
178 |
order = 40 |
0 | 179 |
|
180 |
def etype_rset_selector(cls, req, rset, **kwargs): |
|
181 |
if rset is not None and not rset.rowcount: |
|
182 |
rqlst = rset.syntax_tree() |
|
183 |
if len(rqlst.children) > 1: |
|
184 |
return 0 |
|
185 |
select = rqlst.children[0] |
|
186 |
if len(select.defined_vars) == 1 and len(select.solutions) == 1: |
|
328
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
187 |
rset._searched_etype = select.solutions[0].itervalues().next() |
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
188 |
eschema = cls.schema.eschema(rset._searched_etype) |
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
189 |
if not (eschema.is_final() or eschema.is_subobject(strict=True)) \ |
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
190 |
and eschema.has_perm(req, 'add'): |
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
191 |
return 1 |
0 | 192 |
return 0 |
193 |
||
194 |
def has_add_perm_selector(cls, req, rset, **kwargs): |
|
195 |
eschema = cls.schema.eschema(rset.description[0][0]) |
|
328
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
196 |
if not (eschema.is_final() or eschema.is_subobject(strict=True)) \ |
02abf429dd91
don't show add new action for composed objects
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
254
diff
changeset
|
197 |
and eschema.has_perm(req, 'add'): |
0 | 198 |
return 1 |
199 |
return 0 |
|
254
b1eda3dd844a
more selector renaming
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
200 |
__selectors__ = (match_search_state, |
0 | 201 |
chainfirst(etype_rset_selector, |
431 | 202 |
chainall(two_lines_rset, one_etype_rset, |
0 | 203 |
has_add_perm_selector))) |
204 |
||
205 |
@property |
|
206 |
def rsettype(self): |
|
207 |
if self.rset: |
|
208 |
return self.rset.description[0][0] |
|
209 |
return self.rset._searched_etype |
|
210 |
||
211 |
@property |
|
212 |
def title(self): |
|
213 |
return self.req.__('add a %s' % self.rsettype) # generated msgid |
|
214 |
||
215 |
def url(self): |
|
216 |
return self.build_url('add/%s' % self.rsettype) |
|
217 |
||
218 |
||
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
219 |
# logged user actions ######################################################### |
0 | 220 |
|
221 |
class UserPreferencesAction(Action): |
|
222 |
category = 'useractions' |
|
431 | 223 |
__selectors__ = authenticated_user, |
0 | 224 |
order = 10 |
225 |
||
226 |
id = 'myprefs' |
|
227 |
title = _('user preferences') |
|
228 |
||
229 |
def url(self): |
|
230 |
return self.build_url(self.id) |
|
231 |
||
401
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 UserInfoAction(Action): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
234 |
category = 'useractions' |
431 | 235 |
__selectors__ = authenticated_user, |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
236 |
order = 20 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
237 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
238 |
id = 'myinfos' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
239 |
title = _('personnal informations') |
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('euser/%s'%self.req.user.login, vid='edition') |
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 |
class LogoutAction(Action): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
246 |
category = 'useractions' |
431 | 247 |
__selectors__ = authenticated_user, |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
248 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
249 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
250 |
id = 'logout' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
251 |
title = _('logout') |
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 |
# site actions ################################################################ |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
258 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
259 |
class ManagersAction(Action): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
260 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
261 |
__abstract__ = True |
431 | 262 |
__selectors__ = match_user_group, |
401
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
263 |
require_groups = ('managers',) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
264 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
265 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
266 |
return self.build_url(self.id) |
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 SiteConfigurationAction(ManagersAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
270 |
order = 10 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
271 |
id = 'siteconfig' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
272 |
title = _('site configuration') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
273 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
274 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
275 |
class ManageAction(ManagersAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
276 |
order = 20 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
277 |
id = 'manage' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
278 |
title = _('manage') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
279 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
280 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
281 |
class ViewSchemaAction(Action): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
282 |
category = 'siteactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
283 |
id = 'schema' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
284 |
title = _("site schema") |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
285 |
__selectors__ = yes, |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
286 |
order = 30 |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
287 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
288 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
289 |
return self.build_url(self.id) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
290 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
291 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
292 |
# content type specific actions ############################################### |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
293 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
294 |
class FollowAction(EntityAction): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
295 |
category = 'mainactions' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
296 |
accepts = ('Bookmark',) |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
297 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
298 |
id = 'follow' |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
299 |
title = _('follow') |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
300 |
|
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
301 |
def url(self): |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
302 |
return self.rset.get_entity(self.row or 0, self.col or 0).actual_url() |
bc55a104d636
cleanup, backport manage perm action from jpl
sylvain.thenault@logilab.fr
parents:
328
diff
changeset
|
303 |
|
0 | 304 |
class UserPreferencesEntityAction(EntityAction): |
431 | 305 |
__selectors__ = EntityAction.__selectors__ + (one_line_rset, match_user_group,) |
0 | 306 |
require_groups = ('owners', 'managers') |
307 |
category = 'mainactions' |
|
308 |
accepts = ('EUser',) |
|
309 |
||
310 |
id = 'prefs' |
|
311 |
title = _('preferences') |
|
312 |
||
313 |
def url(self): |
|
314 |
login = self.rset.get_entity(self.row or 0, self.col or 0).login |
|
315 |
return self.build_url('euser/%s'%login, vid='epropertiesform') |
|
316 |