651 |
651 |
652 def complete(self, cls): |
652 def complete(self, cls): |
653 self.rtype = cls.rtype |
653 self.rtype = cls.rtype |
654 self.role = role(cls) |
654 self.role = role(cls) |
655 self.target_etype = getattr(cls, 'etype', None) |
655 self.target_etype = getattr(cls, 'etype', None) |
656 |
|
657 |
|
658 class has_editable_relation(EntitySelector): |
|
659 """accept if some relations for an entity found in the result set is |
|
660 editable by the logged user. |
|
661 |
|
662 See `EntitySelector` documentation for behaviour when row is not specified. |
|
663 """ |
|
664 |
|
665 def score_entity(self, entity): |
|
666 # if user has no update right but it can modify some relation, |
|
667 # display action anyway |
|
668 for dummy in entity.srelations_by_category(('generic', 'metadata'), |
|
669 'add'): |
|
670 return 1 |
|
671 for rschema, targetschemas, role in entity.relations_by_category( |
|
672 ('primary', 'secondary'), 'add'): |
|
673 if not rschema.is_final(): |
|
674 return 1 |
|
675 return 0 |
|
676 |
656 |
677 |
657 |
678 class may_add_relation(EntitySelector): |
658 class may_add_relation(EntitySelector): |
679 """accept if the relation can be added to an entity found in the result set |
659 """accept if the relation can be added to an entity found in the result set |
680 by the logged user. |
660 by the logged user. |