[editform] consistent [do]reledit between attributes and relations: check if rdef is hidden in main section of uicfg.afs for both attributes and relations, and in the reledit view, not in doreledit stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 04 Jun 2010 15:45:54 +0200
branchstable
changeset 5671 3a2063b752f3
parent 5670 80dc2135bf5f
child 5672 14d2a395e8e9
[editform] consistent [do]reledit between attributes and relations: check if rdef is hidden in main section of uicfg.afs for both attributes and relations, and in the reledit view, not in doreledit
rset.py
web/views/editforms.py
--- a/rset.py	Fri Jun 04 13:09:12 2010 +0200
+++ b/rset.py	Fri Jun 04 15:45:54 2010 +0200
@@ -15,9 +15,8 @@
 #
 # You should have received a copy of the GNU Lesser General Public License along
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
-"""The `ResultSet` class which is returned as result of an rql query
+"""The `ResultSet` class which is returned as result of an rql query"""
 
-"""
 __docformat__ = "restructuredtext en"
 
 from logilab.common.decorators import cached, clear_cache, copy_cache
--- a/web/views/editforms.py	Fri Jun 04 13:09:12 2010 +0200
+++ b/web/views/editforms.py	Fri Jun 04 15:45:54 2010 +0200
@@ -340,16 +340,13 @@
                            self._build_renderer(entity, rtype, role))
 
     def should_edit_attribute(self, entity, rschema, form):
-        rtype = str(rschema)
-        rdef = entity.e_schema.rdef(rtype)
-        afs = uicfg.autoform_section.etype_get(
-            entity.__regid__, rtype, 'subject', rdef.object)
-        if 'main_hidden' in afs or not entity.has_perm('update'):
+        if not entity.has_perm('update'):
             return False
+        rdef = entity.e_schema.rdef(rschema)
         if not rdef.has_perm(self._cw, 'update', eid=entity.eid):
             return False
         try:
-            form.field_by_name(rtype, 'subject', entity.e_schema)
+            form.field_by_name(str(rschema), 'subject', entity.e_schema)
         except FieldNotFound:
             return False
         return True
@@ -437,15 +434,27 @@
     _onclick = (u"loadInlineEditionForm(%(eid)s, '%(rtype)s', '%(role)s', "
                 "'%(divid)s', %(reload)s, '%(vid)s', '%(default)s', '%(lzone)s');")
 
+    def should_edit_attribute(self, entity, rschema, form):
+        rdef = entity.e_schema.rdef(rschema)
+        afs = uicfg.autoform_section.etype_get(
+            entity.__regid__, rschema, 'subject', rdef.object)
+        if 'main_hidden' in afs:
+            return False
+        return super(AutoClickAndEditFormView, self).should_edit_attribute(
+            entity, rschema, form)
+
     def should_edit_relation(self, entity, rschema, role, rvid):
         eschema = entity.e_schema
-        rtype = str(rschema)
-        # XXX check autoform_section. what if 'generic'?
-        dispctrl = _pvdc.etype_get(eschema, rtype, role)
+        dispctrl = _pvdc.etype_get(eschema, rschema, role)
         vid = dispctrl.get('vid', 'reledit')
         if vid != 'reledit': # reledit explicitly disabled
             return False
-        if eschema.rdef(rschema, role).composite == role:
+        rdef = eschema.rdef(rschema, role)
+        if rdef.composite == role:
+            return False
+        afs = uicfg.autoform_section.etype_get(
+            entity.__regid__, rschema, role, rdef.object)
+        if 'main_hidden' in afs:
             return False
         return super(AutoClickAndEditFormView, self).should_edit_relation(
             entity, rschema, role, rvid)