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