62 return linksearch_select_url(self.req, self.rset) |
61 return linksearch_select_url(self.req, self.rset) |
63 |
62 |
64 |
63 |
65 class CancelSelectAction(Action): |
64 class CancelSelectAction(Action): |
66 id = 'cancel' |
65 id = 'cancel' |
67 __selectors__ = (match_search_state('linksearch'),) |
66 __select__ = match_search_state('linksearch') |
68 |
67 |
69 title = _('cancel select') |
68 title = _('cancel select') |
70 category = 'mainactions' |
69 category = 'mainactions' |
71 order = 10 |
70 order = 10 |
72 |
71 |
76 vid='edition', __mode='normal') |
75 vid='edition', __mode='normal') |
77 |
76 |
78 |
77 |
79 class ViewAction(Action): |
78 class ViewAction(Action): |
80 id = 'view' |
79 id = 'view' |
81 __selectors__ = (match_search_state('normal'), |
80 __select__ = (match_search_state('normal') & |
82 match_user_groups('users', 'managers'), |
81 match_user_groups('users', 'managers') & |
83 view_is_not_default_view, |
82 view_is_not_default_view() & |
84 non_final_entity()) |
83 non_final_entity()) |
85 |
84 |
86 title = _('view') |
85 title = _('view') |
87 category = 'mainactions' |
86 category = 'mainactions' |
88 order = 0 |
87 order = 0 |
89 |
88 |
110 return entity.absolute_url(vid='edition') |
109 return entity.absolute_url(vid='edition') |
111 |
110 |
112 |
111 |
113 class MultipleEditAction(Action): |
112 class MultipleEditAction(Action): |
114 id = 'muledit' # XXX get strange conflicts if id='edit' |
113 id = 'muledit' # XXX get strange conflicts if id='edit' |
115 __selectors__ = (match_search_state('normal'), |
114 __select__ = (match_search_state('normal') & |
116 two_lines_rset, one_etype_rset, |
115 two_lines_rset(), one_etype_rset() & |
117 has_permission('update')) |
116 has_permission('update')) |
118 |
117 |
119 title = _('modify') |
118 title = _('modify') |
120 category = 'mainactions' |
119 category = 'mainactions' |
121 order = 10 |
120 order = 10 |
122 |
121 |
126 |
125 |
127 # generic secondary actions ################################################### |
126 # generic secondary actions ################################################### |
128 |
127 |
129 class ManagePermissionsAction(Action): |
128 class ManagePermissionsAction(Action): |
130 id = 'addpermission' |
129 id = 'addpermission' |
131 __selectors__ = match_user_groups('managers') |
130 __select__ = match_user_groups('managers') |
132 |
131 |
133 title = _('manage permissions') |
132 title = _('manage permissions') |
134 category = 'moreactions' |
133 category = 'moreactions' |
135 order = 100 |
134 order = 100 |
136 |
135 |
|
136 @classmethod |
137 def registered(cls, vreg): |
137 def registered(cls, vreg): |
138 if 'require_permission' in vreg.schema: |
138 if 'require_permission' in vreg.schema: |
139 cls.__selectors__ |= relation_possible('require_permission', 'subject', 'EPermission', |
139 cls.__select__ |= relation_possible('require_permission', 'subject', 'EPermission', |
140 action='add') |
140 action='add') |
141 |
141 return super(ManagePermissionsAction, cls).registered(vreg) |
|
142 |
142 def url(self): |
143 def url(self): |
143 return self.rset.get_entity(0, 0).absolute_url(vid='security') |
144 return self.rset.get_entity(0, 0).absolute_url(vid='security') |
144 |
145 |
145 |
146 |
146 class DeleteAction(Action): |
147 class DeleteAction(Action): |
147 id = 'delete' |
148 id = 'delete' |
148 __selectors__ = (one_line_rset, has_permission('delete')) |
149 __select__ = one_line_rset() & has_permission('delete') |
149 |
150 |
150 title = _('delete') |
151 title = _('delete') |
151 category = 'moreactions' |
152 category = 'moreactions' |
152 order = 20 |
153 order = 20 |
153 |
154 |
174 class AddNewAction(MultipleEditAction): |
175 class AddNewAction(MultipleEditAction): |
175 """when we're seeing more than one entity with the same type, propose to |
176 """when we're seeing more than one entity with the same type, propose to |
176 add a new one |
177 add a new one |
177 """ |
178 """ |
178 id = 'addentity' |
179 id = 'addentity' |
179 __selectors__ = (match_search_state('normal'), |
180 __select__ = (match_search_state('normal') & |
180 (addable_etype_empty_rset |
181 (addable_etype_empty_rset() |
181 # XXX has_add_permission in the middle so '&' is available |
182 | (two_lines_rset() & one_etype_rset & & has_add_permission())) |
182 | (two_lines_rset & has_add_permission() & one_etype_rset )) |
183 ) |
183 ) |
|
184 |
184 |
185 category = 'moreactions' |
185 category = 'moreactions' |
186 order = 40 |
186 order = 40 |
187 |
187 |
188 @property |
188 @property |
201 |
201 |
202 # logged user actions ######################################################### |
202 # logged user actions ######################################################### |
203 |
203 |
204 class UserPreferencesAction(Action): |
204 class UserPreferencesAction(Action): |
205 id = 'myprefs' |
205 id = 'myprefs' |
206 __selectors__ = (authenticated_user,) |
206 __select__ = authenticated_user() |
207 |
207 |
208 title = _('user preferences') |
208 title = _('user preferences') |
209 category = 'useractions' |
209 category = 'useractions' |
210 order = 10 |
210 order = 10 |
211 |
211 |
213 return self.build_url(self.id) |
213 return self.build_url(self.id) |
214 |
214 |
215 |
215 |
216 class UserInfoAction(Action): |
216 class UserInfoAction(Action): |
217 id = 'myinfos' |
217 id = 'myinfos' |
218 __selectors__ = (authenticated_user,) |
218 __select__ = authenticated_user() |
219 |
219 |
220 title = _('personnal informations') |
220 title = _('personnal informations') |
221 category = 'useractions' |
221 category = 'useractions' |
222 order = 20 |
222 order = 20 |
223 |
223 |
239 |
239 |
240 # site actions ################################################################ |
240 # site actions ################################################################ |
241 |
241 |
242 class ManagersAction(Action): |
242 class ManagersAction(Action): |
243 __abstract__ = True |
243 __abstract__ = True |
244 __selectors__ = (match_user_groups('managers'),) |
244 __select__ = match_user_groups('managers') |
245 |
245 |
246 category = 'siteactions' |
246 category = 'siteactions' |
247 |
247 |
248 def url(self): |
248 def url(self): |
249 return self.build_url(self.id) |
249 return self.build_url(self.id) |