don't propose inlined form if user can't edit the entity stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Sep 2009 19:51:13 +0200
branchstable
changeset 3330 2fa09be849e7
parent 3329 8430f6c693a1
child 3331 8e63b72287b1
don't propose inlined form if user can't edit the entity
web/views/formrenderers.py
--- a/web/views/formrenderers.py	Fri Sep 18 19:50:37 2009 +0200
+++ b/web/views/formrenderers.py	Fri Sep 18 19:51:13 2009 +0200
@@ -491,11 +491,16 @@
         __ = self.req.pgettext
         i18nctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role)
         w(u'<div id="inline%sslot">' % rschema)
-        existant = entity.has_eid() and entity.related(rschema)
-        if existant:
+        existant = False
+        related = entity.has_eid() and entity.related(rschema, role)
+        if related:
             # display inline-edition view for all existing related entities
-            w(form.view('inline-edition', existant, rtype=rschema, role=role,
-                        ptype=entity.e_schema, peid=entity.eid))
+            for i, relentity in enumerate(related.entities()):
+                if relentity.has_perm('update'):
+                    w(form.view('inline-edition', related, row=i, col=0,
+                                rtype=rschema, role=role, ptype=entity.e_schema,
+                                peid=entity.eid, i18nctx=i18nctx))
+                    existant = True
         if role == 'subject':
             card = rschema.rproperty(entity.e_schema, targettype, 'cardinality')[0]
         else:
@@ -524,6 +529,7 @@
         w(u'</div>')
 
 
+
 class EntityInlinedFormRenderer(EntityFormRenderer):
     """specific renderer for entity inlined edition form
     (inline-[creation|edition])