[reledit] also check for cardinality before displaying the delete relation action. Closes #5334750
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 05 May 2015 15:36:56 +0200
changeset 10372 9222e056584e
parent 10348 b9bb4296133d
child 10373 9579cd21412d
[reledit] also check for cardinality before displaying the delete relation action. Closes #5334750
web/views/reledit.py
--- a/web/views/reledit.py	Tue Apr 28 17:00:35 2015 +0200
+++ b/web/views/reledit.py	Tue May 05 15:36:56 2015 +0200
@@ -213,8 +213,12 @@
         entity = self.entity
         if role == 'subject':
             kwargs = {'fromeid': entity.eid, 'toeid': rentity.eid}
+            cardinality = rschema.rdefs[(entity.cw_etype, rentity.cw_etype)].cardinality[0]
         else:
             kwargs = {'fromeid': rentity.eid, 'toeid': entity.eid}
+            cardinality = rschema.rdefs[(rentity.cw_etype, entity.cw_etype)].cardinality[1]
+        if cardinality in '1+':
+            return False
         # NOTE: should be sufficient given a well built schema/security
         return rschema.has_perm(self._cw, 'delete', **kwargs)