81 displayable on single entity result if accept match. |
81 displayable on single entity result if accept match. |
82 """ |
82 """ |
83 # XXX deprecate |
83 # XXX deprecate |
84 |
84 |
85 |
85 |
86 class LinkToEntityAction(EntityAction): |
86 class LinkToEntityAction(Action): |
87 """base class for actions consisting to create a new object |
87 """base class for actions consisting to create a new object |
88 with an initial relation set to an entity. |
88 with an initial relation set to an entity. |
89 Additionaly to EntityAction behaviour, this class is parametrized |
89 Additionaly to EntityAction behaviour, this class is parametrized |
90 using .etype, .rtype and .target attributes to check if the |
90 using .etype, .rtype and .target attributes to check if the |
91 action apply and if the logged user has access to it |
91 action apply and if the logged user has access to it |
92 """ |
92 """ |
93 def my_selector(cls, req, rset, row=None, col=0, **kwargs): |
93 def my_selector(cls, req, rset, row=None, col=0, **kwargs): |
94 return chainall(match_search_state('normal'), |
94 return chainall(match_search_state('normal'), |
95 one_line_rset, accept, |
95 one_line_rset, |
96 relation_possible(cls.rtype, role(cls), cls.etype, |
96 relation_possible(cls.rtype, role(cls), cls.etype, |
97 permission='add'), |
97 permission='add'), |
98 may_add_relation(cls.rtype, role(cls))) |
98 may_add_relation(cls.rtype, role(cls))) |
99 __selectors__ = my_selector, |
99 __selectors__ = (my_selector,) |
|
100 registered = accepts_compat(Action.registered.im_func) |
100 |
101 |
101 category = 'addrelated' |
102 category = 'addrelated' |
102 |
103 |
103 def url(self): |
104 def url(self): |
104 current_entity = self.rset.get_entity(self.row or 0, self.col or 0) |
105 current_entity = self.rset.get_entity(self.row or 0, self.col or 0) |