405 res = {} |
405 res = {} |
406 for a in self.vreg['actions'].poss_visible_objects(req, rset=rset): |
406 for a in self.vreg['actions'].poss_visible_objects(req, rset=rset): |
407 if a.category not in skipcategories: |
407 if a.category not in skipcategories: |
408 res.setdefault(a.category, []).append(a.__class__) |
408 res.setdefault(a.category, []).append(a.__class__) |
409 return res |
409 return res |
|
410 |
|
411 def action_submenu(self, req, rset, id): |
|
412 return self._test_action(self.vreg['actions'].select(id, req, rset=rset)) |
|
413 |
|
414 def _test_action(self, action): |
|
415 class fake_menu(list): |
|
416 @property |
|
417 def items(self): |
|
418 return self |
|
419 class fake_box(object): |
|
420 def mk_action(self, label, url, **kwargs): |
|
421 return (label, url) |
|
422 def box_action(self, action, **kwargs): |
|
423 return (action.title, action.url()) |
|
424 submenu = fake_menu() |
|
425 action.fill_menu(fake_box(), submenu) |
|
426 return submenu |
410 |
427 |
411 def list_views_for(self, rset): |
428 def list_views_for(self, rset): |
412 """returns the list of views that can be applied on `rset`""" |
429 """returns the list of views that can be applied on `rset`""" |
413 req = rset.req |
430 req = rset.req |
414 only_once_vids = ('primary', 'secondary', 'text') |
431 only_once_vids = ('primary', 'secondary', 'text') |
782 rset.req.reset_headers(), 'main-template') |
799 rset.req.reset_headers(), 'main-template') |
783 # We have to do this because some views modify the |
800 # We have to do this because some views modify the |
784 # resultset's syntax tree |
801 # resultset's syntax tree |
785 rset = backup_rset |
802 rset = backup_rset |
786 for action in self.list_actions_for(rset): |
803 for action in self.list_actions_for(rset): |
787 yield InnerTest(self._testname(rset, action.id, 'action'), action.url) |
804 yield InnerTest(self._testname(rset, action.id, 'action'), self._test_action, action) |
788 for box in self.list_boxes_for(rset): |
805 for box in self.list_boxes_for(rset): |
789 yield InnerTest(self._testname(rset, box.id, 'box'), box.render) |
806 yield InnerTest(self._testname(rset, box.id, 'box'), box.render) |
790 |
807 |
791 @staticmethod |
808 @staticmethod |
792 def _testname(rset, objid, objtype): |
809 def _testname(rset, objid, objtype): |