author | sylvain.thenault@logilab.fr |
Thu, 16 Apr 2009 18:51:14 +0200 | |
changeset 1385 | 41fe68a4f94c |
parent 1248 | 4a8c5f8ddff5 |
child 1263 | 01152fffd593 |
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, |
1213
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
11 |
authenticated_user, none_rset, |
554
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) |
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 |
||
1213
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
316 |
# schema view action |
1248
4a8c5f8ddff5
only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents:
1213
diff
changeset
|
317 |
def schema_view(cls, req, rset, row=None, col=None, view=None, |
4a8c5f8ddff5
only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents:
1213
diff
changeset
|
318 |
**kwargs): |
4a8c5f8ddff5
only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents:
1213
diff
changeset
|
319 |
if view is None or not view.id == 'schema': |
4a8c5f8ddff5
only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents:
1213
diff
changeset
|
320 |
return 0 |
4a8c5f8ddff5
only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents:
1213
diff
changeset
|
321 |
return 1 |
1213
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
322 |
|
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
323 |
class DownloadOWLSchemaAction(Action): |
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
324 |
category = 'mainactions' |
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
325 |
id = 'download_as_owl' |
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
326 |
title = _('download schema as owl') |
1248
4a8c5f8ddff5
only show owl action when displaying the schema view
sylvain.thenault@logilab.fr
parents:
1213
diff
changeset
|
327 |
__selectors__ = none_rset, schema_view |
1213
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
328 |
|
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
329 |
def url(self): |
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
330 |
return self.build_url('view', vid='owl') |
06789a89f91f
adding action to startup schema view. this action enables to
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
554
diff
changeset
|
331 |