# HG changeset patch # User Sylvain Thénault # Date 1275659154 -7200 # Node ID 3a2063b752f3de5397af37bc0c7e883bb065a5dc # Parent 80dc2135bf5f5817e68f68e875ec462043d34ebe [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 diff -r 80dc2135bf5f -r 3a2063b752f3 rset.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 . -"""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 diff -r 80dc2135bf5f -r 3a2063b752f3 web/views/editforms.py --- 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)