equal
deleted
inserted
replaced
72 class SelectAction(Action): |
72 class SelectAction(Action): |
73 """base class for link search actions. By default apply on |
73 """base class for link search actions. By default apply on |
74 any size entity result search it the current state is 'linksearch' |
74 any size entity result search it the current state is 'linksearch' |
75 if accept match. |
75 if accept match. |
76 """ |
76 """ |
77 id = 'select' |
77 __regid__ = 'select' |
78 __select__ = match_search_state('linksearch') & nonempty_rset() & match_searched_etype() |
78 __select__ = match_search_state('linksearch') & nonempty_rset() & match_searched_etype() |
79 |
79 |
80 title = _('select') |
80 title = _('select') |
81 category = 'mainactions' |
81 category = 'mainactions' |
82 order = 0 |
82 order = 0 |
84 def url(self): |
84 def url(self): |
85 return linksearch_select_url(self.req, self.rset) |
85 return linksearch_select_url(self.req, self.rset) |
86 |
86 |
87 |
87 |
88 class CancelSelectAction(Action): |
88 class CancelSelectAction(Action): |
89 id = 'cancel' |
89 __regid__ = 'cancel' |
90 __select__ = match_search_state('linksearch') |
90 __select__ = match_search_state('linksearch') |
91 |
91 |
92 title = _('cancel select') |
92 title = _('cancel select') |
93 category = 'mainactions' |
93 category = 'mainactions' |
94 order = 10 |
94 order = 10 |
98 return self.build_url(str(eid), |
98 return self.build_url(str(eid), |
99 vid='edition', __mode='normal') |
99 vid='edition', __mode='normal') |
100 |
100 |
101 |
101 |
102 class ViewAction(Action): |
102 class ViewAction(Action): |
103 id = 'view' |
103 __regid__ = 'view' |
104 __select__ = (match_search_state('normal') & |
104 __select__ = (match_search_state('normal') & |
105 match_user_groups('users', 'managers') & |
105 match_user_groups('users', 'managers') & |
106 view_is_not_default_view() & |
106 view_is_not_default_view() & |
107 non_final_entity()) |
107 non_final_entity()) |
108 |
108 |
117 return self.build_url(self.req.relative_path(includeparams=False), |
117 return self.build_url(self.req.relative_path(includeparams=False), |
118 **params) |
118 **params) |
119 |
119 |
120 |
120 |
121 class ModifyAction(Action): |
121 class ModifyAction(Action): |
122 id = 'edit' |
122 __regid__ = 'edit' |
123 __select__ = (match_search_state('normal') & |
123 __select__ = (match_search_state('normal') & |
124 one_line_rset() & |
124 one_line_rset() & |
125 (has_permission('update') | has_editable_relation('add'))) |
125 (has_permission('update') | has_editable_relation('add'))) |
126 |
126 |
127 title = _('modify') |
127 title = _('modify') |
132 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
132 entity = self.rset.get_entity(self.row or 0, self.col or 0) |
133 return entity.absolute_url(vid='edition') |
133 return entity.absolute_url(vid='edition') |
134 |
134 |
135 |
135 |
136 class MultipleEditAction(Action): |
136 class MultipleEditAction(Action): |
137 id = 'muledit' # XXX get strange conflicts if id='edit' |
137 __regid__ = 'muledit' # XXX get strange conflicts if id='edit' |
138 __select__ = (match_search_state('normal') & |
138 __select__ = (match_search_state('normal') & |
139 two_lines_rset() & one_etype_rset() & |
139 two_lines_rset() & one_etype_rset() & |
140 has_permission('update')) |
140 has_permission('update')) |
141 |
141 |
142 title = _('modify') |
142 title = _('modify') |
148 |
148 |
149 |
149 |
150 # generic "more" actions ####################################################### |
150 # generic "more" actions ####################################################### |
151 |
151 |
152 class ManagePermissionsAction(Action): |
152 class ManagePermissionsAction(Action): |
153 id = 'managepermission' |
153 __regid__ = 'managepermission' |
154 __select__ = one_line_rset() & non_final_entity() & match_user_groups('managers') |
154 __select__ = one_line_rset() & non_final_entity() & match_user_groups('managers') |
155 |
155 |
156 title = _('manage permissions') |
156 title = _('manage permissions') |
157 category = 'moreactions' |
157 category = 'moreactions' |
158 order = 15 |
158 order = 15 |
169 def url(self): |
169 def url(self): |
170 return self.rset.get_entity(self.row or 0, self.col or 0).absolute_url(vid='security') |
170 return self.rset.get_entity(self.row or 0, self.col or 0).absolute_url(vid='security') |
171 |
171 |
172 |
172 |
173 class DeleteAction(Action): |
173 class DeleteAction(Action): |
174 id = 'delete' |
174 __regid__ = 'delete' |
175 __select__ = has_permission('delete') |
175 __select__ = has_permission('delete') |
176 |
176 |
177 title = _('delete') |
177 title = _('delete') |
178 category = 'moreactions' |
178 category = 'moreactions' |
179 order = 20 |
179 order = 20 |
184 return self.build_url(entity.rest_path(), vid='deleteconf') |
184 return self.build_url(entity.rest_path(), vid='deleteconf') |
185 return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf') |
185 return self.build_url(rql=self.rset.printable_rql(), vid='deleteconf') |
186 |
186 |
187 |
187 |
188 class CopyAction(Action): |
188 class CopyAction(Action): |
189 id = 'copy' |
189 __regid__ = 'copy' |
190 __select__ = one_line_rset() & has_permission('add') |
190 __select__ = one_line_rset() & has_permission('add') |
191 |
191 |
192 title = _('copy') |
192 title = _('copy') |
193 category = 'moreactions' |
193 category = 'moreactions' |
194 order = 30 |
194 order = 30 |
200 |
200 |
201 class AddNewAction(MultipleEditAction): |
201 class AddNewAction(MultipleEditAction): |
202 """when we're seeing more than one entity with the same type, propose to |
202 """when we're seeing more than one entity with the same type, propose to |
203 add a new one |
203 add a new one |
204 """ |
204 """ |
205 id = 'addentity' |
205 __regid__ = 'addentity' |
206 __select__ = (match_search_state('normal') & |
206 __select__ = (match_search_state('normal') & |
207 (addable_etype_empty_rset() |
207 (addable_etype_empty_rset() |
208 | (two_lines_rset() & one_etype_rset & has_add_permission())) |
208 | (two_lines_rset() & one_etype_rset & has_add_permission())) |
209 ) |
209 ) |
210 |
210 |
225 return self.build_url('add/%s' % self.rsettype) |
225 return self.build_url('add/%s' % self.rsettype) |
226 |
226 |
227 |
227 |
228 class AddRelatedActions(Action): |
228 class AddRelatedActions(Action): |
229 """fill 'addrelated' sub-menu of the actions box""" |
229 """fill 'addrelated' sub-menu of the actions box""" |
230 id = 'addrelated' |
230 __regid__ = 'addrelated' |
231 __select__ = Action.__select__ & one_line_rset() & non_final_entity() |
231 __select__ = Action.__select__ & one_line_rset() & non_final_entity() |
232 |
232 |
233 submenu = _('addrelated') |
233 submenu = _('addrelated') |
234 order = 20 |
234 order = 20 |
235 |
235 |
291 |
291 |
292 |
292 |
293 # logged user actions ######################################################### |
293 # logged user actions ######################################################### |
294 |
294 |
295 class UserPreferencesAction(Action): |
295 class UserPreferencesAction(Action): |
296 id = 'myprefs' |
296 __regid__ = 'myprefs' |
297 __select__ = authenticated_user() |
297 __select__ = authenticated_user() |
298 |
298 |
299 title = _('user preferences') |
299 title = _('user preferences') |
300 category = 'useractions' |
300 category = 'useractions' |
301 order = 10 |
301 order = 10 |
303 def url(self): |
303 def url(self): |
304 return self.build_url(self.id) |
304 return self.build_url(self.id) |
305 |
305 |
306 |
306 |
307 class UserInfoAction(Action): |
307 class UserInfoAction(Action): |
308 id = 'myinfos' |
308 __regid__ = 'myinfos' |
309 __select__ = authenticated_user() |
309 __select__ = authenticated_user() |
310 |
310 |
311 title = _('personnal informations') |
311 title = _('personnal informations') |
312 category = 'useractions' |
312 category = 'useractions' |
313 order = 20 |
313 order = 20 |
315 def url(self): |
315 def url(self): |
316 return self.build_url('cwuser/%s'%self.req.user.login, vid='edition') |
316 return self.build_url('cwuser/%s'%self.req.user.login, vid='edition') |
317 |
317 |
318 |
318 |
319 class LogoutAction(Action): |
319 class LogoutAction(Action): |
320 id = 'logout' |
320 __regid__ = 'logout' |
321 __select__ = authenticated_user() |
321 __select__ = authenticated_user() |
322 |
322 |
323 title = _('logout') |
323 title = _('logout') |
324 category = 'useractions' |
324 category = 'useractions' |
325 order = 30 |
325 order = 30 |
339 def url(self): |
339 def url(self): |
340 return self.build_url(self.id) |
340 return self.build_url(self.id) |
341 |
341 |
342 |
342 |
343 class SiteConfigurationAction(ManagersAction): |
343 class SiteConfigurationAction(ManagersAction): |
344 id = 'siteconfig' |
344 __regid__ = 'siteconfig' |
345 title = _('site configuration') |
345 title = _('site configuration') |
346 order = 10 |
346 order = 10 |
347 |
347 |
348 |
348 |
349 class ManageAction(ManagersAction): |
349 class ManageAction(ManagersAction): |
350 id = 'manage' |
350 __regid__ = 'manage' |
351 title = _('manage') |
351 title = _('manage') |
352 order = 20 |
352 order = 20 |
353 |
353 |
354 class SiteInfoAction(ManagersAction): |
354 class SiteInfoAction(ManagersAction): |
355 id = 'siteinfo' |
355 __regid__ = 'siteinfo' |
|
356 __select__ = match_user_groups('users','managers') |
356 title = _('info') |
357 title = _('info') |
357 order = 30 |
358 order = 30 |
358 __select__ = match_user_groups('users','managers') |
|
359 |
359 |
360 |
360 |
361 from logilab.common.deprecation import class_moved |
361 from logilab.common.deprecation import class_moved |
362 from cubicweb.web.views.bookmark import FollowAction |
362 from cubicweb.web.views.bookmark import FollowAction |
363 FollowAction = class_moved(FollowAction) |
363 FollowAction = class_moved(FollowAction) |